On Thu, Sep 25, 2014 at 5:37 AM, Forged <
andrew....@gmail.com> wrote:
> We are currently testing an IE based application, the behavior of this
> system is once a button is clicked, it opens a new window and closes the old
> one automatically. Most of the guides I found on google involves multiple
> windows that are simultaneously open and this is not the case with the
> system i am testing.
>
> I have tried the following code after the button for opening the new window
> is clicked:
>
> String winhandlenew = driver.getWindowHandle();
> driver.switchTo().window(winhandlenew);
Windows can be switched to by either name or handle. The name is the
explicit name given to it when doing window.open(url, name). Handles
are UUID's that WebDriver add to make each window uniquely accessible
in the event that they don't have explicit names.
Because the window context you're in when you click the button
disappears WebDriver shouldn't continue on as it looses its default
content. In other words, there is no active document it can operate
within.
Nonetheless it might still work in some drivers to switch to another window:
driver.switchTo().window("name of window");
Or if you don't know the name you need to find the new window handle
from driver.getWindowHandles().