【问题标题】:This version of ChromeDriver only supports Chrome version 79 - Python此版本的 ChromeDriver 仅支持 Chrome 版本 79 - Python
【发布时间】:2020-03-19 21:57:51
【问题描述】:

这个错误让我发疯。我的代码是:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import chromedriver_binary
from selenium.webdriver.common.by import By
import time
from influxdb import InfluxDBClient
chrome_options = Options()
chrome_options.add_argument("--headless")
chromedriver_binary = 
"/home/dario/scripts/cron_run/web_app_login_checker/chromedriver/chromedriver"
driver = webdriver.Chrome(chromedriver_binary, options=chrome_options)

如果我这样做:

 ./chromedriver -v
 ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch- 
 heads/3945@{#614})

这是正确的版本。

完整的追溯是:

    Traceback (most recent call last):
    File "grafana.py", line 12, in <module>
    driver = webdriver.Chrome(chromedriver_binary, options=chrome_options)
    File 
   "/home/dario/scripts/cron_run/web_app_login_checker/lib/python3.6/site- 
    packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
    File 
   "/home/dario/scripts/cron_run/web_app_login_checker/lib/python3.6/site- 
   packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
   self.start_session(capabilities, browser_profile)
   File 
   "/home/dario/scripts/cron_run/web_app_login_checker/lib/python3.6/site- 
   packages/selenium/webdriver/remote/webdriver.py", line 252, in 
   start_session
   response = self.execute(Command.NEW_SESSION, parameters)
   File 
   "/home/dario/scripts/cron_run/web_app_login_checker/lib/python3.6/site- 
   packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
   self.error_handler.check_response(response)
   File 
   "/home/dario/scripts/cron_run/web_app_login_checker/lib/python3.6/site- 
   packages/selenium/webdriver/remote/errorhandler.py", line 242, in 
   check_response
   raise exception_class(message, screen, stacktrace)
   selenium.common.exceptions.SessionNotCreatedException: Message: session 
   not created: This version of ChromeDriver only supports Chrome version 
   79

Stack Overflow 上已经讨论过的主题都没有帮助我。

【问题讨论】:

标签: python selenium google-chrome selenium-webdriver selenium-chromedriver


【解决方案1】:

问题在于 Chrome 浏览器版本,而不是 ChromeDriver 版本。您需要将其更新到版本 79,或降级 ChromeDriver。您可以找到here 匹配的版本。

【讨论】:

  • 匹配驱动程序和浏览器版本现在更容易了
  • 我运行了which chromedriver 来确定二进制文件的去向。
  • 我怎么知道哪个版本在哪里运行?这些天来的一切都是自动更新的。我的 TFS 构建服务器有一个版本的 Chrome,我的开发盒有另一个;我们的生产服务器完全是第三个版本。由于显而易见的原因,我们不会使所有内容保持最新。那是错误的。但当然,我们会一直更新我们的开发环境。
【解决方案2】:

如果您在自动集群上运行东西时遇到此错误,并且每次都在下载稳定版本的 google chrome,那么您可以使用下面的 shell 脚本每次动态下载兼容版本的 chrome 驱动程序,即使如果 Chrome 的稳定版本得到更新。你可以做一些类似于这个 python 的事情来让它工作。

%sh
#downloading compatible chrome driver version
#getting the current chrome browser version
**chromeVersion=$(google-chrome --product-version)**
#getting the major version value from the full version
**chromeMajorVersion=${chromeVersion%%.*}**
# setting the base url for getting the release url for the chrome driver
**baseDriverLatestReleaseURL=https://chromedriver.storage.googleapis.com/LATEST_RELEASE_**
#creating the latest release driver url based on the major version of the chrome
**latestDriverReleaseURL=$baseDriverLatestReleaseURL$chromeMajorVersion**
**echo $latestDriverReleaseURL**
#file name of the file that gets downloaded which would contain the full version of the chrome driver to download
**latestDriverVersionFileName="LATEST_RELEASE_"$chromeMajorVersion**
#downloading the file that would contain the full release version compatible with the major release of the chrome browser version
**wget $latestDriverReleaseURL** 
#reading the file to get the version of the chrome driver that we should download
**latestFullDriverVersion=$(cat $latestDriverVersionFileName)**
**echo $latestFullDriverVersion**
#creating the final URL by passing the compatible version of the chrome driver that we should download
**finalURL="https://chromedriver.storage.googleapis.com/"$latestFullDriverVersion"/chromedriver_linux64.zip"**
**echo $finalURL**
**wget $finalURL**

在 databricks 环境中运行计划作业时,我能够使用上述方法获得兼容版本的 chrome 浏览器和 chrome 驱动程序,它的运行就像一个魅力,没有任何问题。

希望它能以某种方式帮助他人。

【讨论】:

    【解决方案3】:
    1. 检查您的 chrome 版本

      1. 下载同版本的chrome驱动 Check the latest driver here

      2. 更新参考文件夹中的驱动程序。

    就我而言,我使用的是 Windows 10 和 python,我已使用最新的 chromedriver.exe 文件(适用于 Chrome v83)进行了更新

    【讨论】:

      【解决方案4】:

      此错误消息...

      selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 79
      

      ...暗示 ChromeDriver 无法启动/生成新的浏览上下文,即 Chrome Browser v79.x 会话。

      您的主要问题是您使用的二进制文件版本之间的不兼容性,如下所示:

      支持Chrome 79版

      • 大概您使用的是最新的版本 78.0.3904.108(官方版本)

      所以 ChromeDriver v79.0.3945.36 和 Chrome 浏览器 v78.0.3904.108

      之间存在明显的不匹配

      解决方案

      有两种可能的解决方案:

      【讨论】:

        猜你喜欢
        • 2020-04-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-29
        • 2020-04-16
        • 2022-07-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多