本文介紹了Selenium - chrome 驅(qū)動程序無法在后臺啟動(沒有啟動窗口)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在使用 Selenium 并嘗試初始化 Chrome 驅(qū)動程序以在沒有啟動窗口的情況下啟動.
I am using Selenium and trying to initialize the Chrome driver to start without a start up window.
ChromeOptions options= new ChromeOptions();
options.addArguments("--no-startup-window");
//I tried this line also: options.addArguments("--silent-launch");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(Capabilities);
我收到以下異常:
未知錯誤:Chrome 無法啟動:正常退出
Unknown error: Chrome failed to start: exited normally
誰能幫幫我?
推薦答案
你需要先從selenium網(wǎng)站下載二進制文件,根據(jù)你的要求下載二進制文件:-
You need to download the binary first from selenium website, download binary according to your specifications:-
http://chromedriver.storage.googleapis.com/index.html?path=2.19/
現(xiàn)在設置下面的代碼,這樣 selenium 腳本就會知道你的二進制文件的路徑
Now set below code so selenium script will know the path of your binary
System.setProperty("webdriver.chrome.driver","./src\lib\chromedriver.exe");
所以代碼應該是這樣的:-
So the code should be like this:-
System.setProperty("webdriver.chrome.driver","./src\lib\chromedriver.exe");
ChromeOptions options= new ChromeOptions();
options.addArguments("--no-startup-window");
//I tried this line also: options.addArguments("--silent-launch");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
希望對你有幫助:)
這篇關(guān)于Selenium - chrome 驅(qū)動程序無法在后臺啟動(沒有啟動窗口)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!