selenium.common.exceptions.SessionNotCreatedException: 信息: 会话未创建:此版本的ChromeDriver仅支持Chrome 85版本。

5

嘿,我有一个使用Selenium打开Google的简单代码:

from selenium import webdriver
import chromedriver_binary


driver = webdriver.Chrome()
driver.get('https://google.com')

我没有打开Google页面,而是遇到了这个错误。

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\vipku\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\vipku\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\vipku\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\vipku\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\vipku\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, 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 85

你使用的是哪个版本的Chrome浏览器? - Peaceful James
我不是。我正在导入chromedriver_binary模块,它基本上获取Web驱动程序的版本85.0.4183.38并将其添加到路径,而无需将exe文件添加到路径。 - alnesef2002
3个回答

4

This error message...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 85

这意味着ChromeDriver v85.0无法初始化/生成一个新的浏览上下文,也就是Chrome浏览器会话。


你的主要问题在于你使用的二进制版本之间存在不兼容性,具体如下:

  • 您提到使用chromedriver=85.0.4183.38,而chromedriver=85.0.4183.38的发布说明明确提到了以下内容:

支持Chrome版本85

  • 你使用的当前版本的Chrome浏览器应该是Version 84.0.4147.135

因此,ChromeDriver v85.0Chrome浏览器v84.0之间存在明显的不匹配。


解决方案

请确保:

  • ChromeDriver已更新到当前的ChromeDriver v84.0级别。
  • Chrome已更新到当前(已发布)的Chrome Version 84.0级别(根据ChromeDriver v84.0发布说明)。
  • 通过您的IDE清理项目工作空间,并仅使用所需的依赖项重新构建您的项目。
  • 如果您的基本Web客户端版本太旧,则卸载它并安装最近的GA和发布版本的Web客户端
  • 进行一次系统重启
  • 非root用户身份执行您的@Test
  • 始终在tearDown(){}方法中调用driver.quit()以优雅地关闭和销毁WebDriverWeb Client实例。

参考资料

您可以在以下讨论中找到相关的详细信息:


1

1

我使用以下代码解决了问题:pip install chromedriver-binary==83.0.4103.39


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