Translate

How to create custom firefox profile in Selenium WebDriver

Why create a new Firefox profileA 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 follow 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.

@Test(priority=185)
public void test() throws Exception
{

ProfilesIni profile = new ProfilesIni();

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

WebDriver driver = new FirefoxDriver(myprofile);
driver.get("https://www.seleniumbycharan.wordpress.com");

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

}

}

No comments:

Post a Comment