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

 

 

 

Reply via email to