IE转到http:// localhost:36559 /并显示消息“这是WebDriver服务器的初始启动页面”

时间:2018-02-07 05:50:24

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

我正在尝试启动IE,但下面的Selenium Java代码没有任何反应:

protected WebDriver ieBrowserSetUp() throws Exception {
    // Read the properties file
    Properties prop = getProperties();
    System.setProperty("webdriver.ie.driver", prop.getProperty("IEDriverPath"));
    driver = new InternetExplorerDriver();
    driver.navigate().to("https://www.google.com");
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.manage().window().maximize();


    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
    caps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "");

    WebDriver driver= new InternetExplorerDriver(caps);

    System.out.println("Internet Explorer Browser Setup Done Successfully");    
    return driver;
}

Firefox和Chrome Webdriver正常运行。我在其中一篇帖子中看到需要更改保护模式设置。考虑到我不是Windows管理员,因为在工作中禁用了设置,是否有解决方法。该路径指向我下载的IEDriverServer.exe,而不是“Windows-installed-and-defaulted”IE应用程序。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题:

System.setProperty("webdriver.ie.driver", prop.getProperty("IEDriverPath"));

                DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
                caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //disable protected mode settings
                caps.setCapability("initialBrowserUrl", url);
                driver = new InternetExplorerDriver(caps);