selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 103 Current browser version is 106.0.5239.0

发布时间 2023-12-06 15:32:50作者: ziff123

pyhon 调selenium报:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 103
Current browser version is 120.0.xxx.0 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Stacktrace:

原因:当前安装的谷歌浏览器内核跟chromeDriver版不一致引起

解决方法:1、安装chromedriver 版本120与谷歌内核浏览器内核一致。

2、安装谷歌浏览器内核为103与chromedriver一致

实施:

第一种方案:在 https://registry.npmmirror.com/binary.html?path=chromedriver/ 这里面找了一圈,没有找到120版本的,这种方案方弃。

第二种方案:在https://registry.npmmirror.com/binary.html?path=chromium-browser-snapshots/Win_x64/ 里面找到内核103版本的谷歌浏览器

 注意,这个名称跟实际版本不一致。

解压出来。

找到谷歌浏览器的安装目录,我的是C:\Program Files\Google\Chrome\Application,将里面的文件全部删掉,然后将上面下载的谷歌浏览器解压出来,全部复制进来。重新运行程序就可以。这种方法谷歌浏览器也不会自动更新。