会话未创建异常:消息:会话未创建:此版本的ChromeDriver仅支持Chrome 96版本,当前浏览器版本为98.0。

20

错误跟踪日志:

DevTools listening on ws://127.0.0.1:54791/devtools/browser/6f264bcc-d44a-40d9-b6cf- 
8b1655c97ccd
Traceback (most recent call last):
File "c:\Users\alsgn\OneDrive\desktop\mypython\getselenium\dc\findbulletins.py", line 11, in 
<module>
browser = webdriver.Chrome()
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "C:\Users\alsgn\AppData\Local\Programs\Python\Python39\lib\site- 
packages\selenium\webdriver\remote\errorhandler.py", line 247, 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 96
Current browser version is 98.0.4758.82 with binary path C:\Program 
Files\Google\Chrome\Application\chrome.exe
Stacktrace:
Backtrace:
    Ordinal0 [0x00FF6903+2517251]
    Ordinal0 [0x00F8F8E1+2095329]
    Ordinal0 [0x00E92848+1058888]
    Ordinal0 [0x00EB0B9D+1182621]
    Ordinal0 [0x00EACA60+1165920]
    Ordinal0 [0x00EAA2CF+1155791]
    Ordinal0 [0x00EDAAAF+1354415]
    Ordinal0 [0x00EDA71A+1353498]
    Ordinal0 [0x00ED639B+1336219]
    Ordinal0 [0x00EB27A7+1189799]
    Ordinal0 [0x00EB3609+1193481]
    GetHandleVerifier [0x01185904+1577972]
    GetHandleVerifier [0x01230B97+2279047]
    GetHandleVerifier [0x01086D09+534521]
    GetHandleVerifier [0x01085DB9+530601]
    Ordinal0 [0x00F94FF9+2117625]
    Ordinal0 [0x00F998A8+2136232]
    Ordinal0 [0x00F999E2+2136546]
    Ordinal0 [0x00FA3541+2176321]
    BaseThreadInitThunk [0x755AFA29+25]
    RtlGetAppContainerNamedObjectPath [0x775C7A9E+286]
    RtlGetAppContainerNamedObjectPath [0x775C7A6E+238]

我运行的代码在两天前还可以,但现在它显示了这个错误。 请告诉我如何解决这个问题。我想知道为什么之前它能正常运行。


错误很明显:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 96 Current browser version is 98.0.4758.82 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe。这是一个版本兼容性问题。您的Chrome浏览器已更新到版本98,但驱动程序仍处于版本96。下载更新的chromedriver(chromedriver 98),它应该可以正常工作。 - Anand Gautam
8个回答

8
我也遇到过同样的问题,你需要做的就是前往https://chromedriver.chromium.org/downloads,查看你的浏览器版本并进行相应的下载,将新的 chromedriver.exe 替换旧的,它就能正常工作了。

7

这个错误信息...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 96
Current browser version is 98.0.4758.82 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe

这意味着ChromeDriver无法启动/生成新的浏览上下文,即会话。
您的主要问题在于您使用的二进制文件版本不兼容,具体如下:

支持Chrome 98版本

支持Chrome 96版本

因此,chromedriver=96.0chrome=96.0.4664.45之间存在明显的不匹配。


解决方案

请确保:


4

我也收到了这个错误消息,因为我忘记关闭Chrome的更新。我使用的是chromedriver 98.0.4758.80,但现在我的Chrome版本是98.0.4758.82。因此,即使您更新到我使用的最新的chromedriver 98.0.4758.80,您仍将收到此错误消息或类似的消息。

对于我来说,有两种解决方案,首先关闭Chrome更新服务。

  • 等待支持98.0.4758.82的新chromedriver更新
  • 将Chrome降级到版本98.0.4758.80-我仍在苦苦尝试执行降级操作。

也许有人可以解释如何将Chrome降级到早期版本。否则,我们需要等待chromedriver的更新。


3
在我的情况下,只需升级chromedriver自动安装程序即可解决问题。
pip install --upgrade chromedriver-autoinstaller

请以管理员身份运行上述命令。


2
您的输出日志显示:
This version of ChromeDriver only supports Chrome version 96
Current browser version is 98.0.4758.82 with binary path

您有两个选项:

  1. 使用适用于Chrome 98的chromedriver
  2. 安装Chrome 96

1

这是我最近想出的解决方案。我正在使用macOS和Python 3.11进行UI自动化。

您可以使用以下pip命令安装正确版本的chromedriver。

brew install --cask chromedriver

如果您发现chromedriver已经安装在您的系统中,请使用以下命令重新安装。
brew reinstall --cask chromedriver

1
对于C#用户,如果需要,以下内容会自动更新:
IWebDriver driver;
try
{
    driver = new ChromeDriver(chromeOptions);
} 
catch(System.InvalidOperationException ex)
{
    // Update the chromedriver, then retry.
    new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
    driver = new ChromeDriver(chromeOptions);
}

如果发现旧版本,则捕获异常,运行更新,并消除错误。

0

@Ssproutt,Chromedriver已更新至版本98.0.4758.102。

  1. 将Chrome浏览器更新至版本98.0.4758.102
  2. 下载最新的Chromedriver https://chromedriver.storage.googleapis.com/index.html?path=98.0.4758.102/

注意版本不匹配的问题。您可以通过重命名位于C:\Program Files (x86)\Google\Update\的Chrome更新文件(GoogleUpdate.exe)来确保不更新Chrome浏览器。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接