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?
Answers:
You can avoid this issue in two different ways:
-
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)
-
Add firefox to your PATH environment variabile. Windows, Ubuntu
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)
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?
You can avoid this issue in two different ways:
-
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)
-
Add firefox to your PATH environment variabile. Windows, Ubuntu
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)