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

相关推荐
MATLAB代码顾问2 小时前
5大智能算法优化标准测试函数对比(Python实现)
开发语言·python
ting94520002 小时前
Tornado 全栈技术深度指南:从原理到实战
人工智能·python·架构·tornado
果汁华3 小时前
Browserbase Skills:让 Claude Agent 真正“看见“网页世界
人工智能·python
ZhengEnCi3 小时前
04-缩放点积注意力代码实现 💻
人工智能·python
DeepReinforce3 小时前
三、AI量化投资:使用akshare获取A股主板20260430所有的涨停股票
python·量化·akshare·龙头战法
段一凡-华北理工大学4 小时前
【高炉炼铁领域炉温监测、预警、调控智能体设计与应用】~系列文章08:多模态数据融合:让数据更聪明
人工智能·python·高炉炼铁·ai赋能·工业智能体·高炉炉温
万粉变现经纪人4 小时前
如何解决 pip install llama-cpp-python 报错 未安装 CMake/Ninja 或 CPU 不支持 AVX 问题
开发语言·python·开源·aigc·pip·ai写作·llama
清风明月一壶酒4 小时前
OpenClaw自动处理Word文档全流程
开发语言·c#·word
其实防守也摸鱼4 小时前
CTF密码学综合教学指南--第五章
开发语言·网络·笔记·python·安全·网络安全·密码学
callJJ5 小时前
Spring Data Redis 两种编程模型详解:同步 vs 响应式
java·spring boot·redis·python·spring