3

I have checked YouTube & Google for solutions to this error. But I have not been able to get one.

Please, I get this error when I write some code to launch the Firefox driver:

An unhandled exception of type 'OpenQA.Selenium.DriverServiceNotFoundException' occurred in WebDriver.dll

Additional information: 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.

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Threading.Tasks;


namespace FireFox_Driver_Launch
{
    class Program
    {
        static void Main(string[] args)
        {

            var Driver = new FirefoxDriver();
            Driver.Navigate().GoToUrl("http://www.starwoodhotels.com/preferredguest/account/enroll/index.html");

        }
    }
}

I have added the selenium webdriver package from "Manager Nuget Packages" as well.

I have searched this site & Google for a solution. But, I have not gotten a solution yet.

The firefox browser is installed on the PC.

I have downloaded the geckodriver. Please, how do I put it in the PATH?

I believe it should be in the System Environment variables ?

I have also installed Selenium.Firefox.Webdriver.

In addition, I downloaded the gecko driver & put it in the project folder. Still getting an error.

3 Answers 3

3

Make sure that the folder where geckodriver.exe (the one you downloaded) is located is on your systems PATH. Here's a tutorial about how to add a folder to PATH: http://www.computerhope.com/issues/ch000549.htm

0
0

Download selenium support drivers via nuget too. If it didnt work go to http://sqaplus.blogspot.be/2017/01/error-message-on-selenium-3-with-firefox.html?m=1 and see how to initialize firefox driver with selenium 2

0
0

First Update your Firefox Browser to the latest version.

Second you need need to download the geckodriver.exe from the below url as per your system configuration.

https://github.com/mozilla/geckodriver/releases

Third write the below code to start the Firefox Browser.

//Give the path of the geckodriver.exe    
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Users\abcd\Downloads\geckodriver-v0.13.0-win64","geckodriver.exe")

//Give the path of the Firefox Browser        
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

IWebDriver driver = new FirefoxDriver(service);

driver.Navigate().GoToUrl("https://www.google.com");

Note: Assumption you are running selenium 3.0.1

1
  • Many Thanks.. I am using Selenium 2.0. But it is working now.. Many Thanks..... Much Appreciated...
    – OA345
    Jan 22, 2017 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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