Selenium WebDriver windows switching issue in Internet Explorer 8-10

后端 未结 3 1013
情话喂你
情话喂你 2021-01-13 14:47

I found a problem trying to use Selenium WebDriver for testing our application. The issue is in unstable pop-ups focusing in IE9. It is not always reproducible, it takes pl

3条回答
  •  感情败类
    2021-01-13 14:58

    String currentWindowHandle = driver.getWindowHandle();
            driver.findElement(By.cssSelector(locator)).click();
            Set windows = driver.getWindowHandles();
            for (String window : windows) {
                if (!window.equals(currentWindowHandle)) {
                    driver.switchTo().window(window);
                    driver.close();
                }
            }
            driver.switchTo().window(currentWindowHandle);
    

提交回复
热议问题