04
Oct

Switching between windows during script run

String winHandleBefore = driver.getWindowHandle();

// Perform GUI action which opens a new window, use following code to switch to pop-up window:

for (String currentWindow : driver.getWindowHandles())

driver.switchTo().window(currentWindow);

to revert back to parent window

driver.switchTo().window(winHandleBefore);