What to Do When 'geckodriver' Executable Needs to Be in PATH in Ubuntu's Selenium

Linux
2017-02-03 00:40 (9 years ago)
What to Do When 'geckodriver' Executable Needs to Be in PATH in Ubuntu's Selenium

Trying to run Selenium on Ubuntu from Python

Traceback (most recent call last):
... omitted ...
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 81, 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 0x7fd28405b350>> ignored

If that happens,

wget https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-v0.14.0-linux64.tar.gz
tar -zxvf geckodriver-v0.14.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/

You can check the latest release here: https://github.com/mozilla/geckodriver/releases

By the way, the constructor of webdriver.Firefox is as follows:

    def __init__(self, firefox_profile=None, firefox_binary=None,
                 timeout=30, capabilities=None, proxy=None,
                 executable_path="geckodriver", firefox_options=None,
                 log_path="geckodriver.log"):
        """Starts a new local session of Firefox.

So, it seems you can also specify the full path of geckodriver in the executable_path parameter.

Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive