I am doing automation of a application using selenium.
I am trying to switch to a new browser window. but my code get stuck in the line driver.switchTo().window(winhandles)
.
It doesn't give any exception.
I am doing automation of a application using selenium.
I am trying to switch to a new browser window. but my code get stuck in the line driver.switchTo().window(winhandles)
.
It doesn't give any exception.
You can switch between windows as below:
// Store the current window handle
String winHandleBefore = driver.getWindowHandle();
// Perform the click operation that opens new window
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
// Perform the actions on new window
// Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);
// Continue with original browser (first window)