Geckodriver NOT recognized despite being in System PATH

3k Views Asked by At

Summary: Geckodriver seemingly isn't recognized despite that it is accurately set in the SYSTEM PATH

Current System Configuration:

  • Operating System: Windows 10; Version: 1909; OS build: 18363.752; System type: 64-bit OS Windows System Info

  • Installed Microsoft Visual Studio redistributable runtime: vc_redist.x64.exe

  • User Environment Variable value: "C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\;%IntelliJ IDEA Community Edition%;C:\Program Files\Java\jdk-13.0.1\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Development\Selenium Resources\Selenium Drivers\geckodriver.exe;C:\Development\Selenium Resources\Selenium Drivers\chromedriver.exe;C:\Development\Selenium Resources\Selenium Drivers\;C:\Development\Selenium Resources\Selenium Drivers;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;"

  • System Environment Variable value: "%path%;C:\Development\Selenium Resources\Selenium Drivers;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Ruby26-x64\bin;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\Java\jre1.8.0_221\bin\javaw.exe;C:\Program Files\Java\jdk-12.0.2\bin;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\Scripts;C:\Development\Selenium Resources\Selenium Drivers\;C:\Development\Selenium Resources\Selenium Drivers\chromedriver.exe;C:\Development\Selenium Resources\Selenium Drivers\geckodriver.exe;"

  • Directory where Selenium Driver's are saved: C:\Development\Selenium Resources\Selenium Drivers Selenium Drivers Directory

  • Firefox Browser Version Installed: 74.0 (64-bit)

  • Geckodriver version installed: geckodriver-v0.26.0-win64.zip from here: https://github.com/mozilla/geckodriver/releases

  • Github Project (up-to-date): https://github.com/cikent/Selenium-Projects/tree/master/Selenium-PythonProjects/python-webui-testing

Objective/Goal: Resolve Geckodriver not being detected so I can continue setting up an Automation Framework in Python utilizing Selenium and Pytest by referencing the following Guide from Automation Panda: https://blog.testproject.io/2019/07/16/read-config-files-in-python-selenium/

What have I already tried?:

  • Restart System after each update to Environment Variables
  • Launching geckodriver from the Powershell Terminal, run: geckodriver
  • Ensured that had Microsoft Visual Studio redistributable installed to account for the following error called out here for Windows v0.26.0 (as mentioned above):
  • Verified that my Github project executes just fine with the following command: pipenv run python -m pytest when my configuration file config.json has the browser parameter set to: chrome
  • Hour's of searching on Google, Stackoverflow, Reddit and beyond trying to troubleshoot why this isn't working... :(

Actual Result: When I execute: pipenv run python -m pytest from the following directory: C:\Development\Selenium-Projects\Selenium-PythonProjects\python-webui-testing, I get: PowerShell Execution of Pytest & Output

2

There are 2 best solutions below

0
On

I would recommend using the webdriver_manager, so that you don't have to deal with all these issues. It's pretty simple as shown below. And the webdriver_manager will get th latest stable driver based on the Operating system and the architecure.

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get("https://www.google.com")
# continue using the driver as usual.
1
On

The problem is not about geckodriver’s path. The problem is that “Firefox” cannot be found as a token in the Python code.

Add this import to the module with the config fixture: “from selenium.webdriver import Firefox”.