How to use a custom Firefox profile with Selenium? (Java) (and go through the HTML authorization window)

How can I use Selenium with Java with a Firefox user profile?

+5
source share
2 answers

I spent a day trying to do this and decided to share it here. There is some information on the Internet, but most of them are a little more complicated or not updated ...

Here is my configuration:
Firefox version: 12
Selenium version: 2.25
Language: Java
Computer: Macintosh
  • Open terminal
  • type: /Applications/Firefox.app/Contents/MacOS/firefox-bin -p (change the path if necessary)
  • Create a new profile, save it in the directory as you want ..
  • Launch firefox with this profile, add any additions, 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);

. , autoAuth, HTML Firefox .

+6

Windows, Firefox, :

firefox -profilemanager

Run, Firefox.

, Selenium, :

ProfilesIni listProfiles = new ProfilesIni();
FirefoxProfile profile = listProfiles.getProfile("Selenium");
WebDriver driver = new FirefoxDriver(profile);
+4

All Articles