简体   繁体   English

SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 84 使用 ChromeDriver 和 Chrome 通过 Selenium 和 Python

[英]SessionNotCreatedException: This version of ChromeDriver only supports Chrome version 84 using ChromeDriver and Chrome through Selenium and Python

I am using python 3 on windows 7, selenium, chromedriver version 84 (latest) to automate my chrome browser.我在 windows 7、selenium、chromedriver 版本 84(最新)上使用 python 3 来自动化我的 chrome 浏览器。

I am using this script:我正在使用这个脚本:

from selenium import webdriver
#import chromedriver_binary  # Adds chromedriver binary to path

driver = webdriver.Chrome()
driver.get("http://www.python.org")

and I always get this error upon running it.我总是在运行它时遇到这个错误。

Traceback (most recent call last):
  File "D:\Huzefa\Desktop\zzzzzz.py", line 4, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\Huzefa\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\Huzefa\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\Huzefa\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Huzefa\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Huzefa\AppData\Local\Programs\Python\Python36\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 84

My ChromeDriver is in path.我的 ChromeDriver 在路径中。 Also i have used other versions of chromedriver but i am not able to navigate to a website!我也使用过其他版本的 chromedriver,但我无法导航到网站!

Your ChromeDriver version and your installed version of Chrome need to match up.您的 ChromeDriver 版本和您安装的 Chrome 版本需要匹配。 You are using ChromeDriver for Chrome version 84 , which at the time of this answer, is a beta (non-stable) build of Chrome;您正在使用 ChromeDriver for Chrome version 84 ,在此答案时,它是 Chrome 的 beta(非稳定)版本; you're probably not using it.你可能没有使用它。 Likely you're on version 83.您可能使用的是 83 版。

Check your Chrome version (Help -> About) and then find the correct ChromeDriver release .检查您的 Chrome 版本(帮助 -> 关于),然后找到正确的ChromeDriver 版本 You could instead use webdriver-manager which can handle this for you.您可以改为使用可以为您处理此问题的webdriver-manager

This error message...此错误消息...

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

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context ie Chrome Browser session. ...意味着ChromeDriver无法启动/产生新的浏览上下文,即Chrome 浏览器session。


Analysis分析

Your main issue is the incompatibility between the version of the binaries you are using as follows:您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

  • You are using chromedriver=84您正在使用chromedriver=84
  • Release Notes of chromedriver=84 clearly mentions: chromedriver=84的发行说明明确提到:

Supports Chrome version 84支持Chrome 版本 84

  • Presumably you are using chrome=83 the latest push for Chrome.大概您正在使用chrome=83最新的 Chrome 推送。

谷歌浏览器是最新的

So there is a clear mismatch between ChromeDriver v84 and the Chrome Browser v83因此ChromeDriver v84Chrome 浏览器 v83之间存在明显的不匹配


Solution解决方案

There are two (2) solutions to this issue.此问题有两 (2) 个解决方案。

Additionally also ensure that:此外,还要确保:

  • Selenium is upgraded to current levels Version 3.141.59 . Selenium升级到当前级别版本 3.141.59
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client .如果您的基础Web 客户端版本太旧,请卸载它并安装最新的 GA 和发布版本的Web 客户端
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.通过您的IDE清理您的项目工作区,并仅使用所需的依赖项重建您的项目。
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client .如果您的基础Web 客户端版本太旧,请卸载它并安装最新的 GA 和发布版本的Web 客户端
  • Take a System Reboot .重新启动系统
  • Execute your @Test as non-root user.非 root用户身份执行您的@Test
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.始终在tearDown(){}方法中调用driver.quit()以优雅地关闭和销毁WebDriverWeb 客户端实例。

We can automate the task of downloading the binary and configuring the path.我们可以自动化下载二进制文件和配置路径的任务。

We dont have to worry about the browser version or the binary version我们不必担心浏览器版本或二进制版本

This can be done by using webdriver-manager这可以通过使用webdriver-manager来完成

pip install webdriver-manager

Now the above code in the question will work simply with the below change,现在问题中的上述代码将与以下更改一起工作,

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
 

The same can be used to set Firefox, Edge, and ie binaries.同样可用于设置 Firefox、Edge 和 ie 二进制文件。

Original Answer - https://stackoverflow.com/a/58727916/9928905原始答案 - https://stackoverflow.com/a/58727916/9928905

Chromedriver needs to be updated. Chromedriver 需要更新。

Download and install the latest chromedriver from https://chromedriver.chromium.org/downloadshttps://chromedriver.chromium.org/downloads 下载并安装最新的 chromedriver

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SessionNotCreatedException:消息:会话未创建:此版本的 ChromeDriver 仅支持带有 Selenium ChromeDriver 的 Chrome 版本 76 - SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 76 with Selenium ChromeDriver SessionNotCreatedException:消息:会话未创建:此版本的 ChromeDriver 仅支持使用 ChromeDriver 和 Chrome 的 Chrome 版本 87 - SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 87 using ChromeDriver and Chrome Python selenium - session not created: This version of ChromeDriver only supports Chrome version 86 using ChromeDriver and Chrome with Selenium - Python selenium - session not created: This version of ChromeDriver only supports Chrome version 86 using ChromeDriver and Chrome with Selenium SessionNotCreatedException:消息:session 未创建:此版本的 ChromeDriver 仅支持使用 Selenium ChromeDriver v81 的 Chrome 版本 81 - SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 using Selenium ChromeDriver v81 使用 Chrome v84 时“此版本的 ChromeDriver 仅支持 Chrome 版本 84” - “This version of ChromeDriver only supports Chrome version 84” when using Chrome v84 selenium.common.exceptions.SessionNotCreatedException:消息:session 未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 85 - selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 85 selenium.common.exceptions.SessionNotCreatedException:消息:session 未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 83 - selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 83 selenium ChromeDriver 仅支持 Chrome 版本 91 - selenium ChromeDriver only supports Chrome version 91 SessionNotCreatedException:消息:session 未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 99 当前浏览器版本为 105 - SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 99 Current browser version is 105 Selenium报错:这个版本的ChromeDriver只支持Chrome 83版? - Selenium error: This version of ChromeDriver only supports Chrome version 83?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM