Thanks Stephan for the example for:
>Taken a step farther you can make a macro that takes an element and do a retry
>on the element sleeping between retries. Then all you >have to do is pass a
>verifyXPath step for whatever will load with ajax to the macro and it will
>keep trying till it is loaded.
Truly examples are better than sentences, so, I'll include mine as it is a
little different than Stephan's:
<macrodef name="ajaxLoad">
<element name="value" implicit="yes"/>
<sequential>
<retry maxcount="30">
<sleep seconds="1"/>
<value/>
</retry>
</sequential>
</macrodef>
<ajaxLoad>
<verifyXPath xpath="//tab...@id='ajaxLoadTable']" description="Wait for
ajax to load"/>
</ajaxLoad>
This way you can also use webtest steps to verify when ajax is loaded so you
could do:
<ajaxLoad>
<verifyInputField name="valueSetWithAjax" value="100" description="Wait
for ajax to load"/>
</ajaxLoad>
--------------------------------------------------------
Hi,
On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
> Is it possible this stuff is created using ajax for you guys? If so
> you can use a sleep to wait for it to load and then check it with
> xpath.
Instead of sleeping a certain time you can do the check in a loop and
sleep one second only. That saves you time if your request is a lot
shorter that the aproximated 5 seconds and also if a request hangs once
you wont get a failure.
I use this macro to check for an xpath that must be exist after the
response from an ajax call was reveived:
<macrodef name="checkAjaxResponseXpathRegex" description="check
response of an ajax request">
<attribute name="description" />
<attribute name="xpath" />
<attribute name="regex" />
<sequential>
<retry maxcount="10">
<sleep seconds="1"/>
<verifyXPath
description="@{description}"
xpath="@{xpath}"
regex="@{regex}"
/>
</retry>
</sequential>
</macrodef>
Inside the webtest I do this:
<setSelectField
description="Select some value"
xpath="//sele...@id='some_id']"
value="some_val"
/>
<checkAjaxResponseXpathText
description="check result after ajax call"
xpath="//d...@id='some_id']/ol/li[4]/a"
text="Sometext"
/>
With this mechanism I can test most of the Ajax stuff inside a page
that changes the DOM tree when the response is received.
Best regards, Stephan
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest