Skip to content

Chrome 115 Selenium WebDriver 兼容性问题解决指南

问题概述

当使用 Chrome 115.0.5790.99(或更高版本)搭配 Selenium 4.10.0 和 webdriver-manager 库时,会出现以下关键错误:

python
ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790

错误通常发生在执行以下代码时:

python
service = Service(ChromeDriverManager().install())

本质上,问题源于 Chrome 113-114 版本后 Chromium 团队更改了驱动程序发布策略:

  1. ChromeDriver 115+ 不再通过传统存储桶 (chromedriver.storage.googleapis.com) 分发
  2. Chrome 和 ChromeDriver 版本必须完全匹配
  3. webdriver-manager 等工具需要适配新的接口

根本原因分析

Google 从 Chrome 115 开始引入全新的 Chrome for Testing 分发机制:

  1. 传统 storage.googleapis.com 停止提供 115+ 版本的驱动
  2. 新版本驱动只在 Chrome for Testing 发布
  3. 自动下载需要指向 JSON API 端点
  4. 兼容版本查找逻辑发生变化

重要提示

使用传统方法访问 https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790 会返回错误:

No such object: chromedriver/LATEST_RELEASE_115.0.5790

推荐解决方案

方案一:使用 Selenium Manager(官方推荐)

适用条件:Selenium ≥ 4.10.0(推荐升级到最新版)

完全移除对 webdriver-manager 的依赖:

python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)

# 正常使用
driver.get('https://www.crawler-test.com')

工作原理

Selenium Manager 会自动:

  1. 检测系统中安装的 Chrome 版本
  2. 从正确的源下载匹配的 ChromeDriver
  3. 管理驱动路径和版本兼容性

方案二:更新 webdriver-manager 库

适用条件:需要保持原有代码结构

bash
# 更新到最新版本(>=3.8.6)
pip install --upgrade webdriver-manager
python
# 更新后的代码(验证过支持Chrome 115+)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)

方案三:手动管理 Chrome for Testing 版本

当需要精确控制环境版本时:

bash
# 下载匹配的ChromeDriver
CHROME_VERSION=$(curl -sS https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE)
curl -sS -o chromedriver.zip https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip
unzip chromedriver.zip && chmod +x chromedriver

# 下载匹配的Chrome浏览器
curl -sS -o chrome.zip https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chrome-linux64.zip
unzip chrome.zip
bat
# 下载匹配的ChromeDriver
$CHROME_VERSION = (Invoke-WebRequest -Uri "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE" -UseBasicParsing).Content
Invoke-WebRequest "https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/win64/chromedriver-win64.zip" -OutFile chromedriver.zip
Expand-Archive chromedriver.zip; Move-Item chromedriver-win64/chromedriver.exe .

# 下载匹配的Chrome浏览器
Invoke-WebRequest "https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/win64/chrome-win64.zip" -OutFile chrome.zip
Expand-Archive chrome.zip

使用绝对路径指定驱动的代码示例:

python
from selenium.webdriver.chrome.service import Service

# 指定手动下载的驱动路径
service = Service(executable_path='/path/to/chromedriver')
driver = webdriver.Chrome(service=service)

不推荐的解决方式

无效方法

python
# 降级驱动版本(临时解决但不可持续)
service = Service(ChromeDriverManager(version="114.0.5735.90").install())

不可靠方案

  1. 禁用 Chrome 自动更新: Chrome 可能绕过限制强制更新
  2. 安装旧版 Chrome 114: 浏览器会自动升级导致同样问题
  3. 改用 Firefox 驱动: 回避问题而非真正解决

最佳实践总结

方案易用性维护性推荐度
使用 Selenium Manager★★★★★★★★★★⭐️首选
更新 webdriver-manager★★★☆☆★★★★☆次选
手动管理Chrome for Testing★★☆☆☆★★☆☆☆特殊场景

关键步骤:

  1. 升级到最新版 Selenium (pip install --upgrade selenium)
  2. 移除不必要的 webdriver-manager 依赖
  3. 确认环境版本一致性:
python
print("Selenium:", selenium.__version__)
print("Chrome:", driver.capabilities['browserVersion'])
print("ChromeDriver:", driver.capabilities['chrome']['chromedriverVersion'])

官方资源: