Python selenium error when trying to launch firefox

Try specify your Firefox binary when initialize Firefox()

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)

The default path FirefoxDriver looking for is at %PROGRAMFILES%\Mozilla Firefox\firefox.exe. See FirefoxDriver

Or add your path of Firefox binary to Windows' PATH.


Requirements:

  • Ubuntu 16.04 (i386)
  • Firefox 65.0.1.
  • python 3.8.5
  • geckodriver-v0.27.0-linux32.tar.gz

This is what I do:

  • pip3 install selenium

  • Download geckodriver v0.27.0

  • Extract geckodriver

  • mv geckodriver /usr/local/bin/

  • export PATH=$PATH:/usr/local/bin/geckodriver

  • check Xauthority with command --> locate Xauthority

  • cd /home/your-user/Xauthority

  • chown root: .Xauthority

  • create python code:

    from selenium import webdriver

    browser = webdriver.Firefox() browser.get('http://localhost')

  • Run python script.


A similar error happened to me on Linux. Solved it by installing firefox with apt instead of snap.


Problem is ocuring because you don't have geckodriver

Solution:

  1. Go to this website and download appropriate version for you machine, make sure that you have .exe file inside the archieve.
  2. Then unpack and copy .exe file to your directory