1

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 ?

Thank you for your help.

OA345
  • 181
  • 2
  • 3
  • 10

4 Answers4

1

You need to install the GeckoDriver as is stated in the error message. The easiest way to do that is to add the Selenium.Firefox.WebDriver nuget package as well as the Selenium.WebDriver that you already have installed.

John Koerner
  • 37,428
  • 8
  • 84
  • 134
  • Many Thanks for that! I downloaded the package: Selenium.Firefox.WebDriver However, I got this error message: An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:60744/session timed out after 60 seconds. – OA345 Jan 21 '17 at 17:49
  • It may be a bug - acoording to this post: http://stackoverflow.com/questions/22322596/selenium-error-the-http-request-to-the-remote-webdriver-timed-out-after-60-sec But, I get another error. Thank you very much. I tried launching the driver with this code: new FirefoxDriver(new FirefoxBinary(),new FirefoxProfile(),TimeSpan.FromSeconds(180)); – OA345 Jan 21 '17 at 17:59
1

Incase anyone is useing geckodriver, then you would need to set the path for geckodriver this can be absolute path or you can specify the path of geckodriver.exe with respect to project as well.

    System.setProperty("webdriver.gecko.driver", "./myGeckodriverPathFolder/geckodriver.exe");
    File pathToBinary = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
    FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
    FirefoxProfile firefoxProfile = new FirefoxProfile();       
    
    WebDriver driver = new FirefoxDriver(ffBinary, firefoxProfile);

The geckdriver path if used as absolute path then "C:\\myGeckodriverPathFolder\\geckodriver.exe"

Uncle Sam
  • 33
  • 3
0

I had faced the same issue but it is solved by installing Selenium.Firefox.WebDriver in Nuget package manager.

Nandini
  • 31
  • 2
0

Install the Selenium.Firefox.Webdriver from NuGet package manager, and then rebuild the solution, it will work.