click_web(main_page_url)..._raise exception_class(message, screen, stacktrace) sessionnotcreate">
当前位置:   article > 正文

解决selenium.common.exceptions.SessionNotCreatedException:ChromeDriver only supports Chrome version 77_raise exception_class(message, screen, stacktrace)

raise exception_class(message, screen, stacktrace) sessionnotcreatedexceptio

环境

  • Ubuntu 16.04 LTS
  • python 3.x

报错信息:

使用 Chrome 浏览器运行Web自动化测试报错,信息如下:

Traceback (most recent call last):
  File "click_csdn_chromedriver.py", line 80, in <module>
    click_web(main_page_url)
  File "click_csdn_chromedriver.py", line 13, in click_web
    browser = webdriver.Chrome()
  File "/home/zzh/.local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/zzh/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/zzh/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/zzh/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/zzh/.local/lib/python3.5/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 77
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

原因

chrome和chromedriver版本不匹配


解决方法

  • 1、在chrome浏览器地址里面输入:chrome://version/,查看浏览器版本
    在这里插入图片描述

  • 2、找对应的chromedriver版本

    chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.html
    对应我的chrome版本,我下载的是:
    在这里插入图片描述

  • 3、 解压
    unzip chromedriver_linux64.zip

  • 4、mv到/usr/local/bin/下

    sudo mv chromedriver /usr/local/bin/

  • 5、查看版本

    chromedriver -v

    ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185})
    
    • 1
  • 6、再次运行程序,一切ok!


参考

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/168489?site
推荐阅读
相关标签
  

闽ICP备14008679号