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?
-
1AFAIK it's always a brand new one. You should just create your own and modify it to your needs. – devsnd Aug 20 '12 at 01:25
-
2ok its a brand new one, but it is still basing it on some prototype stored on a computer, since it is remembering to start up an addon that was since disabled within firefox. Where is this prototype? – Michael Roller Aug 20 '12 at 01:27
-
4I guess it's the one firefox provides, if you specify the `-CreateProfile` option on the command line. e.g. `firefox -CreateProfile test`. So what you are asking for is rather a firefox question, than a selenium one. I still recommend just to create a new Profile using the Profile Manager, e.g. `firefox.exe -ProfileManager` – devsnd Aug 20 '12 at 01:32
-
In the headless case install / start something like `xvfb` (framebuffer server) and you will be able to use `DISPLAY=:11.0 firefox -CreateProfile test`. – daniel.kahlenberg Jun 24 '15 at 09:49
4 Answers
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

- 14,128
- 14
- 53
- 77
-
What kind of code is this? I.e., I'm using selenium in Rails via the capybara and selenium-webdriver gems. – Dogweather Aug 16 '13 at 23:58
-
can i use this profile the way i used several user logins by using single browsers? @PavelJanicek – gumuruh Oct 01 '16 at 05:47
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

- 2,763
- 35
- 32
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;
}

- 957
- 1
- 13
- 21

- 1,497
- 19
- 18
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");

- 957
- 1
- 13
- 21

- 1,654
- 16
- 26
-
Wow, thanks. The existing ProfilesIni() quit working for some reason, and always returned an anonymous profile directory below /tmp. – philwalk Apr 23 '16 at 23:42