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

相关推荐
青槿吖2 分钟前
第一篇:Spring面试高频三连问:容器区别|Bean作用域|生命周期,一篇拿捏!
java·开发语言·网络·网络协议·spring·面试·rpc
怪侠_岭南一只猿4 分钟前
爬虫阶段三实战练习题二:使用 Selenium 模拟爬取拉勾网职位表
css·爬虫·python·selenium·html
Larry_Yanan11 分钟前
QML学习笔记(六十四)动画相关:State状态、Transition过渡和Gradient渐变
开发语言·c++·笔记·qt·学习
Ronin30511 分钟前
【Qt常用控件】显示类控件
开发语言·qt·常用控件·显示类控件
hoiii18711 分钟前
基于MATLAB的滚动轴承信号Paul谱(功率谱密度)分析实现
开发语言·matlab
前端付豪13 分钟前
自动学习建议解决薄弱知识点
前端·python·openai
deephub15 分钟前
LangGraph vs Semantic Kernel:状态图与内核插件的两条技术路线对比
人工智能·python·深度学习·大语言模型·agent
与虾牵手16 分钟前
多轮对话 API 怎么实现?从原理到代码,踩完坑我总结了这套方案
python·aigc·ai编程
phltxy17 分钟前
前缀和算法:从一维到二维,解锁高效区间求和
java·开发语言·算法
香水5只用六神17 分钟前
【RTOS快速入门】05_动态_静态创建任务(1)
c语言·开发语言·单片机·嵌入式硬件·freertos·rtos·嵌入式软件