WebTest fails on Petstore 2.0

View: New views
3 Messages — Rating Filter:   Alert me  

WebTest fails on Petstore 2.0

by Paul Beck-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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="browse('Dogs')"]" />
            <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




_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

RE: WebTest fails on Petstore 2.0

by WSoula :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried the easyajax config option (http://www.nabble.com/Ajax-Testing-to16051425.html#a16051885)?  Or adding a sleep statement before the verifyText to wait for the text to appear.  I think what is happening is that WebTest loads the page and then moves on to verifying the text but ajax hasn't finished loading the text.

-----Original Message-----
From: webtest-admin@... [mailto:webtest-admin@...] On Behalf Of Paul Beck
Sent: Saturday, July 05, 2008 8:54 PM
To: webtest@...
Subject: [Webtest] WebTest fails on Petstore 2.0

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="browse('Dogs')"]" />
            <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




_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: WebTest fails on Petstore 2.0

by Paul Beck-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Both options cause webtest to go into a loop with the statement that the contents of the window have changed. See snippet below. This repeats over and over until cancelled or the timeout expires.

[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of window changed to http://localhost:4867/petstore/faces/catalog
.jsp?catid=Dogs#canine01,101 (text/html)
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of current window changed, it will become current response
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current form set to none
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current response now: http://localhost:4867/petstore/faces/catalog.jsp?ca
tid=Dogs#canine01,101
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of window changed to http://localhost:4867/petstore/faces/catalog
.jsp?catid=Dogs#canine01,101 (text/html)
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of current window changed, it will become current response
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current form set to none
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current response now: http://localhost:4867/petstore/faces/catalog.jsp?ca
tid=Dogs#canine01,101
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of window changed to http://localhost:4867/petstore/faces/catalog
.jsp?catid=Dogs#canine01,101 (text/html)
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of current window changed, it will become current response
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current form set to none
[clickElement]  INFO (com.canoo.webtest.engine.WebClientContext) - Current response now: http://localhost:4867/petstore/faces/catalog.jsp?ca
tid=Dogs#canine01,101

On Mon, Jul 7, 2008 at 8:29 AM, Soula, William <wsoula@...> wrote:
Have you tried the easyajax config option (http://www.nabble.com/Ajax-Testing-to16051425.html#a16051885)?  Or adding a sleep statement before the verifyText to wait for the text to appear.  I think what is happening is that WebTest loads the page and then moves on to verifying the text but ajax hasn't finished loading the text.

-----Original Message-----
From: webtest-admin@... [mailto:webtest-admin@...] On Behalf Of Paul Beck
Sent: Saturday, July 05, 2008 8:54 PM
To: webtest@...
Subject: [Webtest] WebTest fails on Petstore 2.0

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




_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

LightInTheBox - Buy quality products at wholesale price