WebDriverException:消息:未知错误:Chrome无法启动:在Debian服务器上使用ChromeDriver Chrome和Selenium异常退出 [英] WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server
问题描述
我尝试在debian服务器8.11上运行Selenium Webdriver并收到错误。
Java:Java版本 1.7.0_221,OpenJDK运行时环境(IcedTea 2.6.18)
Webdriver:ChromeDriver(v2.9.248304)
源代码:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible = 0,size =(800 ,800))
display.start()
co = webdriver.ChromeOptions()
co.add_argument(-user-data-dir = profile)
浏览器= webdriver.Chrome('/ usr / local / bin / chromedriver',options = co)
browser.get('example.com')
browser.quit()
display.close( )
我收到此错误:
Traceback(最近一次呼叫最近):
文件 / bin / selenium,< module>中的第11行。
浏览器= webdriver.Chrome('/ usr / local / bin / chromedriver',options = co)
文件 /usr/local/lib/python2.7/dist-packages/selenium/webdriver/ chrome / webdriver.py,第__init__行中的第81行
wanted_capabilities = desired_capabilities)
文件 /usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py ,第157行,位于__init__
self.start_session(capabilities,browser_profile)
文件 /usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py ,第252行,在start_session
response = self.execute(Command.NEW_SESSION,parameters)
File /usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver .py,第321行,执行
self.error_handler.check_response(response)
文件 /usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler。 py,第242行,在check_response
中引发exception_class(消息,屏幕,堆栈跟踪)
selenium.common.exceptions.WebDriverExc eption:消息:未知错误:Chrome无法启动:异常退出
(驱动程序信息:chromedriver = 2.9.248304,platform = Linux 4.9.0-0.bpo.9-amd64 x86_64)
我尝试了几种解决方案,但无济于事...
此错误消息...
selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:异常退出
(驱动程序信息:chromedriver = 2.9.248304,platform = Linux 4.9.0-0.bpo.9-amd64 x86_64)
...表示 ChromeDriver 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话。
您的主要问题是所使用的二进制版本之间的不兼容: / p>
- 您正在使用 chromedriver = 2.9
- chromedriver = 2.9 明确提及以下内容:
支持 Chrome v31-34
- 大概您正在使用 chrome = 76.0
- ChromeDriver v76.0 明确提到以下内容:
支持 Chrome 76版
- 您的 Selenium Client 版本对我们来说是 。
- 您提到 > JDK版本是1.7.0_221,非常古老。
因此之间显然存在不匹配ChromeDriver v2.9 和 Chrome浏览器v76.0
解决方案
确保:
- 硒已升级到当前级别版本3.141.59 。
- ChromeDriver 已更新为当前< a href = https://chromedriver.storage.googleapis.com/index.html?path=76.0.3809.68/ rel = nofollow noreferrer> ChromeDriver v76.0 级别。
- Chrome 已更新为当前的 Chrome版本76.0 级别。 (根据 ChromeDriver v76.0发行说明)
- 如果您的基本 Web客户端版本过旧,请通过 Revo卸载程序 ,并安装最新的GA和 Web Client 的发行版。
- 执行系统重启。
- 以非root用户身份执行
@Test
/ strong>用户。 - 始终在
tearDown(){} {}中调用
driver.quit()
code>方法来关闭&优雅地销毁 WebDriver 和 Web Client 实例。
通过您的 IDE 和 Rebuild 仅使用必需的依赖项来清洁您的项目工作区 。
参考
您可以在以下位置找到一些相关的讨论:
- 消息:未知错误:Chrome无法启动:在带有Linux 4.9.85-38.58.amzn1.x86_64 x86_64 的AWS Cloud9上异常退出:
- WebDriverException:消息:未知错误:Chrome无法启动:异常退出在VPS上通过Python的ChromeDriver Chrome和Selenium
- WebDriverEx接收:消息:未知错误:Chrome无法启动:使用ChromeDriver在VPS上通过Python异常退出了Chrome和Selenium
i try to run the selenium webdriver on a debian server 8.11 and get an error.
Java: java version "1.7.0_221", OpenJDK Runtime Environment (IcedTea 2.6.18)
Webdriver: ChromeDriver (v2.9.248304)
Sourcecode:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 800))
display.start()
co = webdriver.ChromeOptions()
co.add_argument("--user-data-dir=profile")
browser = webdriver.Chrome('/usr/local/bin/chromedriver', options=co)
browser.get('example.com')
browser.quit()
display.close()
I get this error:
Traceback (most recent call last):
File "/bin/selenium", line 11, in <module>
browser = webdriver.Chrome('/usr/local/bin/chromedriver', options=co)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.9.248304,platform=Linux 4.9.0-0.bpo.9-amd64 x86_64)
I try several solutions but nothing works...
This error message...
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.9.248304,platform=Linux 4.9.0-0.bpo.9-amd64 x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chromedriver=2.9
- Release Notes of chromedriver=2.9 clearly mentions the following :
Supports Chrome v31-34
- Presumably you are using chrome= 76.0
- Release Notes of ChromeDriver v76.0 clearly mentions the following :
Supports Chrome version 76
- Your Selenium Client version is unknown to us.
- You mentioned about JDK version is 1.7.0_221 which is pretty ancient.
So there is a clear mismatch between the ChromeDriver v2.9 and the Chrome Browser v76.0
Solution
Ensure that:
- Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v76.0 level.
- Chrome is updated to current Chrome Version 76.0 level. (as per ChromeDriver v76.0 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test
as non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
- Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64
- WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
- WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
这篇关于WebDriverException:消息:未知错误:Chrome无法启动:在Debian服务器上使用ChromeDriver Chrome和Selenium异常退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!