Python selenium 3.0 - Firefox 47.0.1 installed by default is undefined (Geckodriver)

The following is my environment:

  • OS: Windows 10 - 64 (Home version)
  • Browser: Firefox 47.0.1 (32 bit)
  • Python: 2.7.10.12 (64 bit)
  • selenium: 3.0.1
  • Geckodriver: geckodriver-v0.11.1-win64.zip

Firefox installed in C:\Program Files (x86)\Mozilla Firefox.

geckodriver.exe is in C:\Python27\Scriptsplace.

The following is my python code:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("http://www.python.org")

Which gives the following error:

Traceback (most recent call last):
  File "examples1.py", line 5, in <module>
    driver = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__
    keep_alive=True)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

My question is that although firefox is installed in the default folder, webdriver could not find it and gives an error.

Note: when I explicitly specify the Firefox binary location as follows, it works.

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
+4
source share
2

, Python FirefoxBinary.

. , :

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

, ().

0

. ( , geckodriver.exe PATH.

, , , .


geckodriver.exe Firefox:

geckodriver github:

Firefox 47 is explicitly not supported

, Firefox 47.0.1, Firefox driver, geckodriver.

  • 2.53 - ( geckodriver, selenium 2.53 Firefox driver default).
  • Selenium 3.0 geckodriver ( geckodriver - default Firefox Selenium 3.0) System.setProperty marionette false, geckodriver Firefox .

:

System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
DesiredCapabilities d = new DesiredCapabilities();
d.setCapability("marionette", false);  // to disable marionette, by default true
WebDriver driver = new FirefoxDriver(d);

:

0

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


All Articles