Biswajit Chopdar
Biswajit Chopdar

Reputation: 871

How to use existing Firefox profile in Selenium C#?

I need to use an existing Firefox profile in Selenium using C#. That profile has a configured add-on that i need.

I found some code googling but those were for Java, I tried the following code but it still doesn't work.

FirefoxProfile profile = new FirefoxProfile("C:\\Users\\username\\Desktop\\software\\Files");
driver = new FirefoxDriver();

Upvotes: 11

Views: 14467

Answers (3)

user1088259
user1088259

Reputation: 355

In new versions works this method

1) Go to firefox profile selection option

enter image description here

2) Create profile

enter image description here

FirefoxProfile profile = new FirefoxProfileManager().GetProfile("axixa");
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
IWebDriver firefox = new FirefoxDriver(options);

Upvotes: 7

Biswajit Chopdar
Biswajit Chopdar

Reputation: 871

I found the answer on the official docs of selenium

var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("Selenium");
IWebDriver driver = new FirefoxDriver(profile);

Source: Selenium docs

Upvotes: 9

Sandipan Pramanik
Sandipan Pramanik

Reputation: 348

You have to pass the profile object while instantiating the firefox driver. Like,

driver = new FirefoxDriver(profile);

See here for details.

Upvotes: 5

Related Questions