How to create a Firefox profile for selenium testing
What is a profile?
Profile is a collection of file which Firefox saves your personal information like bookmarks, passwords and other user preferences. These are stored in a separate location from actual Firefox program files. You can have one or more Firefox profiles, each containing a separate set of user information.
Why we need a profile in selenium?
profiles are easy to load and very automation friendly. It contains special proxy and several other settings to run a good test.
Create a profile in Linux
- Go to your console
- Execute the following command “
firefox --new-instance --ProfileManager”.
You can see the following profile manager window.
3. Click on the create profile option in the profile manager to start create profiles.
4. Read the instructions and click next .
5. Enter a profile name and a location to store your new profile.
6. Click finish.
Now you have created the profile. Let’s move on how we can use this profile in selenium
How to use the created profile inside selenium web driver code
ProfilesIni profile = new ProfilesIni();
FirefoxProfile profile1 = profile.getProfile("Guru99");// profile name is Guru99
DesiredCapabilities dc = DesiredCapabilities.firefox();
FirefoxOptions opt = new FirefoxOptions();
WebDriver driver=new FirefoxDriver(opt);