Running Selenium with custom Firefox profile

In some instances you may find yourself trying to run functional test against application server that has fake SSL certificates (for example your test environment). In that case Selenium will give you headache since it will create and destroy custom Firefox profile for each test.

Fortunately, you can use your own custom profile and run your Selenium functional tests using this profile. In that case you can accept all of the certificates once and Firefox will never prompt you to accept them again. This is how you do this:

  • Navigate to the directory that contains your Firefox profile. If you use Windows then this directory is something like this C:\Documents and Settings\[your login name]\Application Data\Mozilla\Firefox\Profiles
  • In this directory you will see a subdirectory with Firefox profile in it. It would look something like this zv7rrcv8.default.
  • Copy this entire directory and save it under selenium.default name.
  • Then navigate to this folder and open up prefs.js file in text editor. Find the line that says:
    user_pref("browser.startup.page", 0);
    and comment it out like this
    //user_pref("browser.startup.page", 0);
  • Then open up the bat file that you use to start selenium server.

Use this command to start Selenium server:

java -jar ./selenium-server-0.9.2.jar -firefoxProfileTemplate "C:\Documents and Settings\[your login name]\Application Data\Mozilla\Firefox\Profiles\selenium.default"

Now you can run your functional test against Selenium server using your own Firefox profile and not worry about SSL certificates, and other things that are specific to your network.


Comments are closed.