Search code examples
seleniumgeckodriverselenium-firefoxdriver

Add geckodriver to PATH on Windows 11


To complete a project using Selenium, I first need to add Geckodriver to PATH. I have read many articles about adding elements to PATH, but none of them end up working (I follow the steps and add a new element to PATH, but when I run my program I get the 'geckodriver' executable needs to be in PATH error.

1: I first download this version of Geckodriver from here: https://github.com/mozilla/geckodriver/releases

2: I extract the folder and add it to the PATH

3: When I run my program, I get the same error Message: 'geckodriver' executable needs to be in PATH.

Any help would be appreciated!


Solution

  • You do need to add an environment variable for the firefox driver. String exePath = ".\\lib\\geckodriver.exe"; System.setProperty("webdriver.gecko.driver", exePath); driver = new FirefoxDriver();