3

I cannot find any implementations to get geckodriver to run my tests on FF for my C# solution, so I am reaching out to see what solutions you guys might have.

I have tried these two:

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
                    service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
                    FirefoxDriver driver = new FirefoxDriver(service);

This fails with the message "The type or namespace name 'FirefoxDriverService' could not be found (are you missing a using directive or an assembly reference?)"

System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
                    var _driver = new FirefoxDriver();

This fails the test claiming that it is unable to initialize the firefoxdriver.

FF version #:49.0.2

GeckoDriver version #: 0.11.1

  • 1
    Probably not the best solution but I couldn't get this to work with the latest version of selenium. I rolled back to a previous version of Selenium.Webdriver and Selenium.Support (2.53.1). Now everything works with a simple "var driver = new FirefoxDriver(); " – GKS1 Nov 8 '16 at 17:13
  • That seems to be a solid workaround, but I am still curious if we can use the new development. – DEnumber50 Nov 8 '16 at 17:30
2

I found the solution, by updating to the latest version of Webdriver and Webdriver.support my first method of:

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
                    service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
                    FirefoxDriver driver = new FirefoxDriver(service);

Worked without issue.

|improve this answer|||||
  • Where did you place your geckodriver.exe file? Not specified in above code. – zishan paya Aug 29 '18 at 10:23
  • @zishanpaya I placed it into my C:\ drive in a folder I call selenium, you can see the reference to the location in the question. – DEnumber50 Oct 11 '18 at 17:14
1

I had the same issue. Specifying the geckodriver.exe path when creating the driver service solved the problem for me.

So assuming your geckodriver.exe is located in "C:\Selenium\geckodriver.exe", you could also write:

// Notice the path argument here
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Selenium");
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
FirefoxDriver driver = new FirefoxDriver(service);
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.