Exploratory Maintenance and Debugging Selenium Tests

What would you do if you ever have to maintain or debug tests that are unknown to you or you have forgotten? Sounds familiar? One obvious approach is to study the test scripts. But if pouring over pages and pages of test scripts with cryptic xpath or css selectors is not your favourite way of working, what can you do? I would prefer to watch a movie. :-) Thats right! Just sit back and watch a movie of the test scripts. Visually see what parts of the web application are being accessed by the test scripts. Pause the test whenever you think something is interesting and study the relevant portion of the test script. Even make changes if you need and continue to watch the show. This way you can easily:

  • Get a good overview of what the test scripts are doing.
  • Fix the test scripts if the web application has changed but no one has bothered to update the tests.
  • Check if the test scripts have missed out something.

I have dubbed this technique as Exploratory Maintenance and Debugging of Selenium Tests.  Sounds interesting? And complicated? And too much effort?

If you are already using a programming language like Java or Ruby or Perl or others then you should be able to use the debugging facilities provided by your IDE and a couple of function calls to be able to do this. More on this in a future post.

But if you are still with Selenese, it is indeed possible to do this very easily. Simply run your tests with the Selenium RC (with the -htmlsuite flag) and you will have the ability of highlighting the elements and pausing and resuming tests. Here are the real steps that you will follow.

  • Start Selenium RC with the -htmlsuite flag using a command line like the following.
java -jar selenium-server.jar -htmlSuite "*firefox"
 "http://www.putyourservernamehere.com:80/" "c:\full\path\to\suitefile.html"
 "c:\full\path\to\resultsfile.html"
  • Reduce the speed in the testrunner panel.
  • Check the checkbox Highlight elements.
  • Click on the pause and resume buttons as needed.

What this Selenium RC approach lacks is the ability to make changes. If your tests are still in Selenese (HTML or XML) then Selenium IDE is the perfect tool for making changes. Being able to easily turn element highlighting on and off is missing, even though the ability to highlight elements is built into Selenium core. With my Highlight Element plugin for Selenium IDE, it is no longer an issue. Once you install the plugin, you can easily turn element highlighting on or off with a click on the toolbar. So you can watch the movie of your tests easily in the Selenium IDE itself and pause and resume test execution as well as make changes whenever needed (while the test execution has been paused). One thing to watch out for is that some changes will prevent you from resuming the test correctly, but you can always save the changes and restart your test all over again.

So element highlighting is a powerful tool that should not be underestimated. Let me know if it saves you some time. Happy testing!

This entry was posted in Selenium Tips and tagged , , , , , , , . Bookmark the permalink.

2 Responses to Exploratory Maintenance and Debugging Selenium Tests

  1. Pingback: Highlight Elements Plugin for Selenium IDE ver 1.0 Released | Really Simple Thoughts of a Perpetual Learner

  2. Pingback: Highlight Elements Plugin for Selenium IDE ver 1.0 Released | Really Simple Thoughts of a Perpetual Learner

Leave a Reply

Your email address will not be published. Required fields are marked *