問題描述
我嘗試用 Selenium 啟動 Chromedriver
從 selenium 導入 webdriver驅動程序 = webdriver.Chrome()driver.get("http://www.google.com/")打印(驅動程序.標題)
和下面的錯誤消息:
raise exception_class(message, screen, stacktrace)selenium.common.exceptions.WebDriverException:消息:未知錯誤:Chrome 無法啟動:異常退出(驅動信息:chromedriver=2.33.506092,platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64)
我正在使用這些:
[root@jdu4e00u53f7 工作區]# ll/usr/local/bin/chromedriverlrwxrwxrwx 1 root root 17 11 月 14 00:31/usr/local/bin/chromedriver ->/opt/chromedriver
- CentOS 7.3
- Python(3.6.2)
- 硒 (3.7.0)
- 谷歌瀏覽器 (62.0.3202.89)
- chromedriver(2.9)/我改成chromedriver=2.33.506092
- Xvfb
ps,我也試過了
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
,不行……
test.py輸出
參考:Selenium 無法啟動 Chromedriver
- 在我的服務器上在后臺啟動 Xvfb:
Xvfb :0 -ac -screen 0 1024x768x24 &
也不起作用
ref:未知錯誤:Chrome 失敗啟動:異常退出(驅動信息:chromedriver=2.9
從您提到的配置中可以明顯看出您使用的是 Selenium v??3.7.0
, Google Chrome 62.0
以及不兼容的 chromedriver v2.9
.因此,我們看到了錯誤 WebDriverException: Message: unknown error: Chrome failed to start: exited異常
ChromeDriver v2.33
的發行說明明確提到Supports Chrome v60-62
解決方案:
從 chromedriver v2.33
="nofollow noreferrer">this link
并執行你的測試用例.
更新:
試試下面的代碼塊:
從 selenium 導入 webdriverdriver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')driver.get('https://www.google.co.in')print("頁面標題是:%s" %driver.title)driver.quit()
<塊引用>
或
從 selenium 導入 webdriverdriver = webdriver.Chrome(executable_path='/opt/chromedriver')driver.get('https://www.google.co.in')print("頁面標題是:%s" %driver.title)driver.quit()
I try to start Chromedriver with Selenium
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.google.com/")
print(driver.title)
and error msg below:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.33.506092,platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64)
I am using these:
[root@jdu4e00u53f7 workspace]# ll /usr/local/bin/chromedriver
lrwxrwxrwx 1 root root 17 11月 14 00:31 /usr/local/bin/chromedriver -> /opt/chromedriver
- CentOS 7.3
- Python(3.6.2)
- selenium (3.7.0)
- Google Chrome (62.0.3202.89)
- chromedriver(2.9)/ I changed to chromedriver=2.33.506092
- Xvfb
ps, I also tried
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
,it not work...
test.py output
ref :Selenium fails to start Chromedriver
- On my server start Xvfb in the background:
Xvfb :0 -ac -screen 0 1024x768x24 &
and also not work
ref:unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9
It is much evident from your mentioned configuration that you are using Selenium v3.7.0
, Google Chrome 62.0
along with chromedriver v2.9
which is not compatible. Hence we are seeing the error WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
The Release Notes of
ChromeDriver v2.33
clearly mentionsSupports Chrome v60-62
Solution:
Download the latest chromedriver v2.33
from this link
and execute your testcase.
Update :
Try the following code block :
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
OR
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/opt/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
這篇關于Selenium 無法在 CentOS 中啟動 Chromedriver的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!