Python 3 Selenium KeyError: 'value' Issue won't initialize Geckodriver for Firefox

对着背影说爱祢 提交于 2019-12-04 13:05:16

Updating to geckodriver 0.17.0 fixed the issue for me
Firefox 53.0.3
Selenium 3.4.3
Python 3.6

binary = FirefoxBinary('C:\\Program Files (x86)\\Mozilla Firefox\\Firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary) 
driver.get(url)

Here is the Answer to your Question:

Using Selenium 3.4.x, Python 3.6.1 along with geckodriver v0.16.1 & Mozilla Firefox 53.0, you can configure the following parameters:

  1. firefox_binary: To provide the absolute path of the exact Firefox Binary you intend to use.
  2. firefox_profile: To specify if you want to start with a new/existing Firefox Profile.
  3. executable_path: To specify absolute path of the geckodriver.exe.

It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary as firefox_binary argument while initializing the webdriver

The following code block will open a Firefox Browser as per the configuration we set through the previous mentioned parameters:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
profile = webdriver.FirefoxProfile()
path = "C:\\Utility\\BrowserDrivers\\geckodriver.exe"

browser = webdriver.Firefox(executable_path=path, firefox_profile=profile,firefox_binary=binary)
browser.get("http://google.com")

Let me know if this Answers your Question.

I also met this problem when I tried to run the code at home with geckodriver in Pycharm. I added the geckodriver folder to System Environment Path. And then I updated Pycharm as well as the Selenium version and then it just fixed the problem. I could run the code from CMD before updating my Selenium version. After updating the Selenium version in Pycharm. It's working again. It's weird.

I aslo tried to add the geckodriver path before but it didn't fix the problem.

driverPath = 'C:\\Users\\xxx\\OneDrive\\xxx\\geckodriver.exe'
driver = webdriver.Firefox(firefox_profile=profile, executable_path=driverPath)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!