Total Pageviews

Wednesday, August 17, 2011

How to handle ssl certificate error in selenium rc

Hi all,
when your tests redirect to an HTTPS URL on the same host, where your SSL certificate is self-signed, things go wrong. As Selenium effectively runs Firefox with a new profile every time, you potentially lose any certificate exceptions you might accept.

We have a technique to avoid this problem:
  - create a custom profile;
  - run Firefox using that profile;
  - browse to the HTTPS URL and accept the exception into that profile;
  - close the profile.

Steps to create a Firefox profile:
1. Close down any running Firefox instances.
2. Start Firefox (the one you're going to run your tests with) with the profile manager: firefox –ProfileManager using command prompt.
3. Create a new profile. You'll be prompted to choose a directory for the profile. Put it somewhere inside the project where you're writing the tests.
4. Select the profile and run Firefox using it.
5. Browse to the HTTPS URL (with self-signed certificate) you're going to be testing against.
6. Accept the self-signed certificate when prompted. This creates an exception for it in the profile.
7. Close the browser.
8. Go to the Firefox profile directory.
9. When you run your Selenium server, pass a -firefoxProfileTemplate /path/to/profile/dir argument to it. This tells Selenium to use your partial profile (with certificate exceptions) as a basis for minting its new profile. So you get the certificate exceptions, but without any of the other clutter you would get if you used a whole profile.


command for using the firefox profile template in selenium server.

java -jar selenium-server.jar -firefoxProfileTemplate /path/to/profile \
-htmlSuite “*chrome firefox-bin” “http://host.com” “testSuite.html” “seleniumResults.html”

1 comment:


  1. I didn't get any thing from this can u please explain in detail, with step by step procedure.. So it may be help full to me.... thanks in advance ... i hope u post with clean information

    ReplyDelete