2

I am trying to run a simple program but getting the following error:

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

Additional information: Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista

Code:

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

namespace selenium
{
    class Program
    {
           static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.reuters.com");
            driver.Manage().Window.Maximize();

            IWebElement searchInput = driver.FindElement(By.XPath("//html/body/div[10]/div[3]/div/td[1]"));
            searchInput.GetAttribute("value").ToString();

            driver.Close();           

        }
    }
}

I checked the environment variables, and I have the following in the path:

PATH=C:\Program Files\Mozilla Firefox\firefox.exe

I am currently running Windows 10, Visual Studio 2015 and selenium Webdriver 2.53.0

user2434600
  • 41
  • 1
  • 4
  • 8
  • 2
    Windows `PATH` is a list of directories, not filenames. Try changing that to `PATH=C:\Program Files\Mozilla Firefox` instead. – dxiv Jul 05 '16 at 05:02
  • Thanks a lot. It worked like a charm – user2434600 Jul 05 '16 at 13:04
  • Possible duplicate of [Cannot find firefox binary in PATH. Make sure firefox is installed](http://stackoverflow.com/questions/20950748/cannot-find-firefox-binary-in-path-make-sure-firefox-is-installed) – JeffC Jul 10 '16 at 17:25

1 Answers1

2

Cannot find firefox binary in PATH. Make sure firefox is installed Solution for C#.

var opt = new FirefoxOptions
{
    BrowserExecutableLocation = @"c:\program files\mozilla firefox\firefox.exe"
};
var driver = new FirefoxDriver(opt);
lebelinoz
  • 4,890
  • 10
  • 33
  • 56
Akhil Singh
  • 700
  • 6
  • 17