WebDriverException: Message: Expected browser binary location, but unable to find binary in default location

Question:

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?

Asked By: Pablo

||

Answers:

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

Answered By: Veenz

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)

Answered By: Anand Singh
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.