Selenium Firefox webdriver results in error: Service geckodriver unexpectedly exited. Status code was: 2

后端 未结 3 692
名媛妹妹
名媛妹妹 2020-12-21 02:17

I\'m writing a program that will search a website for specific entries inside of articles, I\'m using selenium webdriver for Python.

While attempting to connect to t

相关标签:
3条回答
  • 2020-12-21 03:03

    I had this problem on MacOS Big Sur and it's a security issue. To resolve it, go to your system preferences -> Security & Privacy and at the bottom it will complain about geckodriver. You need to click "Allow Anyway."

    0 讨论(0)
  • 2020-12-21 03:16

    I fixed this, I deleted the egg that was installed and reinstalled selenium, it works perfectly now.

    0 讨论(0)
  • 2020-12-21 03:19

    Running python selenium tests in latest Firefox browser (Version 47 above)

    “Marionette" or "Gecko Driver” is the future version of firefox driver. Firefox 47+ is not compatible with the driver used in Selenium 2.53, and Selenium 3+ will be using a new driver called "Marionette" or "Gecko Driver" (which isn't officially released yet).

    Prerequisites:

    • Mozilla firefox : Version 50.0.2(Version 47 above)

    • Selenium : Version 3.0.2

    • Geckodriver : Version 0.11.1

    • Python : Version 2.7.3

    Setup:

    • Selenium : pip install –U selenium

    • Geckodriver : Download the geckodriver from https://github.com/mozilla/geckodriver/releases , unzip the file and place it in a folder

    • Set the ‘Path’ environment variable with geckodriver path

    Sample script:

    from selenium import webdriver
    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    

    #Provide the Firefox binary path

    binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe’)
    
    caps = DesiredCapabilities.FIREFOX.copy()
    

    #Set ‘marionette’ browser to True

    caps['marionette'] = True
    

    #Launch the Firefox instance by specifying the geckodriver executable path

    driver = webdriver.Firefox(firefox_binary=binary,capabilities=caps, executable_path`='D:/Installers/geckodriver-v0.11.1-win64/geckodriver')
    

    You are done ...!

    0 讨论(0)
提交回复
热议问题