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

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

问题描述

我有一个在AWS的EC2实例(ubuntu)上运行的python脚本.它使用硒.它运行了好几个星期,然后突然间,今天,它停止工作并出现以下错误:

I have a python script running on an EC2 instance (ubuntu) on AWS. It uses selenium. It was working perfectly for weeks, and then all of the sudden, today, it stopped working with the following error:

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

这是我在ubuntu上运行的python脚本:

Here is my python script, which I'm running on ubuntu:

#install dependencies
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import ElementNotVisibleException
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

#Set up chromedriver
options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--window-size=1420,1080')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")

driver = webdriver.Chrome(chrome_options=options)

奇怪的是,chromedriver和Chrome浏览器似乎兼容.

What is odd is that chromedriver and chromium-browser appear to be compatible.

运行chromedriver -v后,我看到的版本是:

Upon running chromedriver -v I see the version is:

ChromeDriver 79.0.3945.79 (29f75ce3f42b007bd80361b0dfcfee3a13ff90b8-refs/branch-heads/3945@{#916})

然后,运行chromium-browser --version我得到:

Chromium 79.0.3945.79 Built on Ubuntu , running on Ubuntu 18.04

运行chromium-browser -v后,我看到了:

(chromium-browser:2901): Gtk-WARNING **: 17:28:14.613: cannot open display: 

我希望回答两个问题:

  1. 如何工作几个星期,然后突然,chromedriver和chrome决定不相互合作?可能是chromedriver或chrome被更新而没有另一个被更新吗?除了更新从crontab运行脚本的时间以外,我没有进行任何更改.

  1. How could work for weeks, and then all of the sudden, chromedriver and chrome decide not to cooperate with each other? Could it be that either chromedriver or chrome was updated without the other being updated? I did not change anything, with the exception of updating the time from which the script was run from crontab.

当我的chromedriver和chrome浏览器版本完全相同时,为什么会发生此错误?要让chromedriver在ubuntu上使用chrome(无头),这是一个非常漫长的过程,如果可能,我想设置并忘记它".希望能更好地理解此问题,以免再次发生此问题.

Why is this error happening when my chromedriver and chrome browser are the exact same version? It was an extremely long process to get chromedriver to work with chrome (headless) on ubuntu and I'd like to "set it and forget it" if possible. Looking for away to better understand this problem so I can avoid it happening again and again.

谢谢.

推荐答案

此错误消息...

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

...表示 ChromeDriver v79 无法启动/产生新的 Browsing Context 即浏览器版本所在的 Chrome浏览器会话而不是v79.x.

...implies that the ChromeDriver v79 was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session where the browser version was other then v79.x.

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

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.79. Though the released versions of ChromeDriver v79.x are ChromeDriver 79.0.3945.16 (2019-10-30) and ChromeDriver 79.0.3945.36 (2019-11-18), however both the release notes of chromedriver=79.0.3945.79 clearly mentions the following :

支持 Chrome v79

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