本文介紹了ChromeDriver:自定義 Chrome 可執行文件路徑的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我使用的是便攜版的谷歌瀏覽器.
I'm using the portable version of Google Chrome.
由于 WebDriver 需要默認安??裝路徑,它沒有找到明顯在另一個位置的便攜式:
Since WebDriver expects the default installation path, it does not find the portable one which obviously is at another location:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11.13 seconds
Build info: version: '2.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
如何設置 chrome.exe
文件的自定義路徑?
How do I set a custom path to the chrome.exe
file?
推薦答案
沒關系,我自己找到了答案:
Nevermind, I found the answer myself:
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/chrome/binary");
ChromeDriver driver = new ChromeDriver(options);
Chromedriver 文檔
這篇關于ChromeDriver:自定義 Chrome 可執行文件路徑的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!