3

I'm trying to use Selenium in Python 2.7 and I get the following error,

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

Any idea what could it be?

2 Answers 2

4

You can avoid this issue in two different ways:

  1. Explicit where to find firefox binary to your selenium code:

    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    from selenium import webdriver
    firefox_binary = FirefoxBinary('/usr/bin/firefox/')
    driver = webdriver.Firefox(firefox_binary=firefox_binary)
    
  2. Add firefox to your PATH environment variabile. Windows, Ubuntu

0

It worked for me without passing the argument in "firefox_binary = FirefoxBinary('/usr/bin/firefox/')"

The working code for me is -

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium import webdriver firefox_binary = FirefoxBinary() driver = webdriver.Firefox(firefox_binary=firefox_binary)

2
  • This is pretty much a duplicate of the accepted answer, but applies when the default binary location is already correct. This is a different use case from what the question asked. Dec 29, 2022 at 21:53
  • Yeah my default binary location is already correct. But it is not a different use case. It can be a use for many different user. So posted my answer as well coz the accepted answer was not working for me. When I passed 'firefox_binary = FirefoxBinary('/usr/bin/firefox/')' without the arguments, then it worked. Jan 2, 2023 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.