Tuesday, 9 December 2014

How to handle multiples windows || Using an Utility

/**
 * This method will toggle the driver handle from main window to popup
 * window.
 *
 * @param driver
 */
public static void handlePopupWindow(WebDriver driver)
{
(new WebDriverWait(driver, 90)).until(new ExpectedCondition<Boolean>()
{
public Boolean apply(WebDriver d)
{
return d.getWindowHandles().size() > 1;
}
});

for (String winHandle : driver.getWindowHandles())
{
driver.switchTo().window(winHandle);
}

}


Call this Utility method, whenever need to switch to a new window.

No comments:

Post a Comment