2016-07-06 91 views
0

我正在使用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驅動程序。

謝謝!

+0

文件是否存在於該路徑? – ddb

+0

當然可以。我編輯 – buzz2buzz

+0

不應該這是'-Dwebdriver.chrome.driver =路徑/到/ chromedriver.exe'你的Windows風格路徑?或者你需要編輯? – nilesh

回答

0

終於得償所願。沒有在任何文檔上看到它,因爲他們都談論binarychromeOptions

答案在這裏https://stackoverflow.com/a/33151376/4675568,非常感謝他,簡而言之:沒有chromeOptions,只是chrome_binary關鍵像firefox。

"capabilities": [{ 
    "browserName": "chrome", 
    "platform": "WINDOWS", 
    "chrome_binary":"C:/path/to/chrome_binary.exe", 
    "maxInstance":1 
}] 
0

也許應該把它應用此更改

"binary":"C://path//chromedriver.exe" 

編輯1

嘗試用這種JSON配置文件:

{ 
    "capabilities":[ 
     { 
     "browserName":"chrome", 
     "platform":"WINDOWS", 
     "binary":"C:/path/chrome_binary.exe" 
     "maxInstance":1 
     } 
    ], 
    "configuration":{ 
     "cleanUpCycle":2000, 
     "timeout":30000, 
     "register":true, 
     "hubPort":4444, 
     "hubHost":"hub.location.net", 
     "maxSessions":1 
    } 
} 

最終,也儘量躲避 「/」作爲例子如下:

"binary":"C://path//chrome_binary.exe" 

"binary":"C:\/path\/chrome_binary.exe" 
+0

沒有工作。 BTW的路徑/ to/chrome_binary.exe,對不起,對於閱讀答案的人來說可能很奇怪。我編輯了我的問題 – buzz2buzz

+0

,如果你嘗試'「binary」:「C:\/path \ /chrome_driver.exe」'? – ddb

+0

沒有工作。 PS:這是一個奇怪的路徑 – buzz2buzz

0

路徑在Windows中使用反斜槓:

"binary":"C:\\path\\chrome_binary.exe" 
+0

我試過沒有運氣 – buzz2buzz

相關問題