TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Selenium

Custom Firefox Profile for Selenium Webdriver

Introduction

In this tutorial, we will learn how to create a Custom Firefox Profile. A Firefox profile is a collection of bookmarks, browser settings, history etc.

Why you need a custom profile ?

A simple example is that you may want to have all your tests run under same Firefox profile across all tests.
The most common example is an SSL certificate settings or browser plug-ins.Furthermore, it makes sense to create a profile that handles these special test needs.

You should be consistent with the profile you use on all test execution machines. If you used different profiles everywhere, the certificates you accepted or the plug-ins you installed would be different and that would make the tests behave differently across machines.

How to create Firefox custom profile on Windows ?

Step1 : If Firefox is open, close Firefox:
Step2 : Press Windows Key +R on the keyboard. A Run dialog will open.

 

RunDialog_Firefox

Step3 :  as shown above , in the Run dialog box, type in   firefox.exe -P
( You can also use -P, -p or -ProfileManager )

 

ProfileManager_default
Steps4 : Follow the steps of profile manager as shown in the pictures.

 

Create Profile Wizard

Step 5:

ProfileName CreateProfile

 

Step 6

FirefoxProfileManager

 

How to use the custom profile created in selenium webdriver automation ?

Below code example to demonstrate how to use the custom profile.

public class FirefoxCustomProfile
{
 WebDriver firefoxdriver;
 
 @BeforeSuite
 public void launchBrowser()
 {
 ProfilesIni profileIni = new ProfilesIni();
 FirefoxProfile customprofile = profileIni.getProfile("testingdocs");
 firefoxdriver = new FirefoxDriver(customprofile); 
 }
 
 @Test
 public void openFacebookURL()
 {
 firefoxdriver.get("https://www.facebook.com"); 
 }
 
 @AfterSuite
 public void closeBrowser()
 {
 firefoxdriver.quit(); 
 }
 
}

 

Another example :

For example to disable Flash within Firefox for Browserstack test as passing it to desiredcapabilities .It is possible to disable Flash within Firefox, by setting the profile capability to 0. Flash is enabled by default.

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("plugin.state.flash", 0);
caps.setCapability(FirefoxDriver.PROFILE, profile);

 

Conclusion:

You should use a custom profile for all your firefox tests if you need customization for the entire execution. Also, each time Selenium starts a new session driving a Firefox instance, it copies the entire profile in a temporary directory. So, having lightweight profile makes the tests fast and also reliable!

 

Selenium Tutorials on this website:

https://www.testingdocs.com/selenium-webdriver-tutorial/

Official Website:

https://www.selenium.dev/

Related Posts

Windows 10 Settings

Selenium /

Add Microsoft Webdriver on Windows OS

Download Selenium Components

Selenium /

Getting Started with Selenium Webdriver

LambdaTest Testing Cloud SaaS Platform

Selenium /

LambdaTest – Testing Cloud SaaS Platform

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

SauceLabs Website

Selenium /

Run an Example Test on SauceLabs

‹ Working with Slider Example› Understanding common Selenium Exceptions

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version