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)】,右键------选择属性------启动类型禁用。

相关推荐
iCxhust3 分钟前
c# U盘映像生成工具
开发语言·单片机·c#
yangzhi_emo42 分钟前
ES6笔记2
开发语言·前端·javascript
emplace_back2 小时前
C# 集合表达式和展开运算符 (..) 详解
开发语言·windows·c#
jz_ddk2 小时前
[学习] C语言数学库函数背后的故事:`double erf(double x)`
c语言·开发语言·学习
萧曵 丶2 小时前
Rust 所有权系统:深入浅出指南
开发语言·后端·rust
xiaolang_8616_wjl2 小时前
c++文字游戏_闯关打怪2.0(开源)
开发语言·c++·开源
收破烂的小熊猫~2 小时前
《Java修仙传:从凡胎到码帝》第四章:设计模式破万法
java·开发语言·设计模式
蹦蹦跳跳真可爱5893 小时前
Python----OpenCV(图像増强——高通滤波(索贝尔算子、沙尔算子、拉普拉斯算子),图像浮雕与特效处理)
人工智能·python·opencv·计算机视觉
nananaij3 小时前
【Python进阶篇 面向对象程序设计(3) 继承】
开发语言·python·神经网络·pycharm