I had a bug to fix earlier this week which was really just a UI bug. The details arenâ€™t all that important but it was something like a field in a popup div wasnâ€™t being properly updated. This felt a lot like something which could use not just a test in the back end to ensure the correct data was being passed back but also a test in the front end to make sure it was being displayed. As our front end is all webby, as most front ends tend to be these days. Years ago I did some work with Mercury QuickTest as it was then called(I believe it is now owned by HP which makes it pure evil, just like HP-UX). I looked at a couple of tools for automating the browser and decided on selenium partially because it appeared to be the most developed and partially because I couldnâ€™t refuse a tool with an atomic mass of 78.96.
This is the part where I warn you that I really have no idea what Iâ€™m doing, Iâ€™m no selenium expert and Iâ€™ll probably change my mind about how to best implement it. Iâ€™ll post updates as I change my mind.
I started by installing the selenium IDE and, on another computer, the remote control. The IDE is just a plugin for firefox while the RC is a java based tool which happily runs on windows. I opened up a port for it in the windows firewallâ€¦ oh who am I kidding I turned the damn thing off.
I recorded a number of actions using the IDE and added a number of verifications(you can add a check by right clicking on an element and selecting one of the verify options in there). I donâ€™t consider these to be unit tests since they tend to cross over multiple pages. What Iâ€™m creating are work flow tests or behavioral tests. These could be used as part of BDD in conjunction with a tool such as Cucumber or SpecFlow. As such I donâ€™t really care how long these tests take to run, I donâ€™t envision them being run as part of our continuous integration process but rather as part of hourly builds. If things really get out of hand(and they wonâ€™t our application isnâ€™t that big) then the tests can be distributed over a number of machines and even run in the cloud on some Amazon instances.
Iâ€™ll let you know what I come up with. Chances are it will be crazy, because sensible isnâ€™t all that fun.
- Design of Selenium tests for Asp.netA blog with some specific suggestions about how to work with selenium and asp.net. Iâ€™m not in 100% agreement with his ideas but I might change my mind later.
- Adam Goucherâ€™s blog â€“ Adam is a hell of a nice guy who has been helping me out with Selenium on the twitter.