Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium OpenQA.Selenium.DriverServiceNotFoundException in FireFox

I'm trying to get started writing Selenium tests, and the first very basic test I write fails with the exception OpenQA.Selenium.DriverServiceNotFoundException.

using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace WebDriverDemo
{
        class Program
    {
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Url = "http://www.google.com";

        }
    }
}

The debugger says I need to download geckodriver.exe and set it up on my PATH variable, which I've done, and I still get the same exception. When I do the same thing with a ChromeDriver, it works fine.

Also, according to the MDN, if I'm using Selenium 3.0 or later, it should be enabled by default. I'm using Selenium 3.0.1 on a Windows 10 computer.

like image 500
Martin Boros Avatar asked Sep 04 '25 16:09

Martin Boros


2 Answers

Another option is to install Selenium.Firefox.WebDriver NuGet package which will copy the driver to the bin folder.

Then you can provide path to the current folder to driver ctor to run your tests:

IWebDriver driver = new FirefoxDriver("./");
like image 104
Andrii Litvinov Avatar answered Sep 07 '25 08:09

Andrii Litvinov


I solved the problem by adding geckodriver.exe to my project and choosing "Copy if newer" for its Copy to Output Directory property.

This allows both regular code and NUnit tests to find the driver. No changes to PATH or SetProperty calls required.

like image 28
MonteChristo Avatar answered Sep 07 '25 08:09

MonteChristo