Chrome自动更新后,chromedriver版本不匹配的问题
问题
使用selenium模块的webdriver打开网页时,发现报错:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 122
Current browser version is 128.0.6613.138 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
原因是chrome自动更新了版本,chromedriver的版本和chrome不匹配了
解决方法
1.查看当前Chrome浏览器版本并下载对应版本的chromedriver
下载地址: https://googlechromelabs.github.io/chrome-for-testing/
2.调用 where chromedriver 命令找到之前的chromedriver所在目录
3.把新下载的chromedriver.exe替换python目录下Scripts文件中的旧chromedriver.exe
4.再次运行之前程序即可