selenium.common.exceptions.SessionNotCreatedException:消息:会话未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 80 [英] selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
问题描述
当我进入命令提示符并输入 chromedriver -v 时:
when i go to command prompt and type chromedriver -v:
ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})
但是当我尝试运行此代码时:
but when i try to run this code :
from selenium import webdriver
class InstaBot:
def __init__(self):
self.driver=webdriver.Chrome()
self.driver.get("www.instagram.com")
InstaBot()
它给了我这样的错误:引发异常类(消息,屏幕,堆栈跟踪)
it gives me error like this: raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
为什么会发生这种情况我试图删除 selenium 和 chromedriver并重新安装版本 79.0.3945 但当我运行它时,它显示这只能在版本 80 上运行我的 chrome 版本是最新的 79.0.3945,版本 80 chrome 是 chrome beta
why this is happening i tried to remove selenium as well as chromedriver and reinstall of version 79.0.3945 but when i run it ,it show this can only be run on version 80 my chrome version is 79.0.3945 which is lastest ,and version 80 chrome is chrome beta
推荐答案
此错误信息...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
...表示 ChromeDriver v80.0 无法启动/生成新的浏览上下文,即 Chrome 浏览器 会话.
...implies that the ChromeDriver v80.0 was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- 您提到使用 chromedriver=79.0.3945.36 并且 chromedriver=79.0 的发行说明清楚地提到以下内容:
- You mentioned about using chromedriver=79.0.3945.36 and the release notes of chromedriver=79.0 clearly mentions the following :
支持 Chrome v79
- 大概您正在使用 chrome v79.0 浏览器.
因此,很明显您的系统中存在 chromedriver=80.0,它也在系统
PATH
变量中,并在您调用时调用:>- Presumably you are using chrome v79.0 browser.
So, it's quite evident your have chromedriver=80.0 present within your system which is also within the system
PATH
variable and is invoked while you:self.driver=webdriver.Chrome()
- 要么将 chrome 升级到 Chrome 版本 80.0 级别.(根据 ChromeDriver v80.0 发行说明)
或者您可以使用 chromedriver v79.0 二进制位置覆盖默认的 chromedriver v80.0 二进制位置,如下所示:
- Either you upgrade chrome to Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)
Or you can override the default chromedriver v80.0 binary location with chromedriver v79.0 binary location as follows:
有两种解决方案:
from selenium import webdriver driver = webdriver.Chrome(executable_path=r'C:path ochromedriver.exe') driver.get('http://google.com/')
- 清理您的项目工作区,通过您的 IDE 并重建您的项目,仅使用所需的依赖项.
- 如果您的基本 Web Client 版本太旧,请将其卸载并安装 Web Client 的最新 GA 和发布版本.
- 进行系统重启.
- 以非root用户身份执行您的
@Test
. - 总是在
tearDown(){}
方法中调用driver.quit()
来关闭 &优雅地销毁 WebDriver 和 Web Client 实例. - Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test
as non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
您可以在 Ubuntu:selenium.common.exceptions:未创建会话:此版本的 ChromeDriver 仅支持 Chrome 版本 79
<小时>
其他注意事项
确保:
您可以在以下位置找到相关的详细讨论:
You can find a relevant detailed discussion in:
这篇关于selenium.common.exceptions.SessionNotCreatedException:消息:会话未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!