How good is WebTest’s JS support? Quite good in fact

A JS error with WebTest
During the JAX Ballroom at last JAX conference, I wanted to show to the persons present at the Test Automation table how to get started with WebTest. To do that I chose to write some tests for the conference web site Unfortunately WebTest got following error directly at invocation of the url:

The error being located in a js file with “prototype” in its name, I thought that HtmlUnit still had problems with the prototype library although I was convinced that these had been fixed.

Exactly the same with Firefox
On the next day I was motivated to look at it more attentively and was motivated to get it fixed for the presentation we would have on the day after. Indeed the JAX website could be a good example to show some of WebTest features as all attendees should know it. Therefore I started to examine HtmlUnit’s execution of the javascript with a debugger. Unfortunately I couldn’t find anything and first after a while I’ve had a look at the JavaScript console of my Firefox:

Firefox Javascript console for

WebTest was correct!
This was the explaination: WebTest had no problem and just reacted like Firefox providing precise information concerning the js error (including the line number and file name)!
The faulty line was
for (var i = 0; i < element.childNodes.length; i++) {
and both Firefox and WebTest gave correct message (a bit different) concerning the problem.

It’s possible to tell WebTest to ignore JS errors but it’s not recommanded as it doesn’t help producing high quality Web Sites and is an example of WebSite that didn’t get tested correctly (or with a tool that doesn’t help discovering such failures).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: