I too am testing ajax with webtest. There is always the option of manually adding sleeps after a step that will cause ajax to be called, but this would lead to wasted time as it will sleep for too long or false positives because the ajax took just a little longer this time and ended up loading after your sleep was done. Marc has added some config option called easyAjax, but that just sleeps for two seconds in between steps and sometimes it takes longer than that for our ajax to load. I have created a macro I called ajaxLoad that accepts an implicit element, then the function retries that element 30 times with a sleep of 1 second before the element, so it looks like below:
<macrodef name="ajaxLoad"> <element name="value" implicit="yes"/> <sequential> <retry maxcount="30"> <sleep seconds="1"/> <value/> </retry> </sequential> </macrodef> Then I call the function and pass an xpath that will appear when ajax has finished loading, like below: <ajaxLoad> <verifyXPath xpath="//t...@id='loadedAfterAjaxCall']" description="Wait for ajax to load"/> </ajaxLoad> This way you sleep for the correct amount of time and our ajax always comes back in 30 seconds, and you know that the element you want on the page is actually there. What do people think of this method? Does anyone else have a better way of doing this, so far it appears to be working for me but I haven't used it in too many places as my first attempt on an older build wasn't working correctly and so I just made it sleep for 5 seconds :) Then I got a newer build and decided to try it again in new tests and its been working fine. :) -----Original Message----- From: webtest-ad...@lists.canoo.com [mailto:webtest-ad...@lists.canoo.com] On Behalf Of Robert Fischer Sent: Monday, December 29, 2008 2:03 PM To: webtest@lists.canoo.com Subject: [Webtest] AJAX? What are the best practices for AJAX with Canoo right now? I'm having trouble finding documentation on it. Basically, I've got a site where components are loaded/operated via AJAX calls to the server, and I'd like to use Canoo to functionally test them, but I'm having trouble figuring out how to make that work. ~~ Robert Fischer. Grails Trainining http://www.smokejumperit.com/grails_training.html Smokejumper Consulting http://smokejumperit.com Enfranchised Mind Blog http://enfranchisedmind.com/blog _______________________________________________ WebTest mailing list WebTest@lists.canoo.com http://lists.canoo.com/mailman/listinfo/webtest _______________________________________________ WebTest mailing list WebTest@lists.canoo.com http://lists.canoo.com/mailman/listinfo/webtest