IE 11与Selenium WebDriver:org.openqa.selenium.NoSuchWindowException

时间:2015-07-29 11:53:48

标签: java selenium selenium-webdriver internet-explorer-11

我不知道为什么,如果我设置断点(参见代码),它的工作(它正在点击)但是如果我只是运行我有一个异常org.openqa.selenium.NoSuchWindowException on line(JavascriptExecutor)。 ... 也许有人现在如何帮助我,或者有人知道如何忽略IE中的证书。 谢谢。

public class ie {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.ie.driver", "drivers/iexploredriver.exe");

        DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
        //caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        WebDriver driver = new InternetExplorerDriver(caps); // there i setting break point
        driver.get("https://sasdka.test/uk/");
        ((JavascriptExecutor) driver).executeScript("document.getElementById('overridelink').click()");
        driver.quit();
    }
}

1 个答案:

答案 0 :(得分:-1)

Open Internet Options and switch to "Security" Tab
Select the "Internet" Zone and Unselect the Checkbox "Enable Protected Mode".
Apply this and do this for remaining 3 zones: 
 "Local intranet", "Trusted sites" and "Restricted sites".

After this, close the Internet Options and Restart Internet Explorer to get these changes reflected.