【问题标题】:UnReachableBrowserException in Chome with Selenium Webdriver带有 Selenium Webdriver 的 Chrome 中的 UnReachableBrowserException
【发布时间】:2016-09-20 05:47:13
【问题描述】:

在 chrome 中尝试以下代码时出现 UnhandledBrowserException:

公共类我的类{

public static void main(String[] args) {
    // declaration and instantiation of objects/variables

    System.setProperty("webdriver.chrome.driver", "C://Program Files (x86)//Google//Chrome//Application//chrome.exe");
    WebDriver driver= new ChromeDriver();


    String baseURL = "http://newtours.demoaut.com";
    String expectedTitle = "Welcome: Mercury Tours";
    String actualTitle = "";

    // launch Firefox and direct it to the Base URL
    driver.get(baseURL);
    // get the actual value of the title
    actualTitle = driver.getTitle();

    /*
     * compare the actual title of the page witht the expected one and print
     * the result as "Passed" or "Failed"
     */
    if (actualTitle.contentEquals(expectedTitle)){
        System.out.println("Test Passed!");
    } else {
        System.out.println("Test Failed");
    }

    //close Firefox
    driver.close();

    // exit the program explicitly
    System.exit(0);
}

它正在 chrome 中启动一个新会话,但随后抛出异常。任何帮助将不胜感激。

【问题讨论】:

标签: selenium


【解决方案1】:

我认为您正在点击程序可执行文件而不是驱动程序。

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();

它应该是 chrome 驱动程序的路径,而不是 chrome 浏览器可执行文件。 你可以看看https://sites.google.com/a/chromium.org/chromedriver/getting-started

【讨论】:

    猜你喜欢
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    • 2018-11-30
    • 2017-11-24
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多