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);
Share:
18,075
stats101
Author by

stats101

Updated on July 20, 2022

Comments

  • stats101
    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
    sara over 8 years
    This doesn't build for me, there is no ctor in FirefoxDriver that takes a FirefoxBinary argument. Also, your string is incorrectly quoted.
  • Mister Q
    Mister Q about 7 years
    A 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);