Mark is a graph advocate and field engineer for Neo Technology, the company behind the Neo4j graph database. As a field engineer, Mark helps customers embrace graph data and Neo4j building sophisticated solutions to challenging data problems. When he's not with customers Mark is a developer on Neo4j and writes his experiences of being a graphista on a popular blog at http://markhneedham.com/blog. He tweets at @markhneedham. Mark is a DZone MVB and is not an employee of DZone and has posted 522 posts at DZone. You can read more from them at their website. View Full User Profile

Selenium, Firefox and HTTPS pages

03.25.2010
| 8291 views |
  • submit to reddit

A fairly common scenario that we come across when building automated test suites using Selenium is the need to get past the security exception that Firefox pops up when you try to access a self signed HTTPS page.

Luckily there is quite a cool plugin for Firefox called 'Remember Certificate Exception' which automatically clicks through the exception and allows the automated tests to keep running and not get stuck on the certificate exception page.

One other thing to note is that if the first time you hit a HTTPS page is on a HTTP POST then the automated test will still get stuck because after the plugin has accepted the certificate exception it will try to refresh the page which leads to the 'Do you want to resend the data' pop up.

We've previously got around this by writing a script using AutoIt which waits for that specific pop up and then 'presses the spacebar' but another way is to ensure that you hit a HTTPS page with a GET request at the beginning of the build so that the certificate exception is accepted for the rest of the test run.

To use the plugin in the build we need to add it to the Firefox profile that we use to run the build.

In Windows you need to run this command (having first ensured that all instances of Firefox are closed):

firefox.exe --ProfileManager

We then need to create a profile which points to the '/path/to/selenium/profile' directory that we will use when launching Selenium Server. There is a much more detailed description of how to do that on this blog post.

After that we need to launch Firefox with that profile and then add the plugin to the profile.

Having done that we need to tell Selenium Server to use that profile whenever it runs any tests which can be done like so:

java -jar selenium-server.jar -firefoxProfileTemplate /path/to/selenium/profile

From http://www.markhneedham.com

Published at DZone with permission of Mark Needham, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Lajos Papp replied on Thu, 2010/03/25 - 7:25am

Hi Mark,

 Isn't it easier to:

  • create a new profile for selenium tests
  • start firefox manually to use that profile
  • navigate to the selfsigned https site
  • accept permanently the certificate (ar install it as trusted)
  • exit firefox
Than later you can use this profile for selenium tests, and you are not facing the security exception.

Chris Roberts replied on Thu, 2010/03/25 - 2:47pm

Great tips, Mark!  Getting past HTTPS issues has been my major problem with Selenium in the past, particularly when I've wanted to use it for testing eCommerce sites that use HTTPS for pages that require credit card data.  Next time I'll know exactly what to try.  Thanks!

Mike Haller replied on Thu, 2010/03/25 - 5:04pm

Why not just use a valid certificate from startssl.com? It's free and the root CA is in all browsers.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.