WebDriverException:消息:未知错误:Chrome 无法启动:在 debian 服务器上使用 ChromeDriver Chrome 和 Selenium 异常退出
问题描述
我尝试在 debian 服务器 8.11 上运行 selenium webdriver 并收到错误.
i try to run the selenium webdriver on a debian server 8.11 and get an error.
Java:java 版本1.7.0_221",OpenJDK 运行时环境(IcedTea 2.6.18)
Java: java version "1.7.0_221", OpenJDK Runtime Environment (IcedTea 2.6.18)
网络驱动程序:ChromeDriver (v2.9.248304)
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")
browser = webdriver.Chrome('/usr/local/bin/chromedriver', options=co)
browser.get('example.com')
browser.quit()
display.close()
我收到此错误:
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...
解决方案
这个错误信息...
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)
...暗示 ChromeDriver 无法启动/生成新的 WebBrowser 即 Chrome 浏览器 会话.
...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:
- 您正在使用 chromedriver=2.9
- chromedriver=2.9 的发行说明明确提及以下内容:
支持 Chrome v31-34
- 大概你正在使用 chrome= 76.0
- ChromeDriver v76.0的发行说明/a> 明确提及以下内容:
- Presumably you are using chrome= 76.0
- Release Notes of ChromeDriver v76.0 clearly mentions the following :
- 您的 Selenium 客户端 版本对我们来说是未知.
- 您提到JDK 版本 是1.7.0_221,相当古老.
- Your Selenium Client version is unknown to us.
- You mentioned about JDK version is 1.7.0_221 which is pretty ancient.
- Selenium 已升级到当前级别版本 3.141.59.
- ChromeDriver 已更新为当前 ChromeDriver v76.0 级别.
- Chrome 已更新至当前 Chrome 版本 76.0 级别.(根据 ChromeDriver v76.0 发行说明)
- 清理你的项目工作区通过你的IDE和重建你的项目只需要依赖.
- 如果您的基础 Web Client 版本太旧,请通过 卸载它Revo Uninstaller 并安装最新的 GA 和发布版本的 Web Client.
- 进行一次系统重启.
- 以 非 root 用户身份执行您的
@Test
. - 总是在
tearDown(){}
方法中调用driver.quit()
来关闭 &优雅地销毁 WebDriver 和 Web Client 实例. - 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. - 消息:未知错误:Chrome 无法启动:在 AWS Cloud9 上使用 Linux 4.9.85-38.58.amzn1.x86_64 x86_64 异常退出
- WebDriverException:消息:未知错误:Chrome 无法启动:在 VPS 上通过 Python 使用 ChromeDriver Chrome 和 Selenium 异常退出
- WebDriverException:消息:未知错误:Chrome 无法启动:在 VPS 上通过 Python 使用 ChromeDriver Chrome 和 Selenium 异常退出
支持Chrome 76版
所以 ChromeDriver v2.9 和 Chrome 浏览器 v76.0
确保:
您可以在以下位置找到一些相关讨论:
You can find a couple of relevant discussions in:
相关文章