Python selenium error when trying to launch firefox
Try specify your Firefox binary when initialize Firefox()
from selenium import webdriverfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinarybinary = 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.
Problem is ocuring because you don't have geckodriver
Solution:
- Go to this website and download appropriate version for you machine, make sure that you have .exe file inside the archieve.
- Then unpack and copy .exe file to your directory
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.