Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

python - Ubuntu: selenium.common.exceptions: session not created: This version of ChromeDriver only supports Chrome version 79

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

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)

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

Upon running chromedriver -v I see the version is:

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

And, running chromium-browser --version I get:

Chromium 79.0.3945.79 Built on Ubuntu , running on Ubuntu 18.04

Upon running chromium-browser -v I see :

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

Two questions I'm hoping to answer :

  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.

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

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

By default, webdriver.Chrome runs /usr/bin/google-chrome if available, not chromium-browser (see Default location of ChromeDriver binary and Chrome binary on windows 7). Check google-chrome --version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...