Selenium for your web application testing

Selenium looks cool. Sure, its slower than unit tests, but its much faster than a human. It uses the web browser itself, to get your tests going, and will test it just like how a human tests. In a continious build farm, you can have good browser compatibility testing (run it against IE on Windows, even), and it also does functional testing.

It’s not only for Ruby, it works with Perl, Python, PHP and so forth. Its good for regression testing, and uses JavaScript. This means its very cross-platform, and cross-browser compatible.

How does it work with Flash? The new version of Flash apparently has JavaScript support according to Alex Chaffee, and you can actually use Selenium if need be. A member of the audience did mention that he had tried it, and its a little icky.

When testing web apps, getting titles are important, to see what the title of the page says – do it frequently in testing, because sometimes with web apps, you don’t get a 404 error, but a 200 OK (even though the page itself says it has failed). Write your tests early. Selenium can become slow – consider refactoring, or maybe move it to unit testing. It also has a slow mode, and it might be useful for a demo of your application even (well, you can see the login, and so forth). Polling architecture, web apps will time out – a somewhat sensible timeout is about 20 seconds, even if you’re on a very slow connection – any longer, and you’re probably not generating the page and its a (timing) failure.

Selenium doesn’t work well with testing file downloads. And on Firefox, you might need to use the Chrome extension. Cookies stay on between tests, so this can leads to tests passing when run alone, but failing when run together – solution is to eval JavaScript to clear cookies between tests. In Firefox, you can specify the name of a profile and launch it in a clean browser – Selenium by default, makes a new profile by itself – this really helps as some Extensions might affect your tests. On Linux, this is firefox -ProfileManager.

Peer To Patent, a community patent review site (and it will be open source!). Its tested with Selenium, sponsored by the USPTO, and looks like something that can definitely be useful in making sure silly patents aren’t passed (when the patent officer doesn’t know there’s prior art). When asked at the SDForum Ruby on Rails gathering, how many held patents, I’d say about 15-20% of the crowd raised their hands! Impressive number, but then again, I’m sitting in the Silicon Valley, what did I expect, right?

Continious testing architecture? Mac Mini, Parallels (Ubuntu, Windows), they use coherence mode of Parallels and IE sits and looks like a “native” application. All tests run, and the Ubuntu virtual instance is what launches everything. Testing thus happens on everything – OS X, Linux and Windows.

Technorati Tags: , , , ,

One Comment

  1. […] highly motivated/dedicated speaker. This being my second talk that I’ve attended on Selenium (last year at the Ruby Conf), and now, its pretty cemented in my head that I’ve got to make use of it, the next time I […]


i