Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 590
stats101 Avatar asked Feb 28 '12 00:02

stats101


1 Answers

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);
like image 167
AutomatedTester Avatar answered Oct 05 '22 23:10

AutomatedTester