Python selenium error when trying to launch firefox

前端 未结 8 1313
时光取名叫无心
时光取名叫无心 2020-12-01 16:35

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

相关标签:
8条回答
  • 2020-12-01 16:50

    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.

    0 讨论(0)
  • 2020-12-01 16:50

    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
    0 讨论(0)
  • 2020-12-01 16:51

    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.

    0 讨论(0)
  • 2020-12-01 16:53

    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/

    0 讨论(0)
  • 2020-12-01 16:56

    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)

    0 讨论(0)
  • 2020-12-01 17:12

    This is what worked:

    apt-get update
    
    apt-get install -y xorg xvfb firefox dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic
    
    0 讨论(0)
提交回复
热议问题