Basic Selenium

Simple step to start Default Firefox Profile in Selenium

Default Firefox Profile in Selenium

Welcome back to another post of Selenium Webdriver in this post I will show you how to start default Firefox profile in Selenium Webdriver.

While working with Firefox in Selenium you have noticed that it starts the fresh profile every time so you will not get any cookies, form data and any plugin or add-on, which you have installed on your local browser.

 

What is Firefox Profile?

Ans- Firefox or any other browser contain your normal data like- saved data, history, cookies, add-on and all information which is generally called Firefox Profile and using Selenium we can access these profiles and operation can be performed.

You can create an own profile and can use throughout your Selenium script execution.

Default Firefox Profile in Selenium

 

Usage of Default Firefox Profile in Selenium

If you want to start default, profile every time when you execute your test so that you do not have to handle two instances of the same browser then you can do using FirefoxProfile class in Selenium.

I have used the Firefox profile while downloading the file in Selenium so if you have still not visited then check below post for more usage of Firefox Profile.

How to download file in Selenium

 

If you want to check from where we get default profile.

Step 1- Close all Firefox Instance

Step 2- Open run

Step 3- Type firefox.exe –p

Default Firefox Profile in Selenium

Step 4- Hit enter

Step 5- Check whether you have default profile in the `list. If yes then below code will work fine.

Default Firefox Profile in Selenium

 

Please use below code to start default Firefox session.

 

Program to start Default Firefox Profile in Selenium

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 FirefoxDemo {



      public static void main(String[] args) {



            // Create object of ProfilesIni class

            ProfilesIni init=new ProfilesIni();



            // Get the default session  

            FirefoxProfile profile=init.getProfile("default");



           // Pass the session/profile to FirefoxDriver 

            WebDriver driver=new FirefoxDriver(profile);



            driver.get("https://vistasadprojects.com/mukeshotwani-blogs-v2/");



            driver.quit();



      }



}

 

Output- After running your code you will get Firefox with preinstalled cookies, Add-on and all the details, which saved earlier.

 

Hope you enjoyed this article if any doubt in Selenium then feels free to post in Selenium Forum.

For any comment or feedback please comment below section.

author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.