4

I added geckodriver.exe into PATH as you can see on this image and i restarted my computer after. But the error still show up.

Here's my code :

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://stackoverflow.com')

Do you have clues about what I did wrong ?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Hobsido
  • 41
  • 1
  • 2
  • 1
    Would you mind posting the error? – cjonesrun Jun 19 '17 at 12:50
  • Possible duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – Andersson Jun 19 '17 at 12:54
  • In windows, Create Enviroment variable "webdriver.gecko.driver" and set the driver path("c:\geckodriver.exe") as value. – Murthi Jun 19 '17 at 13:14

4 Answers4

1

There are three ways to resolve this error.

  1. Download the gecko driver and keep it in directory where your python test script is there.
  2. Set the environment variable "webdriver.gecko.driver" with driver path as value. os.environ["webdriver.gecko.driver"]="c:\geckodriver.exe"

  3. Pass executable path to the constructor like driver = WebDriver.Firefox("path of executable")

Murthi
  • 5,299
  • 1
  • 10
  • 15
1

I don't see any significant error in your code block. While working with Selenium 3.4.3, geckodriver v0.17.0, Mozilla Firefox 53.0 with Python 3.6.1 you can consider downloading the geckodriver and save it anywhere in your machine and configuring the absolute path of the geckodriver through executable_path.

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

Here is your own code block which executes well at my end:

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

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get('https://stackoverflow.com')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Are you setting the capabilities correctly? In case you are setting the version capability, verify that it is correct or remove it altogether. I am talking of the below:

capabilities.SetCapability("version", "50.0");
rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
Kiran
  • 21
  • 5
0

In Windows 10 it can be solved after replacing Firefox driver with chrome driver. driver = webdriver.Chrome()

Download Visual Studio 2015, 2017 and 2019 https://aka.ms/vs/16/release/vc_redist.x86.exe OR https://aka.ms/vs/16/release/vc_redist.x64.exe and install based on your Operating system.

Download Chrome Driver from https://chromedriver.storage.googleapis.com/index.html?path=79.0.3945.36/ based on your operating system.

Add chrome drivers in your PATH

sayah imad
  • 1,507
  • 3
  • 16
  • 24