[Webtest] VerifyElementText and AJAX
Shawn Bradley
Shawn Bradley" <sbradley@sunergeosystems.com
Sat, 15 Sep 2007 18:42:05 -0500
This is a multipart message in MIME format.
------=_NextPart_000_0058_01C7F7C8.1EA8FE60
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
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
------=_NextPart_000_0058_01C7F7C8.1EA8FE60
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal>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:<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><verifyElementText<o:p></o:p></p>
<p class=3DMsoNormal> description=3D"Check login =
results"<o:p></o:p></p>
<p class=3DMsoNormal> htmlId=3D"msgArea"<o:p></o:p></p>
<p class=3DMsoNormal> type=3D"div"<o:p></o:p></p>
<p class=3DMsoNormal> text=3D"success" =
/><o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>fails, because as far as webtest is concerned, the =
DIV is
still blank. The results from webtest are as =
follows:<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>[clickButton] INFO =
(com.canoo.webtest.steps.Step) -
>>>> Start Step: clickButton "Click the submit =
button"
(4/5)<o:p></o:p></p>
<p class=3DMsoNormal>[clickButton] INFO
(com.canoo.webtest.steps.request.AbstractTargetAction) - -> =
gotoTarget by
clickButton with name: null<o:p></o:p></p>
<p class=3DMsoNormal>[clickButton] INFO
(com.canoo.webtest.steps.request.ClickButton) - -> findTarget(by =
input):
name=3DLogin value=3DLogin<o:p></o:p></p>
<p class=3DMsoNormal>[verifyElementText] INFO
(com.canoo.webtest.steps.Step) - >>>> Start Step: =
verifyElementText
"Check login results" (5/5)<o:p></o:p></p>
<p class=3DMsoNormal>[verifyElementText] INFO =
(com.canoo.webtest.steps.Step)
- Running with: Canoo Webtest: R_1551.<o:p></o:p></p>
<p class=3DMsoNormal>[verifyElementText] INFO
(com.canoo.webtest.steps.Step) - Exception thrown from this class:
com.canoo.webtest.engine.StepFailedException<o:p></o:p></p>
<p class=3DMsoNormal>[verifyElementText] INFO
(com.canoo.webtest.steps.Step) - Message was: Wrong contents found in =
HTML
element (type=3D"div", name=3D"null",
htmlId=3D"msgArea")!. Expected value "success" but =
got
""<o:p></o:p></p>
<p class=3DMsoNormal> INFO (com.canoo.webtest.steps.Step) - Running =
with:
Canoo Webtest: R_1551.<o:p></o:p></p>
<p class=3DMsoNormal> INFO (com.canoo.webtest.steps.Step) - =
Exception thrown
from this class: =
com.canoo.webtest.engine.StepFailedException<o:p></o:p></p>
<p class=3DMsoNormal> INFO (com.canoo.webtest.steps.Step) - Message =
was:
Wrong contents found in HTML element (type=3D"div",
name=3D"null", htmlId=3D"msgArea")!. Expected value
"success" but got ""<o:p></o:p></p>
<p class=3DMsoNormal> INFO (com.canoo.webtest.ant.WebtestTask) - =
Finished
executing webtest "UserTest" =
(C:\Projects\PhpWebProjects\ettc\test\canoo\UseCases\UserTest.xml:37:
)<o:p></o:p></p>
<p class=3DMsoNormal> INFO (com.canoo.webtest.ant.WebtestTask) - =
Test report
successfully created.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>I am currently using webtest 2.5 build R_1551, so I =
should
have the latest code for webtest and htmlunit.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>How do I work around this issue?<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Thanks,<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Shawn Bradley<o:p></o:p></p>
<p class=3DMsoNormal>President, Sunergeo Systems, Inc.<o:p></o:p></p>
<p class=3DMsoNormal><a =
href=3D"http://www.sunergeosystems.com">www.sunergeosystems.com</a><o:p><=
/o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
</body>
</html>
------=_NextPart_000_0058_01C7F7C8.1EA8FE60--