Search code examples
linuxpython-3.xseleniumfirefoxgeckodriver

RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox


Somebody...Who use Selenium with Firefox. Write:

  • Which Firefox version you use
  • Which geckodriver version you use
  • And which selenium version you use

It's badly annoying! I have Firefox version 58.0.2, geckodriver 0.19.1, selenium 3.9.0, python 3.6.4 but it doesn't work ! Errors.

I installed Firefox without sudo apt-get (unzipped archive), cause repository haven't new version of Firefox.


Solution

  • So the problem is that selenium can't find Firefox because It's path isn't on your $PATH variable.

    To solve the Issue, You've two options:

    1. Install Firefox from a repository using the package manager

    2. Specify the installed Firefox binary to selenium.

    3. Add the Firefox binary to the Path variable.

    For the second option:

    To set the custom path to Firefox you need to use FirefoxBinary:

    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    
    binary = FirefoxBinary('/Firefox/Path')
    driver = webdriver.Firefox(firefox_binary=binary)
    

    For the third option:

    Add the following to your ~/.profile or ~/.bashrc:

    export PATH="$PATH:/home/firefox"
    

    Use which firefox or whereis firefox to get Firefox path.