Create Firefox Profile in Selenium

Firefox keeps user’s information such as bookmarks, passwords and user preferences in a set of files called “Firefox profile“. These profiles are stored in a separate location from the Firefox program files.

 

You can have multiple Firefox profiles, each containing a separate set of user information. The Profile Manager allows you to create, remove, rename, and switch profiles.

In Firefox you can create multiple profiles and selenium provides the functionality to execute the test cases in desired profile.

 

Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

Need of Firefox Profile

The default Firefox working profile is not very automation friendly. Automation profile should be light to load and have the special proxy and other settings to run the test.

  • Many times you need some special settings in your profile to make test execution reliable. The most common example is an SSL certificate settings or browser plug-ins that handle self-signed certs. It makes a lot of sense to create a profile that handles these special test needs and packaging and deploying it along with the test execution code.
  • In Automation, you should use the lightweight profile with just the settings and plug-ins you need for the execution. Each time Selenium starts a new session driving a Firefox instance, it copies the entire profile in some temporary directory and if the profile is big, it makes it, not only slow and unreliable.

 

Create New Firefox Profile

We can create the Firefox profile using Firefox profile manager. There are finite steps to create the Firefox profile –

1. Close the Firefox application.

2. Now we need to open Profile Manager to create the Firefox profile-

  • If you are working on windows press “window + R” and type “firefox.exe -P” and press OK.
  • If you are using Linux, Open terminal and run command “locate firefox” and then execute “./firefox -profilemanager

Create Firefox Profile

 

3. Now click on “Create Profile” button.

4. Now click “Next”.

5. Now enter your profile Name.

Create Firefox Profile

 

6. Now click “Finish”.

Create Firefox profile

 

7. You have created your New Firefox profile with name SeleniumBix. Now click on Start Firefox to open the firefox in a new profile.

 

You noticed, Now Firefox launched in a new profile. Firefox is not showing any bookmark and browser plug-in here.

 

Now you need to run your selenium code in this profile. Let’s see an example where we are opening the SeleniumBix in new firefox profile.

To run Selenium with custom profile we need to perform following steps-

  • First, we need to instantiate the inbuilt class in selenium “ProfilesIni“.
  • Load your custom profile with the help of getProfile() method. We actually are creating the clone of the custom profile.
  • Now assign this custom profile to your webdriver instance.

In the above example, we are opening the Easybix.com in our new custom profile.

 

So this is all about Firefox profile and how we can use Firefox profile with selenium.

0 Comment

Leave a Reply