赞
踩
在使用之前的代码通过web驱动执行时,报错:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 119.0.6045.124 with binary path xxx
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 90, in __init__
keep_alive,
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 114, in __init__
options=options,
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 288, in __init__
self.start_session(capabilities, browser_profile)
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 381, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "D:\develop\python\Python3\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 119.0.6045.124 with binary path xxx
截图如下:
主要报错信息内容翻译如下所示:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 119.0.6045.124 with binary path xxx
翻译:
selenium.common.exceptions.SessionNotCreatedException: 消息:会话未创建:此版本的ChromeDriver只支持Chrome 114版本
当前浏览器版本为119.0.6045.124,二进制路径为xxx
这个报错是由于当前的Chrome版本是119,但ChromeDriver版本是114。需要使用最新版的谷歌驱动安装。国内正常用的网址是:https://registry.npmmirror.com/binary.html?path=chromedriver
但里面最新只到114,所以需要更新的版本。
小伙伴们按下面的解决方法即可解决!!!
需要使用适用于当前Chrome119版本的ChromeDriver版本。通过搜索,找到了这个网址,里面有最新的版本:Chrome for Testing availability。
下载最新的版本后,问题解决。
安装可点击进行参考ChromeDriver谷歌浏览器驱动下载安装与使用最新版118/119/120
完成之后运行如下代码:
# 导入selenium
from selenium import webdriver
# 选择谷歌浏览器
driver = webdriver.Chrome()
# 打印网页title
print(driver.title)
运行之后可以看到:
操作成功了浏览器窗口,并且获取到了当前页面的 title
。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。