I finally got around to setting up Selenium and writing a few tests yesterday. I have been meaning to do that ever since Charlie pointed it out to me a few months ago. Man, I wish I hadn’t waited. Selenium is easily the best way to test a web app that I have every tried. With Selenium your application is tested in the same environment it will be used, in the browser. And it is easy to use, to boot.
Just to be clear, Selenium is not a replacement for unit tests1. It is a functional or acceptance testing tool. It is slower2 and its results are probably less specific than those of most unit tests. However, if you need to verify that your application actually works from the users perspective (and you do) Selenium is the tool for you. The tests are run in the target browser(s) so the tests fail when the user would see a failure, even if the problem is some esoteric browser compatibility issue.
If you are developing web applications and you are not using it already give Selenium a try. You will not regret it.
Postscript: Trouble in paradise
I am having one problem with Selenium, though. It is really, really slow in Internet Explorer 6 on my Ubuntu box. A test suite that takes 1 minute 15 seconds in Firefox take 12 minutes and 42 seconds in IE (same machine, network, etc). I expected IE to be slower, both because it is IE and because it is running under Wine but expected the difference to be percentages not orders of magnitude. If anyone has any ideas about how to make Selenium run faster in IE on Linux I would love to here them.
I consider functional tests in Rails to be unit tests for the purpose of this discussion.
Selenium actually make the same HTTP calls that will be made in the wild. This is a good way to test but it has significant overhead when compared to an approach, like “functional” tests in Rails, which by-passes the HTTP layer altogether.
↩</li> </ol> </div>