ChromeDriver与Chrome版本不兼容求助:如何用Chrome测试版124运行代码
解决ChromeDriver与Chrome测试版124的版本匹配问题
你遇到的错误核心是版本不匹配:ChromeDriver 124仅支持Chrome 124版本,但当前系统默认调用的是123稳定版。要使用Chrome测试版124运行程序,按以下步骤操作:
1. 安装Chrome测试版124
- 获取Chrome测试版安装包并完成安装,测试版会被安装到独立目录(默认路径通常为
C:\Program Files\Google\Chrome Beta\Application\chrome.exe) - 安装后打开Chrome测试版,在
设置 > 关于Chrome中确认版本为124.x.x.x
2. 修改代码指定Chrome测试版路径
在原代码中添加options配置,明确指定测试版Chrome的二进制文件路径,让Selenium调用测试版而非默认的稳定版:
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options driver_path = r"C:\Users\hp\Desktop\Udemy\chromedriver.exe" # 保留你的ChromeDriver路径 chrome_beta_path = r"C:\Program Files\Google\Chrome Beta\Application\chrome.exe" # 配置Chrome选项,指定测试版浏览器路径 options = Options() options.binary_location = chrome_beta_path # 初始化驱动服务与浏览器实例 service = Service(executable_path=driver_path) driver = webdriver.Chrome(service=service, options=options) driver.get("https://www.google.com")
运行修改后的代码,Selenium会启动Chrome测试版124,与你的ChromeDriver 124版本匹配,即可正常执行。
内容的提问来源于stack exchange,提问作者AFREEN POLY
相关产品推荐
相关产品推荐

