Firefox Profiling in Selenium

In the previous post, we have learnt few useful operations on Excel File using POI API. In this post, we will see the importance of Firefox Profiling in Selenium.

When we start Fire fox browser using Selenium, it opens a fresh instance of browser. If you have some customized setting in browser like book marks, plugin, Firebug ,Fire path etc. It will not be loaded with the opened browser instance in selenium. That’s a good point, it will speed up the browser slightly.

But sometimes, there might be requirements you would like to customize your browser that should open during execution.

  • You might want your browser to handle some SSL certification error, so you don’t need to add the separate code for handling it.
  • You may add some required site in trustworthy sites of the browser.
  • You may add preferred privacy options.
  • You may add preferred security options.

All of this is possible by creating your customized Firefox Profiling.

In short, Profile in Firefox is a collection of bookmarks, browser settings, extensions, passwords, and history customized by you to have a personal browser. This may help to to make automation reliable and smooth in terms of browser handling.

Color change in excel POI

It is suggested not load the unnecessary settings or plug-in to your Firefox Profile i.e. It is better to keep it light weight. Because when ever Selenium start a new instance of Firefox, before that It will store the whole Firefox in some temporary folder. If profile is big, It might make it slow and unreliable as well.

Color change in excel POI

 You should same featured Firefox profile on each execution and development machine i.e. Profile should be consitent in terms of all browser settings, plug-ins, SSL certificate etc. Other wise, during execution test cases may behave differently.

Where to find the profile folder in System? 

Find below the path of the folders where the firefox profile is residing for different operating systems.

Operating Systems Firefox Profile Folder path
Window XP/2000/Windows 7 , 8 %AppData%\Local\Mozilla\Firefox\Profiles\xxxxxxxx.default
Linux ~/.mozilla/firefox/xxxxxxxx.default
Mac OS X ~/Library/Application Support/Firefox/Profiles/xxxxxxxx.default

Note: The String ‘xxxxxxxx’  is nothing but the name of Profile, which is made up of 8 random character and numbers. It is assigned by Firefox itself. There is already one default profile present in the profile folder.

default Firefox Profile1


How to create Firefox Profile?

Note: Make sure before creating Firefox profile, all firefox browser windows should be closed.

Step#1 Open a Run command window by pressing  “windows Key + R”  Windows key. It will open a window as shown below.

Run command window Firefox profile

Step#2  Type “firefox.exe -p” in the Edit box of the run window and click OK. It will open a Firefox Profile manager window. Which have few buttons to create profile, rename profile, delete profile, Exit etc. (as shown below).

Firefox Prfile Manager

Step#3 You can see a default profile already present which we have seen in the profile folder as well above. Now, Click on button“Create Profile” and follow the steps as screen shots given below.

Click Next in firefox profile


Step#4 Provide the desired profile name (We have given “Selenium_User”) and you have the option to choose folder location to keep your profile. Click Finish.

Choose Firefox Profile Name


Step#5 After Clicking Finish, It will show your profile Create in the Firefox Profile manager.

Firefox Profile created

Step#6 To customize the browser settings according to your need, Click “Start Firefox” button.It will open Firefox browser instance.

For demo purpose, we are bookmarking “Gmail” and “Yahoo”. So, next time when we open out Firefox Profile through Selenium. Both the bookmarks should be available.

Bookmark saved for Firefox Profile

Step#7 After Customizing setting, Close the browser. It is suggested not to directly close the browser, Instead Go to File –> Exit.

File Exit Browser

How to use your Firefox Profile in Selenium?

Create a class and use the below code to open you Firefox Profile. In the code first we are loading Firefox profile using method “getProfile” and that profile is passed to FirefoxDriver instance.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class FireFoxProfileExample {

	public static void main(String[] args) {
		ProfilesIni Prof = new ProfilesIni();
		//Provide your profile name
		FirefoxProfile profile = Prof.getProfile("Selenium_User");
		//Open Firefoxdriver that will open your Firefox Profile
		WebDriver driver = new FirefoxDriver(profile);		



Output: As an output, you will be able to see the bookmark which were saved with the profile.

Bookmark saved Firefox Profile

Ask Question
Have any question or suggestion for us?Please feel free to post in   Q&A Forum


Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...