Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium fails to start Chromedriver

I am unable to start Chromedriver with Selenium.

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://www.google.com')

It never gets to browser.get('http://www.google.com') but fails with:

    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.13.0-76-generic x86_64)

I am on Ubuntu 14.04 (64b) using Python 2.7.6 (virtualenv installation) and selenium==2.50.1.

dm@Z580:~$ which chromedriver
/usr/local/bin/chromedriver

dm@Z580:~$ ll /usr/local/bin/chromedriver
lrwxrwxrwx 1 root root 24 feb  4 22:13 /usr/local/bin/chromedriver -> /opt/google/chromedriver*

EDIT

dm@Z580:~$ google-chrome --version
Google Chrome 48.0.2564.97 

Downgraded to Chromedriver 2.20:

wget http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod 777 chromedriver
sudo mv -f chromedriver /opt/google/chromedriver

but, sadly, still the same result.

Any idea why is this happening?

like image 894
Dušan Maďar Avatar asked Feb 04 '16 22:02

Dušan Maďar


1 Answers

Ok, so the solution is a bit weird.

I moved the Chromedriver binary from /opt/google/ (where Google Chrome is installed itself) to /opt/, updated the symlink and it's working now!

Compared to the question itself, these two lines of code solve the issue:

sudo mv /opt/google/chromedriver /opt/
sudo ln -fs /opt/chromedriver /usr/local/bin/chromedriver

And now I am able to run the following Python code:

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://www.google.com')

Chrome starts and everything.

The following line on the old Selenium docs page inspired me to check and eventually to change the Chromedriver location:

For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.

like image 184
Dušan Maďar Avatar answered Sep 23 '22 19:09

Dušan Maďar