# Follow up to - How to target robot at a specific window?

**URL:** <https://forum.katalon.com/t/follow-up-to-how-to-target-robot-at-a-specific-window/131121>\
**Category:** Miscellaneous\
**Created:** [May 14, 2024, 4:14pm UTC](https://forum.katalon.com/t/follow-up-to-how-to-target-robot-at-a-specific-window/131121 "2024-05-14T16:14:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kevin.jackey](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kevin.jackey/32/22420_2.png) [@kevin.jackey](https://forum.katalon.com/u/kevin.jackey)\
**Post date:** [May 14, 2024, 4:14pm UTC](https://forum.katalon.com/t/follow-up-to-how-to-target-robot-at-a-specific-window/131121/1 "2024-05-14T16:14:07Z")

</div>

Well, Katalon cursed us by converting [How to target robot at a specific window?](http://forum.katalon.com/t/how-to-target-robot-at-a-specific-window/129757) into a blog post 🙂

Essentially it appears that Javascript has built functionality that puts some significant constraints on the window.close() javascript function in that the targeted window now has to be explicitly called out, as noted in the following section from [Window: close() method - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/close), which I had not encountered because the scripts I was previously using this function against only opened a single page and then closed it, thus putting them into the “top-level windows that have a single history entry” category

“This method can only be called on windows that were opened by a script using the Window.open() method, or on top-level windows that have a single history entry. If the window doesn’t match these requirements, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.”

For more complex scripts, I’m at a loss as to how to do this, as the method described in the linked article -

```auto
//Global variable to store a reference to the opened window
let openedWindow;

function openWindow() {
  openedWindow = window.open("moreinfo.htm");
}

function closeOpenedWindow() {
  openedWindow.close();
}

```

Only works for Javascript opened windows, which I am failing to get the Katalon webdriver to recognize. On the flip side I can’t figure out how to put the WebDriver object into a javascript-recognized object such as myWindow to use in the myWindow.close() javascript call.

Anyone have any suggestions on how I might get this to work in Katalon, as if I have to stick to the javascript opening method and am unable to use the Katalon web functions I might as well forget Katalon for this instance and just move to basic Selenuim?

---

_[View the full topic](https://forum.katalon.com/t/follow-up-to-how-to-target-robot-at-a-specific-window/131121)._
