异常(org.openqa.selenium.NoSuchWindowException):在Internet Explorer中使用Selenium WebDriver和Java

Ami*_*mit 5 java selenium internet-explorer exception selenium-webdriver

使用IE进行自动化使用Selenium Webdriver时,我可以打开URL,但在该页面上找到该元素会引发以下异常:

org.openqa.selenium.NoSuchWindowException:无法在关闭的窗口中找到元素(警告:服务器未提供任何堆栈跟踪信息)

我尝试过这种driver.switchTo.window()方法,但它没有用.我已经搜索了几个小时,我没有到达任何地方.

这是代码:

public static Selenium selenium;

public static void main(String args[]) {

    try {

        System.setProperty(
            "webdriver.ie.driver",
            "D:\\Driver\\IEDriverServer_Win32_2.32.3_latest\\IEDriverServer.exe");

        DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
        capab.setCapability(
            InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
            true);

        WebDriver driver = new InternetExplorerDriver(capab);
        driver.get("http://www.google.com");
        driver.findElement(By.xpath(".//*[@id='addlang']/a[1]")).click();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

Yi *_*eng 7

删除功能INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS并手动将IE保护模式设置设置为对所有区域都相同.

资源:

  1. http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html

  2. 在Selenium WebDriver中实现InternetExplorerDriver期间发生NoSuchElementException

  • 您应该问您的办公室管理员您需要更改以便自动化测试工作,不应该那么难. (2认同)