在进行Selenium项目更新时遇到SessionNotCreatedException错误,经过排查发现可能是由于Selenium版本升级至4.x.x导致的,该版本可能对Chrome版本有最低要求。解决方案包括回退到Selenium3.141.0版本或升级Chrome和chromedriver到最新版,并使用services设置chromedriver路径。
摘要生成于
,由 DeepSeek-R1 满血版支持,
今天做selenium项目更新,莫名其妙报了SessionNotCreatedException 错误,显示错误如下:
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 89, in __init__
keep_alive,
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 112, in __init__
options=options,
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "D:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Missing or invalid capabilities
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.18363 x86_64)
显示不是chromedriver与chrome版本不兼容问题。后面脑回路,终于知道原因。
之前可能安装了其它包把selenium版本更新到了4.x.x。猜测这个版本对chrome版本有最低要求。经过升级chrome版本与chromedriver,测试了下也确实能正常。懒得去追根溯源了,解决方案:
1)安装回selenium 3版本,目前最后一版3的版本号是3.141.0:
pip install selenium==3.141.0
2)升级chrome与chromedriver到较新版。记selenium4 使用services设置chromedriver路径:
from selenium.webdriver.chrome.service import Service as ChromeService
......
s = ChromeService(executable_path=driver_path)
webdriver.Chrome(service=s, options=options)
selenium.common.SessionNotCreatedException Message session not created.ChromeDriver support ver解决方案
本文主要介绍了selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 102 Current browser version is 114.0.5735.248解决方案,希望能对学习Python selenium的同学们有所帮助。
1. 问题描述
2. 解决方案
解决报错:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versi
报错selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version
Chrome与ChromeDriver版本不一致
executable_path = Service(r"C:\Program Files\Python39\Scripts\chromedriver.exe")
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
browser = w.
E:\Python\python.exe D:/PythonWorkSpace/PythonTest/Common/ChromeWebDriver.py
Traceback (most recent call last):
File "D:/PythonWorkSpace/PythonTest/Common/ChromeWebDriver.py", line 9, in <module>
driver = we
selenium3.141.0+python3.6.7+firefox66.0
上述配置,下载geckodriver v0.24.0版本,驱动已配置到path中。
驱动从v0.21.0试到v0.24.0,全部报以下错误。
另外,电脑里还有个firefox35,跟firefox66不在一个盘符。
使用driver=webdriver.Firefox()
一直报错
实在菜鸡,折腾不出来,...
错误提示:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
Chrome版本和ChromeDriver版本不一致,极有可能是Chrome浏览器自动升级了新版本,导致两者版本差异,运行不了。
解决方法:
1)查看Chrome浏览器的版本
我这里是83版本的
【chromium】解决vpython.bat generate_location_tags.py location_tags.json returned non-zero exit status 1
史蒂芬闰土:
交叉编译aarch64架构支持openssl的curl、libcurl
咕咕827:
python 报 selenium.common.exceptions.SessionNotCreatedException
T-fly:
使用qt5.15.2 qmake 编译qtwebengine支持mp4
SmarterTech:
使用qt5.15.2 qmake 编译qtwebengine支持mp4
Tan_.: