I used following code for child window,
driver.getWindowHandles().forEach(winHandle -> driver.switchTo().window(winHandle));
How to switch to parent window??
Set<String> ids = driver.getWindowHandles();
Iterator<String> i = ids.iterator();
String parentID = i.next(); //Parent Window
while(i.hasNext())
{
String childID = i.next(); //Child Windows
driver.switchTo().window(childID); // Iterating over child windows
}
driver.switchTo().window(parentID); //switching back to Parent window
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With