How can I use Selenium with Java with a custom Firefox Profile?
Asked
Active
Viewed 1.6k times
7
-
1Have you already checked http://garbuz.com/2010/07/31/running-selenium-with-custom-firefox-profile/ and http://luhman.org/blog/2010/03/26/using-custom-firefox-profile-when-running-selenium-tests etc? – Swapnil Jan 22 '13 at 12:14
-
1@Swapnil I asked this question just to add some information to StackOverflow. Thanks. – Koray Tugay Jan 22 '13 at 12:19
3 Answers
8
Here is my configuration:
Firefox version: 12
Selenium version: 2.25
Language: Java
Platform: MacOS
- Open Terminal
- type:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -p
( change the path as necessary ) - Create a new profile, save it in a directory as you wish..
- Start firefox with this profile, add any add-ons, modifications as you wish.
- In Selenium, use:
FirefoxBinary binary = new FirefoxBinary();
File firefoxProfileFolder = new File("/Users/xxx/work/xxx/selenium/src/test/resources/firefoxprofile");
FirefoxProfile profile = new FirefoxProfile(firefoxProfileFolder);
profile.setAcceptUntrustedCertificates(true);
webDriver = new FirefoxDriver(binary, profile);
Again here change the absolute path as required. Add add-ons like autoAuth to pass the HTML Authorization windows in Firefox to this profile..

Koray Tugay
- 22,894
- 45
- 188
- 319
8
For Windows, to create a new Firefox Profile, type:
firefox -profilemanager
in Run that will open the Firefox Profile Manager.
Let's say you have created a profile called Selenium
, then you can use the following code:
ProfilesIni listProfiles = new ProfilesIni();
FirefoxProfile profile = listProfiles.getProfile("Selenium");
WebDriver driver = new FirefoxDriver(profile);
0
You cannot pass HTML authorization window with Selenium. You have to use Auto IT for this purpose. AutoIT gives you the platform to manage the windows based components. You can invoke AUTO IT scripts from Selenium WebDriver

Rahul
- 31
- 1