How to create a Firefox profile for selenium testing

What is a profile?

Profile is a collection of file which Firefox saves your personal information like bookmarks, passwords and other user preferences. These are stored in a separate location from actual Firefox program files. You can have one or more Firefox profiles, each containing a separate set of user information.

Why we need a profile in selenium?

profiles are easy to load and very automation friendly. It contains special proxy and several other settings to run a good test.

Create a profile in Linux

  1. Go to your console
  2. Execute the following command “firefox --new-instance --ProfileManager”.

You can see the following profile manager window.

profile manager

3. Click on the create profile option in the profile manager to start create profiles.

4. Read the instructions and click next .

5. Enter a profile name and a location to store your new profile.

create window of profile manager

6. Click finish.

Now you have created the profile. Let’s move on how we can use this profile in selenium

How to use the created profile inside selenium web driver code

ProfilesIni profile = new ProfilesIni();
FirefoxProfile profile1 = profile.getProfile("Guru99");// profile name is Guru99
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile1);
FirefoxOptions opt = new FirefoxOptions();
opt.merge(dc);
WebDriver driver=new FirefoxDriver(opt);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store