Koray Tugay Koray Tugay - 1 year ago 132
Java Question

How to use custom Firefox Profile with Selenium? (Java) (And pass HTML Authorization Window)

How can I use Selenium with Java with a custom Firefox Profile?

Answer Source

I have spent a day trying to do this and decided to share it here. There is some information on the web as well but most of them are a bit complicated or not up to date...

Here is my configuration:
Firefox version: 12
Selenium version: 2.25
Language: Java
Computer: Macintosh
  1. Open Terminal
  2. type: /Applications/Firefox.app/Contents/MacOS/firefox-bin -p ( change the path as necessary )
  3. Create a new profile, save it in a directory as you wish..
  4. Start firefox with this profile, add any addons, modifications as you wish.
  5. In Selenium, use:

 FirefoxBinary binary = new FirefoxBinary();  
 File firefoxProfileFolder = new 
 FirefoxProfile profile = new FirefoxProfile(firefoxProfileFolder);
 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..

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download