Thursday, July 03, 2008

The Immaturity of In Browser Testing

Designing applications that behave the same in several browsers is a miserable job. Unfortunately, it's often a business requirement. If your application needs to behave flawlessly in multiple browsers, In Browser testing is probably a necessary evil.

I tend to use Selenium for In Browser testing; therefore, this entry is written from the perspective of a Selenium user.

Selenium is terrible for several reasons.Of course, there is another point of view. There are several reasons that Selenium is a good tool.The trick to using Selenium is knowing who (for), what (for), when, and why it's useful. For those that desire concise descriptions -- Selenium is best used by developers or testers when testing the most valuable (to the business) happy paths of a Javascript heavy web application that must function in several browsers.

When you begin to deviate from the above context, things begin to get problematic.

Selenium is undoubtably a tool that can be used by both developers and testers. The various ways to drive the tool ensure that both less than technical users and very technical users both have options. Selenium is best used for happy path testing because large suites can be both hard to maintain and prohibitively slow. Selenium is an appropriate choice for Javascript heavy applications since the tests run directly in the browser, ensuring expected behavior. Selenium is also helpful for mitigating cross-browser compatibility risks. The write once, run in several browsers model is a powerful one. You should chose Selenium when it can improve your confidence that the highest business value features are working correctly.

Despite it's problems it would be misleading not to mention that it probably is the best solution for In Browser testing, but there is surely room for improvement.

Labels: ,




Comments:
Hey Jay,

I can understand that pain, because we have the same issue in .Net.

Should I go with Selenium? Watin? Watir?

All of them feature most of these problems you mentioned.

That's why I started a project that aims at being an easier, fluent interface for doing browser driver acceptance testing.

If you'd like to check it out, just go to http://using.stormwindproject.org and check the Stormwind.Accuracy project.

Hope you like it! It's for .net, but the idea behind is definitely platform agnostic.

Cheers,
Bernardo Heynemann
ThoughtWorks UK
 
You mentioned going the DSL route for selenium. This is exactly what we did at my last gig for a commercial property insurance app. It worked out really well. We made a simple declarative DSL (in Java, which turned out nice because of good auto-completion in IDE) and wrote all our tests in that language.

The DSL turned out really key for us because not only were our tests readable, but the DSL provided us a layer of abstraction over SeleniumRC. We actually implemented 2 targets for our DSL, Selenium RC and a Selenium HTML. And we were toying with implementing other targets like HTMLUnit.

I could go on and on... but my point is having a good DSL really was what helped power the success of our Selenium test suite implementation.
 
We use Concordion to express the test cases and WebDriver to provide the scripting DSL for Selenium. Together they work really well.

http://www.concordion.org
http://code.google.com/p/webdriver
 
We've found that our selenium scripts fail roughly 16 percent of the time randomly (probably due to timing issues)

One of our developers saw it randomly fail and wondered about what the heck happened so scripted a set of 500 identical tests to run, 86 of which failed. I don't care whether it's 0 or 500 successes, I just want consistency.

Ransom
 
I think the way to go is do the unit testing on the server. Why should UI code by so difficult to test? MVC was created to enable easy unit testing of business logic so business logic wasn't always easy to test. If we rewrite UI code to be easier to test then we can eliminate the browser all together. It's a high ideal but I think it's the best way to go in the long term. you can find more of my thought on the future of UI testing here: http://jonathanparker.com.au/archive/2008/01/12/why-microsoft-is-going-in-the-wrong-direction-with-the-asp-net-mvc-framework.aspx
 
I found WatiN or InCisif.net easier to use for implementing functional web testing on the .NET platform.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?