I have a parent window, click on a link in parent window --> child window1 opens --> click on a link in child window1 --> child winodw2 opens --> click on a link in child window2 --> child window 3 opens --> click on a link in child window 3 --> child window 4 opens --> then return the control back to window4, window3, window2, window1 and parent window. Kindly help me on this using Selenium Webdriver in JAVA
driver.getWindowHandles();//Return all open window handles
Loop through the windows as required for your case
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
If one window opens new window , You need to switch to second window. Only from there you can click and goto third window. Use the above steps.