报错情况
The chromedriver version (126.0.6478.182) detected in PATH at D:\develop\chromedriver.exe might not be compatible with the detected chrome version (129.0.6668.58); currently, chromedriver 129.0.6668.58 is recommended for chrome 129.*, so it is advised to delete the driver in PATH and retry Traceback (most recent call last):
这个错误提示表明在你的系统路径(PATH)中检测到的 ChromeDriver 版本(126.0.6478.182)与检测到的 Chrome 浏览器版本(129.0.6668.58)不兼容。目前,对于 Chrome 129.* 版本,推荐使用 ChromeDriver 129.0.6668.58。
解决方法如下:
- 删除系统路径(PATH)中的旧版本 ChromeDriver。找到文件路径 D:\develop\chromedriver.exe 并将其删除。每个人路径不一样,找你自己驱动安装的位置。
- 下载与你的 Chrome 浏览器版本对应的 ChromeDriver 版本。你可以在以下网址查找与你的 Chrome 版本匹配的 ChromeDriver:https://googlechromelabs.github.io/chrome-for-testing/。
- 将下载的新 ChromeDriver 文件放置在你的项目目录中,并在你的代码中指定 ChromeDriver 的路径,或者将其添加到系统环境变量中以便能够被自动识别。
这样可以确保你的 Selenium 脚本能够正确地与 Chrome 浏览器进行交互,避免出现版本不兼容的错误。