Search code examples
c#seleniumfirefoxwebdrivergeckodriver

Geckodriver with selenium 3.0 throws DriverServiceNotFoundException


I need help to upgrade to geckodriver using C#. I downloaded geckodriver from here. Downloaded windows 64bit version as I'm on windows 10 64bit. Copied the driver to my project location.

Environment.SetEnvironmentVariable("webdriver.gecko.driver", @"C:\Git\AutomationTest\Drivers\geckodriver.exe");
FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;
driver = new FirefoxDriver(driverService, new FirefoxOptions(), TimeSpan.FromMilliseconds(600));

It threw error:

Initialization method UnitTestProject1.UnitTest1.Init threw exception. OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException: The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at https://github.com/mozilla/geckodriver/releases..
Result StackTrace:  
at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
at OpenQA.Selenium.Firefox.FirefoxDriverService.CreateDefaultService()
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor()
at UnitTestProject1.UnitTest1.Init()

Tried renaming it to 'Wires' but didn't work. Searched so many questions on SO, didn't find a solution with Selenium 3.0.

Added the path of the folder that has the driver to System variables path and tried using DesiredCapabilities.

DesiredCapabilities cap = DesiredCapabilities.Firefox();
cap.SetCapability("marionette", true);
var driver = new RemoteWebDriver(cap);

Using Selenium 3.0, FF 47.0.1, gecko v0.11.1 Can someone help me with this issue.

Thanks.


Solution

  • I updated Firefox to Version 49.0.2 and updated my selenium driver to 3.0.0 from nuget packages. Added Firefox path to the system path variables. That's it I didn't change anything else in my coding i.e, declaration of Firefox. After updating I'm having too many issues like wait and System.Net.Web exception. I need to fix some of my test cases but it works.