[Webtest] WebTest fails on Petstore 2.0

Paul Beck Paul Beck <pbeck@nearinfinity.com>
Sat, 05 Jul 2008 21:53:38 -0400


Hello,

I am doing a comparison of various web application testing tools. WebTest
appeared to be a strong contender from the documentation, however that
turned out not to be the case in practice. I am using the Petstore 2.0
application from Sun's Blueprints as a basis for test, as this has a lot of
AJAX stuff in it. Simple assertions fail as WebTest apparently does not see
the text that is displayed via AJAX. Here is a trivial test which fails:

<project default="test">

    <target name="test">

        <webtest name="check that petstore categories can be found by
clicking images">
            <invoke url="http://localhost:51492/petstore/faces/index.jsp"
description="Go to Petstore 2.0"/>
            <verifyTitle text="Java Pet Store Reference Application" />
            <clickElement
xpath="//area[@onclick=&quot;browse('Dogs')&quot;]" />
            <verifyText text="Beach Dog"/>
            <clickElement
xpath="//img[@src='/petstore/images/banner_logo.gif']" description="Main
Page" />
        </webtest>

    </target>
</project>

It cannot find any text of the page. If I click on the failed step
(verifyText) Page link, it displays a page with almost no text.

What am I doing wrong?

In addition, XPath expressions that work in Selenium-RC or Watir fail in
WebTest. For example, on the home page for Petstore, the images on the left
which are displayed as a dojo pick list can be accessed and clicked on via
the XPath //img[@src="/petstore/images/dogs_icon.gif"] in either Watir or
Selenium. Also, the WebTest recorder recognizes this as a valid XPath
expression but a <verifyXPath /> fails as does any use of it in a test.

Am I missing something?

Paul Beck