switch to another window

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

switch to another window

srinithya
when a page redirects to another page how  to switch to other window?
Reply | Threaded
Open this post in threaded view
|

Re: switch to another window

softwaretestingforum
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: switch to another window

mfsi_sitamj
In reply to this post by srinithya
Hi srinithya,

You can use following snippet for your purpose :-

String currentWindowHandle=driver.getWindowHandle();
String dialogWindowHandle=null;
for(String windowHandle:driver.getWindowHandles())
{
        if (!windowHandle.equals(currentWindowHandle))
       dialogWindowHandle=windowHandle;  
}
driver.switchTo().window(dialogWindowHandle);

Thanks
Sitam