All IT Courses 50% Off
Selenium Tutorials

Creation of Firefox Profile in Selenium WebDriver

What is Firefox Profile?

A Firefox profile is a user personalized setting that consists of the user’s bookmarks, plugins, extensions, and saved passwords that can be done on the Firefox Browser. When Firefox is installed, it creates a profile folder by default in your local drive that saves information like passwords, bookmarks, etc. You can have many Firefox profile, each profile contains a separate set of user information.  Let’s, for example, you and your friend are using the same computer and both of them want to see their own kind of Firefox settings when they log in, then both users can create and access their own  Firefox profile whenever they open Firefox browser.

Whenever the Firefox browser is launched with Selenium WebDriver, it opens a blank Firefox browser without bookmarks, extensions, plug-ins, etc. Sometimes we required these plug-ins bookmarks, extensions, etc. while executing the selenium test case.

What is the purpose of creating a custom Firefox profile?

  • In the Firefox profile to make the test execution more reliable we need some special settings in the Firefox profile. A common example is handling SSL certificate settings. During test execution to handle these requirements, we need to create a custom profile and to make test execution more reliable.
  • Whenever we use different profiles every time, the SSL certificates you accepted or the installed plug-ins would be different and would make the tests behave differently on the machines.
  • Always make sure that the profile which you have created is lightweight that includes only plug-ins, bookmarks, extensions, settings that are required for test execution. Every time for Firefox instance a new session is created whenever selenium starts it will copy the entire profile in some temporary directory and if the profile is big, it makes it slow and unreliable.

Finding Your Profile Folder

Based on the operating system you use your profile folder’s location depends. The location of the profile is as follows:

Operating SystemProfile Folder Path
Windows XP / 2000 / Vista / 7 / 10%AppData%MozillaFirefoxProfiles_name.default
Mac OS X~/Library/Application Support/Firefox/Profiles/profilename.default/

Creating a New Firefox Profile

There are three steps to create New Firefox profiles and use the same in the test script. First 

  • First we need to start the Profile Manager, 
  • Creating a New Custom Profile and 
  • Using the same profile in Test scripts.

Step 1: Starting the Profile Manager

  1. First close Firefox if it is open. Click on the File menu at the top of the Firefox window, and click Exit.
  2. Press ‘Windows Key + R’, and type firefox – p, and click the OK button.
Creation of Firefox Profile in Selenium WebDriver

Note: After clicking on the ‘OK’ button and if the Profile Manager window does not seem, it may be opened in the background that needs to be closed properly, you can use the Ctrl+Alt+Del program to kill it. If it still does not open then you can try using the full path, enclosed in quotes. 

For example:

  • “C: Program FilesMozilla Firefox.exe” –p: On 32 bit- Windows
  • Windows: “C: Program Files(x86)Mozilla Firefox.exe” –p: On 64 bit
  1. A dialogue box choose user profile window will look like
Creation of Firefox Profile in Selenium WebDriver

Step 2: Creating a Profile

  1. Click on the ‘Create Profile’ button and Choose User Profile’ window.
Creation of Firefox Profile in Selenium WebDriver
  1. Click on the ‘Next’ button in the ‘Create Profile Wizard’ window.
Creation of Firefox Profile in Selenium WebDriver
  1. Type a new name ‘profileTestQA’ in the ‘Enter new profile name’ box and click on the ‘Finish’ button. 
Creation of Firefox Profile in Selenium WebDriver
  1. A newly created profile is displayed in the ‘Choose User Profile’ window.
Creation of Firefox Profile in Selenium WebDriver
  1. Click on the ‘Start Firefox’ button. Firefox will start with the new profile.
Creation of Firefox Profile in Selenium WebDriver

Note: Once you click the Start Firefox button you will notice that the new Firefox window will not show any of your Bookmarks and Favourite icons.

Note: The last selected profile will start loading automatically when you next start Firefox and you will need to restart the Profile Manager again to change profiles.

Step 3: Using the Custom Profile in Selenium Test Script

Once the Profile is created, it needs to be called in the test scripts. To Instantiate the Firefox Driver you need to add the below code to your Test scripts.

ProfilesIni profile = new ProfilesIni();

// creating an object for the Firefox profile

FirefoxProfile myprofile = profile.getProfile(“profileTestQA”);

// initializing the Firefox driver

WebDriver driver = new FirefoxDriver(myprofile);

Let see the below examples for implementation of this code.

package Profile;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class FirefoxProfiles {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Selenium\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile fireFoxProfile = profile.getProfile("abcProfile");
FirefoxOptions opt = new FirefoxOptions();
opt.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);
WebDriver driver = new FirefoxDriver(opt);

//Set the timeout  for 5 seconds for the page to load within that time
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);




  • A Firefox profile is a user personalized setting that consists of the user’s bookmarks, plugins, extensions, and saved passwords that can be done on the Firefox Browser.
  • Firefox profile should be such that it must easy to load and should have some user-specific proxy settings to run the test.
  • We need to use web drivers inbuilt class ‘profilesIni’ and its method getProfile in Selenium Webdriver to use the newly created Firefox profile.
Facebook Comments

Related Articles

Back to top button

Get Selenium Training Online
Course Now at 50%OFF!

Offer valid for 1st 20 seats only, Hurry up!!

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

H2kinfosys will use this information to be in touch with you for providing updates.