Friday, February 13, 2009

Selenium and https

Selenium is a great tool to automate tests for your website. Unfortunately there is a glitch when some of the pages redirect to https.
Selenium can't accept a certificate and when running FireFox, FireFox runs with a new clean profile so the exception to the https site is lost.
A way around this problem is to create a "selenium profile" and when running Selenium Server one specifies the custom profile to be used, thus the exception will be in the profile and the tests will pass!

Here is a breakdown of the steps involved to get it running:
1. Close down instances of FireFox
2. Run FireFox from command line as follows: C:\Program Files\Mozilla Firefox\firefox.exe -ProfileManager
3. Profile dialog loads up, create a new profile. I called it SeleniumProfile and added a new folder in my selenium test suite, something as follows: /mysuite/seleniumprofile
4. Browse to the HTTPS page (with self-signed certificate) and accept the self-signed certificate when prompted. An exception is added in the profil
5. Close the browser.
6. Add the profile to the Selenium Server. The command will look something as follows:

java -jar selenium-server.jar -firefoxProfileTemplate "C:\mysuite\seleniumprofile"

That's it, kick in your lovely automated tests and let them roll without https problems!

No comments:

Post a Comment