Python——调用webdriver.Chrome() 报错

今天运行脚本,报错内容如下:

collecting ...
login_case.py:None (login_case.py)
login_case.py:11: in <module>
dr = webdriver.Chrome()
D:\Program Files (x86)\Python\Python39\Lib\site-packages\selenium\webdriver\chrome\webdriver.py:76: in init
RemoteWebDriver.init(
D:\Program Files (x86)\Python\Python39\Lib\site-packages\selenium\webdriver\remote\webdriver.py:157: in init
self.start_session(capabilities, browser_profile)
D:\Program Files (x86)\Python\Python39\Lib\site-packages\selenium\webdriver\remote\webdriver.py:252: in start_session
response = self.execute(Command.NEW_SESSION, parameters)
D:\Program Files (x86)\Python\Python39\Lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
D:\Program Files (x86)\Python\Python39\Lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: in check_response
raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 97
E Current browser version is 115.0.5790.110 with binary path C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe

collected 0 items / 1 error

【报错翻译】This version of ChromeDriver only supports Chrome version 97。此版本的ChromeDriver仅支持Chrome版本97,需要升级Chrome驱动版本WebDriver。

【原因】:

ChromeDriver驱动需要对应的浏览器版本,而当前安装的浏览器版本太低

【解决办法】:

方法1. 更新与当前安装Chrome浏览器版本相对应的driver。

【具体步骤】

查看本机电脑已安装的Chrome版本为115版本。

打开chromedriver下载地址 https://chromedriver.storage.googleapis.com/index.html,找到115版本对应的驱动,下载安装包。

安装包解压后放进Python的安装路径下

方法2: 安装旧版本并关闭谷歌浏览器自动更新功能。

仅阐述关闭谷歌浏览器自动升级功能,防止再次发生此类情况。

右键单击【我的电脑】------【管理】------【计算机管理本地】------【系统工具】------【任务计划程序】------【任务计划程序库】------这里找到两个和Google自动更新相关的任务计划【GoogleUpdateTaskMachineCore】与【GoogleUpdateTaskMachineUA】,把这两个选项禁用。

如果在【服务和应用程序】------【服务】,也存在Google更新相关的服务【Google更新服务(gupdate)】、【Google更新服务(gupdatem)】,右键------选择属性------启动类型禁用。

相关推荐
大米2H4 小时前
Jupyter lab 配置两个python环境
ide·python·jupyter
MessiGo4 小时前
Javascript 编程基础(5)面向对象 | 5.2、原型系统
开发语言·javascript·原型模式
猎嘤一号5 小时前
使用 PyTorch 和 TensorBoard 实时可视化模型训练
人工智能·pytorch·python
慢半拍iii5 小时前
数据结构——D/串
c语言·开发语言·数据结构·c++
Takina~6 小时前
python打卡day49
python
爱学习的白杨树6 小时前
Sentinel介绍
java·开发语言
Frankabcdefgh6 小时前
Python基础数据类型与运算符全面解析
开发语言·数据结构·python·面试
是梦终空6 小时前
Python毕业设计226—基于python+爬虫+html的豆瓣影视数据可视化系统(源代码+数据库+万字论文)
爬虫·python·html·毕业设计·毕业论文·源代码·豆瓣影视数据可视化
kaiaaaa6 小时前
算法训练第十五天
开发语言·python·算法
小玺玺7 小时前
[RDK X5] MJPG编解码开发实战:从官方API到OpenWanderary库的C++/Python实现
c++·python·opencv·rdk x5