首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Selenium Webdriver的Chome中的UnReachableBrowserException

使用Selenium Webdriver的Chome中的UnReachableBrowserException
EN

Stack Overflow用户
提问于 2016-09-20 13:47:13
回答 1查看 288关注 0票数 0

当我在chrome中尝试以下代码时,我得到了UnhandledBrowserException:

公共类myClass {

代码语言:javascript
复制
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中启动了一个新的会话,但随后抛出了异常。任何帮助都将不胜感激。

EN

Stack Overflow用户

发布于 2016-09-20 14:59:07

我认为你点击的是程序可执行文件而不是驱动程序。

代码语言:javascript
复制
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();

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

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39586563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档