我尝试在 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:
支持 Chrome v31-34
支持Chrome 76版
所以 ChromeDriver v2.9 和 Chrome 浏览器 v76.0
确保:
@Test
.tearDown(){}
方法中调用 driver.quit()
来关闭 &优雅地销毁 WebDriver 和 Web Client 实例.@Test
as non-root user.driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.您可以在以下位置找到一些相关讨论:
You can find a couple of relevant discussions in:
这篇关于WebDriverException:消息:未知错误:Chrome 无法启动:在 debian 服务器上使用 ChromeDriver Chrome 和 Selenium 异常退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!