How to create custom firefox profile in Selenium Webdriver

Why create a new Firefox profile
A profile in Firefox is a collection of bookmarks, browser settings, extensions, passwords, and history; in short, all of your personal settings. When you want to run automation reliably on a Firefox browser:

It is advisable to make a separate profile. Automation profile should be light to load and have special proxy and other settings to run good test.
You should be consistent with the profile you use on all development and test execution machines. If you used different profiles everywhere, the SSL certificates you accepted or the plug-ins you installed would be different and that would make the tests behave differently on the machines.

Open your firefox browser And follw the steps.

Step 1. At the top of the Firefox window, click on the File menu and then select Exit.

Step 2. Press ‘Windows Key + R’ or click on the Windows Start Menu (bottom left button) and then select Run.

Step 3. In the Run dialog box, type in: ‘firefox.exe -p’ and then Click OK.

Step 4.Click the ‘Create Profile…’ button on the ‘Firefox – Choose User Profile’

Step 5. Click ‘Next >’ in the ‘Create Profile Wizard’ window that comes up.

Step 6.Type in a new name ‘Dollar_Advanced’ in the ‘Enter new profile name’ box and click ‘Finish.

Step 7. Now choose your profile which was created. It will open the firefox browser

That’s it your own profile was created. Now follow the script below.
public void test() throws Exception

ProfilesIni profile = new ProfilesIni();

FirefoxProfile myprofile = profile.getProfile(“Dollar_Advanced”);

WebDriver driver = new FirefoxDriver(myprofile);

Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
String browserName = cap.getBrowserName().toLowerCase();
String os = cap.getPlatform().toString();
String version = cap.getVersion().toString();



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s