I am getting an error when trying to open Firefox using Selenium in ipython notebook. I\'ve looked around and have found similar errors but nothing that exactly matches the
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.
Problem is ocuring because you don't have geckodriver
Solution:
Requirements:
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.
those 2 packages are needed (ubuntu)!
apt-get update
apt-get install -y xorg xvfb firefox dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic
sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev
sudo apt install linuxbrew-wrapper
brew install geckodriver
also what working for me is to use chrome instead of firefox check this tutorial: https://christopher.su/2015/selenium-chromedriver-ubuntu/
I got the same error when I set environment variable export PYTHONDONTWRITEBYTECODE=1
to get rid of pyc files on every test run. I was able to revert the change by updating selenium pip install --upgrade selenium
. OSX (10.10)
This is what worked:
apt-get update
apt-get install -y xorg xvfb firefox dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic