有没有办法告诉chromedriver(Chrome内的webdriver实现)使用Canary、Beta或当前生产版本的Chrome?
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome.exe");
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
。在theintern中实现这一点的方法是通过以下配置:
capabilities: {
'selenium-version': '2.35.0',
'chrome': {chromeOptions: {'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'}},
},
{
"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"
}
}
应该使用 Google Chrome Canary.app 而不是仅仅使用 Google Chrome.app。
尝试这样做:
options.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary");
ChromeDriver driver = new ChromeDriver(options);
options.setChromeBinaryPath(<PATH HERE>)
自ChromeDriver 2.16.333243和webdriver2.46.1
。 - samccone