stats101
stats101

Reputation: 1877

Selenium Webdriver: Specify filepath for Firefox exe

Can someone advise me on how to set the path for the firefox exe file in Selenium (C#).

I'm using the following code presently, however it is not working as hoped:

 FirefoxProfile profile = new FirefoxProfile();

 profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");

 IWebDriver driver = new FirefoxDriver(profile);

Any suggestions would be appreciated.

Upvotes: 10

Views: 18723

Answers (2)

AutomatedTester
AutomatedTester

Reputation: 22438

You should use FirefoxBinary instead of FirefoxProfile as below

FirefoxBinary binary = new FirefoxBinary(new File("path/to/binary"));

FirefoxOptions options = new FirefoxOptions();
options.setBinary(binary);

IWebDriver driver = new FirefoxDriver(options);

Upvotes: 7

obesechicken13
obesechicken13

Reputation: 833

Another option is to configure the system property.

System.Environment.SetEnvironmentVariable("webdriver.firefox.bin", 'path/to/binary');

Upvotes: 0

Related Questions