I am using Ubuntu 16.04.1 LTS. Executing python -V
returns Python 2.7.12
. I am building a virtualenv off of that so as to install the Selenium package into it via:
pip install -upgrade selenium
But when doing a trial run with the following python script:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
it results this error:
Traceback (most recent call last):
File "/home/myuser/bin/selenium-experiment.py", line 2, in <module>
browser = webdriver.Firefox()
File "/home/myuser/python_virtualenv/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/home/myuser/python_virtualenv/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f782c1caa50>> ignored
Since geckodriver
is an executable, I concluded that it should be provided by the installation of the selenium package via pip
or at least error out with some message stating what I need to do next. Apparently not, so I dug further: I thought that perhaps Ubuntu should have a package that provides the geckodriver
executable so I used apt-file search geckodriver
to search for it and found no results.
Where do I get this geckodriver
executable?
Find the latest release for your OS.
Extract it, and copy geckodriver to
/usr/local/bin
-- so ifv0.11.1
was the most recent version, and you were on 64bit linux, you'd do this:Now your trial run should work.
Ubuntu 16.04+: