Search code examples
c#seleniumfirefoxgeckodriver

Set custom profile directory for Firefox (Geckodriver)


I have some profiles I would like to use in Firefox. I've tried to set a custom folder for the profiles but Firefox can't load the profile. My code right now:

FirefoxOptions options = new FirefoxOptions();
options.AddArguments(@"user-data-dir=C:\SomeFolder\firefox" + @"\" + profilename + @"\");
IWebDriver driver = new FirefoxDriver(options);

Solution

  • You'll need to utilise set the Profile property on the options class, e.g.

    options.Profile = new FirefoxProfile("PATH_TO_PROFILE");
    

    Sadly there seems to be an existing issue with this that many people have run in to. Luckily there is a brilliant answer to actually getting this to work, link is below. I would suggest following the answer to get your custom profile loaded.

    Starting a specific Firefox Profile with Selenium 3