我正在使用Selenium和Java並使用JUnit執行測試。它不斷告訴我無法找到具有JSON配置文件的Chrome二進制文件
找不到Chrome的二進制
二進制位置不標準,因爲我需要測試多個版本。我確切知道Chrome.exe啓動程序存在於指定的JSON位置...
它看起來像仍在搜索標準位置的驅動程序。
我已經得到了JSON配置文件:
{
"capabilities":[
{
"browserName":"chrome",
"platform":"WINDOWS",
"chromeOptions":{
"binary":"C:/path/chrome_binary.exe"
},
"maxInstance":1
}
],
"configuration":{
"cleanUpCycle":2000,
"timeout":30000,
"register":true,
"hubPort":4444,
"hubHost":"hub.location.net",
"maxSessions":1
}
}
正如你可以看到我在Windows上,所以我試圖用斜槓和反斜槓路徑,但它並沒有在任何方式工作。
ChromeOptions對象應該沒問題,我用this official documentation
命令行是:
java -jar selenium-server-standalone.jar -role webdriver -nodeConfig path/to/conf.json -Dwebdriver.chrome.driver=path/to/chromedriver.exe
在代碼中,我創建RemoteWebDriver對象,我只有通過瀏覽器,版本和平臺。它適用於Firefox。例如在JSON節點配置中,我已經設置了firefox_binary,並且在代碼中,我沒有將它傳遞給DesiredCapabilities。 Selenium仍然可以使用我使用上面的命令啓動的遠程Web驅動程序。
謝謝!
文件是否存在於該路徑? – ddb
當然可以。我編輯 – buzz2buzz
不應該這是'-Dwebdriver.chrome.driver =路徑/到/ chromedriver.exe'你的Windows風格路徑?或者你需要編輯? – nilesh