Selenium Webdriver: Specify filepath for Firefox exe
18,075
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);
Author by
stats101
Updated on July 20, 2022Comments
-
stats101 almost 2 years
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.
-
sara over 8 yearsThis doesn't build for me, there is no ctor in FirefoxDriver that takes a FirefoxBinary argument. Also, your string is incorrectly quoted.
-
Mister Q about 7 yearsA little update about this answer, using the ctor FirefoxDriver(FirefoxBinary firefoxBinary, FirefoxProfile firefoxProfile) is obsolete. Instead use FirefoxOptions to setup the driver and pass the object to the ctor FirefoxDriver
ffOptions = new FirefoxOptions(); ffOptions.BrowserExecutableLocation = @"C:\Firefox\App\Firefox\firefox.exe"; driver = new FirefoxDriver(ffOptions);