I'm having trouble running geckodriver with Python 3. I recently switched to Python 3 with an application that I've been working on, and have updated Firefox(53.0), Selenium(3.4.3), and geckodriver(0.17.1). I'm also using OSX and used pip to install all of my packages.
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
# Set Firefox Settings
# binary = FirefoxBinary('Users/username/Applications/Firefox.app/Contents/MacOS/firefox')
# binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox')
# binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox-bin')
path = '/usr/local/bin/geckodriver'
profile = webdriver.FirefoxProfile()
browser = webdriver.Firefox(executable_path=path,
firefox_profile=profile,
firefox_binary=binary)
browser.get("http://google.com")
The web browser will start, but then I will receive the following error:
Traceback (most recent call last):
File "/Users/jphubert/Desktop/AbstractionProject/py/browsertest.py", line 11, in <module>
firefox_profile=profile),
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 155, in __init__
keep_alive=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 183, in start_session
self.capabilities = response['value']
KeyError: 'value'
I have uninstalled and reinstalled Firefox and geckodriver, taking @Viragos advice to ensure I installed the MacOS version. @Debanjan set me on the right track to try and set the Firefox binary and include it in the webdriver profile but I'm still getting the same error.
I've tried taking the Firefox binary from GitHub and putting it in a .py file as well, and have made attempts to remove the profile and executable path, but the same problem persists. My binary files are in the correct location and it works if I follow the path myself and click through their .exe files, but I can't make my script run anymore.
I've been running Selenium without any issues on Python 2.7, and only since yesterday, upgrading gecko and Python, have I been having problems.
Thank you!