【问题标题】:Common Exception in Selenium Chrome-driver while using with Python与 Python 一起使用时 Selenium Chrome 驱动程序中的常见异常
【发布时间】:2018-11-15 17:36:44
【问题描述】:

我已经使用 python 和 selenium 有一段时间了,但是在使用无头版本的 chrome 驱动程序时突然出现这个错误。
这是我一直使用的代码示例;

from selenium import webdriver

chrome_options = Options()  
chrome_options.add_argument("--headless")  
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=chrome_options)
###Function that my code does###
driver.quit()

我得到的错误是:

 browser = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=chrome_options)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/local/bin/chromedriver unexpectedly exited. Status code was: 1

现在我试图通过谷歌找到一个解决方案,但结果表明将 chromedriver 放在路径中并在 python 代码本身中定义该路径。但是所有这些事情都已经完成了,我在这里犯了什么愚蠢的错误?

【问题讨论】:

    标签: python selenium selenium-chromedriver


    【解决方案1】:

    确保您安装的 Chrome 版本与您正在使用的 ChromeDriver 版本兼容。根据this answer,您始终可以在此处找到最新的兼容性信息:

    https://sites.google.com/a/chromium.org/chromedriver/downloads

    此时,兼容性表如下所示:

    chromedriver    chrome
    2.43            69-71
    2.42            68-70
    2.41            67-69
    2.40            66-68
    2.39            66-68
    2.38            65-67
    2.37            64-66
    2.36            63-65
    2.35            62-64
    2.34            61-63
    2.33            60-62
    ---------------------
    2.28            57+
    2.25            54+
    2.24            53+
    2.22            51+
    2.19            44+
    2.15            42+
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多