This script helps you to switch over from a Parent window to a Child window and back cntrl to your Parent Window
String parentWindow = driver.getWindowHandle();
String parentWindow = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
for(String windowHandle : handles)
{
if(!windowHandle.equals(parentWindow))
{
driver.switchTo().window(windowHandle);
<!--Perform your operation here for new window-->
driver.close(); //closing child window
driver.switchTo().window(parentWindow); //cntrl to parent window
}
}
for(String windowHandle : handles)
{
if(!windowHandle.equals(parentWindow))
{
driver.switchTo().window(windowHandle);
<!--Perform your operation here for new window-->
driver.close(); //closing child window
driver.switchTo().window(parentWindow); //cntrl to parent window
}
}
could you please tell me how to handle 3 window
ReplyDeleteIterator windowIterator1 = driver.getWindowHandles().iterator();
ReplyDeletewhile (windowIterator1.hasNext())
{
String windowHandle = windowIterator1.next();
driver = driver.switchTo().window(windowHandle);
if(driver.getTitle().contains("Document Explorer"))
{
}
}
Куку
ReplyDelete