我尝试在Debian服务器8.11上运行Selenium Webdriver并收到错误消息。
Java:Java版本“ 1.7.0_221”,OpenJDK运行时环境(IcedTea 2.6.18)
网络驱动程序: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)
我尝试了几种解决方案,但无济于事…
此错误消息…
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浏览器 会话。
您的主要问题是所使用的二进制版本之间的 不兼容性 ,如下所示:
支持 Chrome v31-34
支持 Chrome版本76
因此, ChromeDriver v2.9 和 Chrome浏览器v76.0 之间存在明显的不匹配 __
确保这件事:
@Test
driver.quit()
tearDown(){}