When I tried to use FireFox with Selenium WebDriver (Python binding), I got the following error.
python
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
...
FileNotFoundError: [Errno 2] No such file or directory: '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
If you call webdriver.Firefox
with no arguments, the default path for each environment will be used. (/Applications/Firefox.app/Contents/MacOS/firefox-bin
for Mac)
(ref) https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/firefox/firefox_binary.py#L143
In my environment, I have installed FireFox via Homebrew-Cask, and the path in that case is ~ / Applications / Firefox.app/Contents/MacOS/firefox-bin
. In order to tell WebDriver this path, you need to give a FireFoxBinary
instance as follows.
python
>>> bin = webdriver.firefox.webdriver.FirefoxBinary('/Users/FGtatsuro/Applications/Firefox.app/Contents/MacOS/firefox')
>>> driver = webdriver.Firefox(firefox_binary=bin)
Recommended Posts