如何在Chrome Canary中运行WebDriver?

3

有没有办法告诉chromedriver(Chrome内的webdriver实现)使用Canary、Beta或当前生产版本的Chrome?

3个回答

9
你可以要求ChromeDriver使用非标准位置的Chrome可执行文件。
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome.exe");

在Mac OS X上,这应该是实际的二进制文件,而不仅仅是应用程序。例如:/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[通过chromedriver功能和开关]

ChromeDriver 2.6中修复了一个bug:https://code.google.com/p/chromedriver/issues/detail?id=612,请更新至最新版本。 - Paul Irish
2
该选项似乎已经更名为options.setChromeBinaryPath(<PATH HERE>)自ChromeDriver 2.16.333243和webdriver 2.46.1 - samccone

4

theintern中实现这一点的方法是通过以下配置:

capabilities: {
    'selenium-version': '2.35.0',
    'chrome': {chromeOptions: {'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'}},
},

此外,如果您想直接配置Selenium节点,以下是如何传递配置的方法:
{
"capabilities": [
    {
        "browserName": "chrome",
        "platform": "MAC"
    },
    {
        "browserName": "chromeCanary",
        "platform": "MAC",
        "chromeOptions": {
            "binary": "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
        },
        "maxInstances": 1,
        "seleniumProtocol": "WebDriver"
    },
    {
        "browserName": "firefox",
        "platform": "MAC"
    }
],
"configuration": {
    "host": "localhost",
    "port": 8989,
    "hubPort": 4444,
    "hubHost": "localhost"
}

}


0

应该使用 Google Chrome Canary.app 而不是仅仅使用 Google Chrome.app。
尝试这样做:

options.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary");
ChromeDriver driver = new ChromeDriver(options);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接