Remove the annoying certificate error page when running selenium tests

Selenium and webdriver tests are everywhere these days. They can be often slow and flaky, but you need to run them to make sure you didn’t break anything.

cf.For more information on selenium webdriver, go to selenium webdriver documentation.

Often what I find is I run selenium tests and start doing something as they take time to run. Then the tests are not running. Firefox stopped with certificate error! You have to add the certificate again to run those tests. It happens again and again, and as you are not a machine, you get tired mentally and emotionally. This is my story with selenium tests, so far.

There are a few ways to get around this certificate error. (I can’t say it’s annoying, as it warns you against the fraudulent websites.)

cert_override.txt

This is a text file gerated in the user profile to store SSL certificate expections, if a user specifies it.
Here is an example.

Fields

Files are separated by a tab character, and each line is finished by a line feed character.

1. domainname:port : port 443 for HTTPS (SSL)
2. hash algorithm OID

  • SHA1-256: OID.2.16.840.1.101.3.4.2.1 (most used)
  • SHA-384: OID.2.16.840.1.101.3.4.2.2
  • SHA-512: OID.2.16.840.1.101.3.4.2.3

3. Certificate fingerprint using previous hash algorithm

4. One or more characters for override type:

  • M : allow mismatches in the hostname
  • U : allow untrusted certs (whether it’s self signed cert or a missing or invalid issuer cert)
  • T : allow errors in the validity time, for example, for expired or not yet valid certs

5. Certificate’s serial number and the issuer name as a base64 encoded string

Firefox profile

In order to edit the file, you would have to find the file first, and it was tricky to locate Firefox profile.
If you are on windows 7 or windows server 2008 like me, click on Windows Start and type %APPDATA%\Mozilla\Firefox\Profiles\ in the search box.
If you on a earlier version of windows, please go to a mozilla support page for the profile location.

Remove the annoying certificate error page when running selenium tests

How to use html test suite and cases on Selenium RC

References

Since 2009, I have used Selenium IDE and core. I love Selenium IDE. It is easy to use and is very handy as I can record test cases and also run them one by one by clicking on each. A colleague of mine used Selenium RC with C# but it did not impress me much because he started RC server first, then executed NUnit to lanuch the test suite. Also, I did not like coding in C# selenium test cases. How simple and elegant those html test caes are!

Then today, a bit shame to say, I realised I can use html test suite on Selenium RC. Oh how fantastic it is. My scrum team had scores of accumulated html test cases, and I can use them without any alteration.

First, let’s see how to install Selenium RC

  1. You download Selenium RC from http://seleniumhq.org/download/
  2. Unzip it into local hard drive, for example, c:\Selenium. Because Selenium RC is written in Java, you need to install java runtime if you do not have it.

selenium-server.jar is the main engine that runs test suite. You can run it on command prompt, but it is very handy to create a batch file to run it as the above reference link showes it.

For IE

cd \
cd C:\Selenium\selenium-server-1.0-beta-2
java -jar selenium-server.jar -port 4545  -htmlSuite *iehta "http://www.sekyee.com" "C:\Selenium\Test_Suite.html" "C:\Selenium\Results.html"
pause

For firefox


cd \
cd C:\Selenium\selenium-server-1.0-beta-2
java -jar selenium-server.jar -port 4545  -htmlSuite *chrome "http://www.totaljobs.com" "C:\Selenium\Test_Suite.html" "C:\Selenium\Results.html"
pause

A simple selenium-server.jar usage is like this.
selenium-server.jar -port {your port number} -htmlSuite {firefox or ie} {base url} {absolute path for your test suite} {absolute path for your test result file}

I’m not sure why * is required befire iehta, yet without the *, it does not find testsuite. Also, Results.html must exist before you run this even though it is an empty file.
I find {base url} very handly, so you can put relative path in your test cases. This enables you to use the same test cases to test on different environments such as Dev, Int, Staging, and Live.

Hoep this helps

How to use html test suite and cases on Selenium RC