I need help to launch Firefox browser with Selenium C# code | Selenium Forum
M
Posted on 11/10/2016
Hi All,

I am facing below error message when trying to launch firefox browser through selenium c# code.

An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll

Below is the code which I have tried:

System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", @"C:\geck\geckodriver.exe");
//FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\seleniumjars3", "geckodriver.exe");
//service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://google.com";

Can anybody help to resolve this issue ASAP.

Thanks,
Venkat.

M
Replied on 13/10/2016

Please find the below code to open the Firefox browser in the latest
Selenium 3.0 version -

FirefoxDriverService service =
FirefoxDriverService.CreateDefaultService(@"G:\softwares\geckodriver-v0.10.0-win64",
"geckodriver.exe");

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

driver.Url = "http://google.com";


And then also set the path of geckodriver.exe file in the environment
variable.