【问题标题】:SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81SessionNotCreatedException:消息:会话未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 81
【发布时间】:2020-06-03 10:01:00
【问题描述】:

我目前是机器人框架的新手。我目前正在使用最新的 chrome 和 chromedriver 窗口版本,它是 80,但是当我尝试运行测试时,它会给出消息“SessionNotCreatedException:消息:未创建会话:此版本的 ChromeDriver仅支持 pycharm 中的 Chrome 版本 81" 但目前只有 81 的 beta 版本可用。我已尝试卸载所有内容并重新安装它,但没有任何效果可以帮助我解决这个问题。谢谢!

以下截图:

【问题讨论】:

  • 为什么不用81版?它不适用于 80 版。
  • 只有测试版可用,不支持。
  • 请勿发布代码、数据、错误消息等的图片 - 将文本复制或输入到问题中。 How to Ask
  • 在 selenium (Angular 8.2.x) 中运行 E2E 测试时出现相同问题(驱动程序信息:chromedriver=81.0.4044.20 (f006328e39a9769596eb506c8841c3004b24e747-refs/branch-heads/4044@{#244}),platform=Windows NT 10.0.18362 x86_64) 在 Object.checkLegacyResponse (..\node_modules\selenium-webdriver\lib\error.js:546:15) 在 parseHttpResponse (..\node_modules\selenium-webdriver\lib\http.js:509: 13) 在 ..\node_modules\selenium-webdriver\lib\http.js:441:30 at processTicksAndRejections (internal/process/task_queues.js:94:5) [08:54:47] E/launcher - 进程退出错误代码 100
  • 在我的情况下,我所要做的就是打开我的普通 chrome 浏览器,转到菜单 Help -> About Google Chrome 然后它开始将 chrome 更新到最新版本(我有 81 并更新到 83)。重新启动 chrome,当我重新运行 chromedriver 时它工作了。

标签: selenium google-chrome selenium-webdriver selenium-chromedriver robotframework


【解决方案1】:

您只需要从 node_module 中卸载或删除量角器并重新安装即可。

npm uninstall protractor
npm install protractor

【讨论】:

    【解决方案2】:

    你可以处理这个异常

    from selenium.common.exceptions import SessionNotCreatedException
    

    添加此功能

    def update_chrome():
    try:
        print("Updating chrome driver")
        download_chrome = "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
        unpack_chrome = "sudo dpkg -i google-chrome-stable_current_amd64.deb"
        install_chrome = "sudo apt-get -f install"
        
        file_path = os.path.join(os.environ['HOME'], "google-chrome-stable_current_amd64.deb")
        if os.path.isfile(file_path):
            print("{} found\nremoving {}".format(file_path, file_path))
            os.remove(file_path)
        else:
            print("File does not exist {}".format(file_path))
        
        old_chrome_ver = os.popen("/usr/bin/google-chrome --version").read().strip('Google Chrome ').strip().split(".")[0]
        print("Current Chrome version: {}".format(old_chrome_ver))
        
        os.system(command=download_chrome)
        sleep(2)
        os.system(command=unpack_chrome)
        sleep(5)
        os.system(command=install_chrome)
        
        crnt_chrome_ver = os.popen("/usr/bin/google-chrome --version").read().strip('Google Chrome ').strip().split(".")[0]
        print("Current Chrome version: {}".format(crnt_chrome_ver))
        
        if crnt_chrome_ver == old_chrome_ver:
            print("Chrome version is same as before")
        elif crnt_chrome_ver > old_chrome_ver:
            print("Chrome version is updated from {} to {}".format(old_chrome_ver, crnt_chrome_ver))
        return True    
    
    except Exception as e:
        print("Error while updating chrome: {}".format(e))
        return False
    

    然后调用这个函数

    try:
        # Your code here
    except SessionNotCreatedException as snce:
        print("Session not created: {}".format(snce))
        chrome_update_result = False
        if recurrences == 0:
            chrome_update_result = update_chrome()
        if chrome_update_result:
            recurrences += 1
            print("Chrome updated successfully")
            erisapedia_bot(state, download_dir)
            return True
        else:
            print("Chrome update failed")
            return False
    

    【讨论】:

      【解决方案3】:

      解决办法是:-

      • 查看您的 chrome 的 chrome 版本。来自 chrome://settings/help
      • 查看哪个版本的 ChromeDriver 与您当前的兼容 来自here的镀铬版本
      • 下载兼容的并将现有的ChromeDriver替换为 一个新的 ChromeDriver。
      • 现在运行代码

      【讨论】:

        【解决方案4】:

        只需将 Chrome 浏览器更新到可用的最新版本。

        【讨论】:

          猜你喜欢
          • 2020-09-28
          • 1970-01-01
          • 1970-01-01
          • 2020-06-30
          • 1970-01-01
          • 1970-01-01
          • 2020-09-16
          相关资源
          最近更新 更多