Chrome 115.0.5790.171与Chromedriver版本不匹配致Selenium运行失败求助
解决Chrome 115+与Chromedriver版本不兼容问题
方案1:用Selenium自动管理驱动(最省心)
Selenium 4.10.0及以上版本内置了驱动自动匹配功能,不用手动下载chromedriver,直接搞定版本匹配:
- 先升级Selenium到最新版:
pip install --upgrade selenium
- 代码这么写:
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://example.com")
运行后会自动下载适配你当前Chrome版本的驱动,完全不用管版本号的问题。
方案2:手动下载完全匹配的ChromeDriver
Chrome 115之后,驱动迁移到了Chrome for Testing仓库,必须找和Chrome版本完全一致的驱动(哪怕小版本差1都可能出错):
- 确认你的Chrome是Windows/macOS/Linux平台,以及位数(32/64位)
- 下载对应版本的ChromeDriver
- 下载后要么把驱动放到系统PATH目录里,要么在代码里指定路径:
from selenium import webdriver from selenium.webdriver.chrome.service import Service # 替换成你的chromedriver实际路径 service = Service(executable_path="C:/xxx/chromedriver.exe") options = webdriver.ChromeOptions() driver = webdriver.Chrome(service=service, options=options)
方案3:降级Chrome到驱动匹配版本
如果不想折腾,可以暂时把Chrome降级到115.0.5790.170版本,和现有驱动对齐。但不推荐长期这么做,毕竟浏览器更新会修复安全漏洞。
内容的提问来源于stack exchange,提问作者SzB
相关产品推荐
相关产品推荐

