Also, Firefox or any other browser handles the SSL certificates settings. So automating them makes a lot of sense along with the test execution code. In short a profile is a user’s personal settings. When you want to run a reliable automation on a Firefox browser, it is recommended to make a separate profile. In this tutorial, you will learn-

Location of your profile folder in the disk How to create a Firefox profile Automation Script for Selenium Firefox Profile Example 1 Firefox Profile Example 2

Location of your profile folder in the disk

Firefox profile is just like different users using Firefox. Firefox saves personal information such as bookmarks, passwords, and user preferences which can be edited, deleted or created using the program manager.

Location of profile is as follows

For windows 7 > /AppData/MozillaFirefoxProfile_name.default For Linux > /.mozilla/firefox/profile_name.default/ For Mac OS X > ~/Library/ApplicationSupport/Firefox/Profiles/profile_name.default/

In order to run a successful Selenium Test, a Firefox profile should be –

Easy to load Proxy settings if required Other user-specific settings based on automation needs

How to create a Firefox profile

Let see step by step how to create a Firefox profile. Step 1) Close the Firefox browser In the first step, First of all close the Firefox if open. Step 2) Open Run (Windows key + R) and type firefox.exe –p

Note: If it doesn’t open you can try using full path enclosed in quotes.

On 32 bit- Windows: “C:Program FilesMozilla Firefox.exe” –p On 64 bit : Windows: “C:Program Files(x86)Mozilla Firefox.exe” –p

Step 3) Choose user profile

Now, dialogue box will open named Firefox Step 4) Create Profile

Now, Select option Create Profile from the window, and a wizard will open. Click on next. Step 5) Give your profile name

Now your profile is ready you can select your profile and open Firefox. You will notice that the new Firefox window will not show any of your Bookmarks and Favorite icons. Note: The last selected profile, will load automatically at next Firefox launch. You will need to restart profile manager if you wish to change profiles.

Automation Script for Selenium

To access newly created Firefox profile in Selenium Webdriver software test, we need to use webdrivers inbuilt class ‘profilesIni’ and it’s method getProfile as shown below. Selenium code for the profile This is a code to implement a profile, which can be embedded in the selenium code. // this will create an object for the Firefox profile // this will Initialize the Firefox driver Let see the implementation of this code in following examples.

Firefox Profile Example 1

EXPLANATION FOR THE CODE: Below is the explanation of code line by line.

Code line 2-7: First of all we need to import the package required to run the selenium code. Code line 8: Make a public class “FirefoxProfile.” Code line 9: Make an object (you need to have basic knowledge of oops concepts). Code line 10-11: We need to initialize Firefox profile with the object of myprofile . Code line 13: Create object for Firefox Code line 15: Maximize window. Code line 17:Driver.get use to navigate to given URL . Code line 19: Set timeout is used to wait for some time so that browser may load the page before proceeding to next page. Code line 21:Close Firefox.

Let’s see one more example.

Firefox Profile Example 2

Explanation for the code: Below is the explanation of code line by line.

Code line 1-6: First of all we need to import the package required to run the selenium code. Code line 8: Make a public class FirefoxProfile 2 . Code line 12: Make the object of myprofile by referring to the exact path . Code line 14: Create object for firefox Code line 16: Maximize window. Code line 18: Driver.get use to navigate to given URL . Code line 20: Set timeout is used to wait for some time so that browser may load the page before proceeding to next page. Code line 22: Close Firefox.

Summary

Automating Firefox profile makes a lot of sense as such they handles SSL certificates settings. Firefox profile can be customized to suit your Selenium automation requirement. Firefox profile should be such that it should be easy to load and have some user-specific proxy settings to run a good test. To access newly created Firefox profile in Selenium Webdriver software test, we need to use webdrivers inbuilt class ‘profilesIni’ and its method getProfile.