Running webdriver with Firefox Python

I am writing a program that will search for a website for specific entries within articles, I use selenium webdriver for Python.

When I try to connect to the site, I get this exception:

Traceback (most 
recent call last):
  File "search.py", line 26, in <module>
    test.search_for_keywords()
  File "search.py", line 13, in search_for_keywords
    browser = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 65, in __init__
    self.service.start()
  File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\common\service.py", line 86, in start
    self.assert_process_still_running()
  File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\common\service.py", line 99, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 2

They say that webdriver came out unexpectedly. How can I fix this problem? I am trying to connect to firefox version 48.0 using python version 2.7.12

+4
source share
2 answers

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

"Marionette" "Gecko Driver" - firefox. Firefox 47+ , Selenium 2.53, Selenium 3+ "Marionette" "Gecko Driver" ( ).

:

• Mozilla firefox: 50.0.2 ( 47 )

• Selenium: 3.0.2

• Geckodriver: 0.11.1

• Python: 2.7.3

:

• : pip install –U selenium

• Geckodriver: geckodriver https://github.com/mozilla/geckodriver/releases,

• "" geckodriver

script:

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

# Firefox

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

caps = DesiredCapabilities.FIREFOX.copy()

#Set ' True

caps['marionette'] = True

# Firefox, geckodriver

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

...!

+4

, egg, selenium, .

+1

Source: https://habr.com/ru/post/1653558/


All Articles