selenium.common.exceptions.SessionNotCreatedException:消息:未创建会话:此版本的ChromeDriver仅支持Chrome版本80 [英] selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80

查看:129
本文介绍了selenium.common.exceptions.SessionNotCreatedException:消息:未创建会话:此版本的ChromeDriver仅支持Chrome版本80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我进入命令提示符并键入chromedriver -v:

ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})

但是当我尝试运行此代码时:

from selenium import webdriver 
class InstaBot:
    def __init__(self):
        self.driver=webdriver.Chrome()
        self.driver.get("www.instagram.com")
InstaBot()

它给了我这样的错误: 引发exception_class(消息,屏幕,堆栈跟踪)

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

为什么发生这种情况,我试图去除硒以及chromedriver 并重新安装版本79.0.3945,但是当我运行它时,它表明只能在版本80上运行 我的chrome版本是最新版本的79.0.3945,而80 chrome版本是chrome beta

解决方案

此错误消息...

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

...表示 ChromeDriver v80.0 无法启动/产生新的浏览上下文,即 Chrome浏览器会话./p>


您的主要问题是所使用的二进制文件版本之间的不兼容性:

  • 您提到过使用 chromedriver = 79.0.3945.36 的情况, chromedriver = 79.0 的发行说明中明确提到了以下内容:

支持 Chrome v79

  • 大概您正在使用 chrome v79.0 浏览器.
  • 因此,很明显,您的系统中存在 chromedriver = 80.0 ,该变量也位于系统PATH变量中,并且在您执行以下操作时被调用:

    self.driver=webdriver.Chrome()
    


解决方案

有两种解决方案:

  • 您可以将 chrome 升级到 Chrome 80.0 级. (根据 ChromeDriver v80.0发行说明)
  • 或者您可以使用 chromedriver v79.0 二进制位置覆盖默认的 chromedriver v80.0 二进制位置,如下所示:

    from selenium import webdriver
    
    driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
    driver.get('http://google.com/')
    

您可以在如何通过Python硒自动更新Chrome浏览器时如何使用特定版本的ChromeDriver

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

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

解决方案

This error message...

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

...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:

  • You mentioned about using chromedriver=79.0.3945.36 and the release notes of chromedriver=79.0 clearly mentions the following :

Supports Chrome v79

  • 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()
    


Solution

There are two solutions:

  • 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\to\chromedriver.exe')
    driver.get('http://google.com/')
    

You can find a detailed discussion in Ubuntu: selenium.common.exceptions: session not created: This version of ChromeDriver only supports Chrome version 79


Additional Considerations

Ensure to:

  • 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() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Reference

You can find a relevant detailed discussion in:

这篇关于selenium.common.exceptions.SessionNotCreatedException:消息:未创建会话:此版本的ChromeDriver仅支持Chrome版本80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆