Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();
like image 301
Biswajit Chopdar Avatar asked Oct 01 '16 17:10

Biswajit Chopdar


People also ask

What is the use of Firefox profile in Selenium WebDriver?

Firefox profiles include custom preferences that you would like to simulate an environment for your test script. For example, you might want to create a profile that sets preferences to handle the download popup programmatically during your test run.

Can you use Selenium with Firefox?

Selenium IDE by Selenium Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests.

Which version of Selenium is compatible with Firefox?

FireFox was fully supported only in previous versions i.e. v47 and earlier. Selenium WebDriver version 2.53 is not compatible with Mozilla FireFox version 47.0+. After v47. 0, FireFox is provided with GeckoDriver.


2 Answers

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);
like image 53
user1088259 Avatar answered Sep 19 '22 08:09

user1088259


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

like image 42
Biswajit Chopdar Avatar answered Sep 22 '22 08:09

Biswajit Chopdar