Hi, if your asynchronous calls are just made using XMLHttpRequest, you can try this:
<groovy description="setup AJAX calls resynchronizer (this will become the default in WebTest)"> import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController as NRAC step.context.webClient.ajaxController = new NRAC(); </groovy> Nevertheless many AJAX frameworks use setTimeout (with a small timeout value) and start processing from there. Ideally WebTest should detect that and automatically wait until this kind of processing is finished but it's not yet the case. You can try something like <groovy description="wait that setTimeout terminates"> step.context.currentResponse.enclosingWindow.threadManager.joinAll(10000); </groovy> this is better than <sleep seconds="10"/> because it will wait at most ~10 seconds but will complete faster if processing is finished. Please let me know how it behaves. This will help to find what would be the best solution that should be the default in WebTest. Marc. -- Blog: http://mguillem.wordpress.com Shawn Bradley wrote: > I am developing an Ajax application, and Iām using canoo webtest for > integration testing of the UI. I am currently working on the login > screen, so the user is presented with a form requesting > username/password. The credentials are submitted via an Ajax call, and > the response (success/fail) is related via the text inside a DIV > element, which remains hidden until a response occurs. Bottom line ā > there is no form submission, as the action takes place asynchronously ā > which means that the HTML is not updated as a result of a server > roundtrip. Because of this, my verifyElementText call, which looks like > this: > > > > <verifyElementText > > description="Check login results" > > htmlId="msgArea" > > type="div" > > text="success" /> > > > > fails, because as far as webtest is concerned, the DIV is still blank. > The results from webtest are as follows: > > > > [clickButton] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: > clickButton "Click the submit button" (4/5) > > [clickButton] INFO > (com.canoo.webtest.steps.request.AbstractTargetAction) - -> gotoTarget > by clickButton with name: null > > [clickButton] INFO (com.canoo.webtest.steps.request.ClickButton) - -> > findTarget(by input): name=Login value=Login > > [verifyElementText] INFO (com.canoo.webtest.steps.Step) - >>>> Start > Step: verifyElementText "Check login results" (5/5) > > [verifyElementText] INFO (com.canoo.webtest.steps.Step) - Running with: > Canoo Webtest: R_1551. > > [verifyElementText] INFO (com.canoo.webtest.steps.Step) - Exception > thrown from this class: com.canoo.webtest.engine.StepFailedException > > [verifyElementText] INFO (com.canoo.webtest.steps.Step) - Message was: > Wrong contents found in HTML element (type="div", name="null", > htmlId="msgArea")!. Expected value "success" but got "" > > INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1551. > > INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class: > com.canoo.webtest.engine.StepFailedException > > INFO (com.canoo.webtest.steps.Step) - Message was: Wrong contents found > in HTML element (type="div", name="null", htmlId="msgArea")!. Expected > value "success" but got "" > > INFO (com.canoo.webtest.ant.WebtestTask) - Finished executing webtest > "UserTest" > (C:\Projects\PhpWebProjects\ettc\test\canoo\UseCases\UserTest.xml:37: ) > > INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully > created. > > > > I am currently using webtest 2.5 build R_1551, so I should have the > latest code for webtest and htmlunit. > > > > How do I work around this issue? > > > > Thanks, > > > > Shawn Bradley > > President, Sunergeo Systems, Inc. > > www.sunergeosystems.com <http://www.sunergeosystems.com> _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

