What is Firefox Profile?
When we install Mozilla Firefox, Firefox creates a default profile, it contains a collection of bookmarks, extensions, passwords, history, preferred home page when you open browser, and another browser setting etc. …,
We can customize this Firefox profile as per our automation testing need. So, one can say like Firefox profile is nothing but different user is using Firefox.
Why do we need to Set Firefox Profile in Selenium WebDriver?
Default Firefox contains a collection of bookmarks, browser settings, extensions, passwords, and history; in short, all of your personal settings.
When you trigger selenium with this browser you test become slow and unreliable. To make it lighter we generally create a custom profile which loads only required plugins and extensions with predefined settings.
In order to run all test successful, we need a browser which –
- Loads easily (very lightweight profile
- Proxy setting (if required)
- SSL certifications handling (if required)
- Company specific username and password to start browser (if required)
How to create Firefox Profile in Selenium WebDriver?
Let us assume that you wanted to have google as the startup page for Firefox. To do this we will need to update the “browser.startup.homepage” preference.
Follow below steps to add a website as your homepage:
1. Let’s first start by creating the FirefoxProfile object.
2. Now we will set the preference by using the below method.
3. To get the profile to be used, we need to pass it in to the driver. To do this, we need
to do the following:
FirefoxProfile ffprofile= new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffprofile);
That’s it, this is all we can set Firefox profile.
Let us see some examples where we can use this Firefox Profile setting.
Below two articles explain the real time use of Firefox profile –