Where does Selenium WebDriver (a.k.a Selenium 2) get the anonymous profile that it uses when it opens FirefoxDriver? If it used the default for Firefox, %appdata%/roaming/mozilla/firefox/profiles, then if I were to disable a firefox plugin, it should be disabled for Selenium WebDriver also, so why isn't it?
Selenium comes with default Mozilla Firefox driver which is bundled in Selenium WebDriver jar file. That's why for calling Firefox driver, no setup is required. If we want to use other browsers, we need to set up its system property.
We can open Chrome default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter. We need to use the ChromeOptions class to open the default Chrome profile. We need to use the add_argument method to specify the path of the Chrome profile.
Profiles profile = new Profiles(); FirefoxProfile fprofile = profile.
Firefox profile is the collection of settings, customization, add-ons and other personalization settings that can be done on the Firefox Browser. You can customize Firefox profile to suit your Selenium automation requirement. Also, Firefox or any other browser handles the SSL certificates settings.
I will answer it, supporting comment from @twall: When starting firefox in Selenium 2 WebDriver, it starts new, anonymous profile.
However, if you want to change it, you can create new Firefox profile and name it somehow, you know what it is - e.g. SELENIUM
Then in your code do this:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
That way, Firefox will always start that profile. In the profile you do all the settings you need
You can assign to each Selenium grid 2 node a specific firefox profile:
java -jar selenium-server-standalone-2.37.0.jar -Dwebdriver.firefox.profile=my-profile -role node -hub http://example-server.org:4444/grid/register
Notice that the value of the webdriver.firefox.profile has to be the firefox profile name, not the location or the folder name
When running webdriver on a test server with no options to create profiles on the machine you can create your profile programmatically:
private FirefoxProfile GetFirefoxProfile()
{
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "http://localhost");
return firefoxProfile;
}
Fetching a profile is not useful as it is internally creating another copy of the fetched named profile. Accessing the original profile is required if for eg: test coverage data should be written to a data store across multiple invocations.
Here is a possible solution by Overriding the ProfilesIni class of Selenium
Start by creating a Custom profile using firefox -p, say "CustomSeleniumProfile"
ProfilesIni profileini = new ProfilesIni() {
@Override
public FirefoxProfile getProfile(String profileName) {
File appData = locateAppDataDirectory(Platform.getCurrent());
Map<String, File> profiles = readProfiles(appData);
File profileDir = profiles.get(profileName);
if (profileDir == null)
return null;
return new FirefoxProfile(profileDir);
}
};
FirefoxProfile profile = profileini.getProfile("CustomSeleniumProfile");
//profile.setEnableNativeEvents(false);
driver = new FirefoxDriver(profile);
//ffDriver.manage().deleteAllCookies();
driver.get("http://www.google.com");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With