[英]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。
Your main issue is the incompatibility between the version of the binaries you are using as follows:您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:
Supports Chrome version 84
支持Chrome 版本 84
So there is a clear mismatch between ChromeDriver v84 and the Chrome Browser v83因此ChromeDriver v84和Chrome 浏览器 v83之间存在明显的不匹配
There are two (2) solutions to this issue.此问题有两 (2) 个解决方案。
Additionally also ensure that:此外,还要确保:
@Test
as non-root user.@Test
。driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.tearDown(){}
方法中调用driver.quit()
以优雅地关闭和销毁WebDriver和Web 客户端实例。 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/downloads从https://chromedriver.chromium.org/downloads 下载并安装最新的 chromedriver
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.