Hi all,
Another quick question. I have some javascript/JQuery that is creating an
img
dynamically. I tried using the assertElementPresentByXPath()method but that is
not behaving as expected. For example, I have an Ajax call that builds the img
tag as follows:
xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &&
xmlhttp.status==200) { try { tableHTML =
"<h2>Administrators <img
id=\"inviteAdmin\" title=\"Invite an administrator\" class=\"clickable\"
src=\"images/icon_envelope.png\" onclick=\"showInviteAdministrator();\"
width=\"48\" height=\"48\" alt=\"Invite administrator\"></img></h2><table>";
result = JSON.parse(xmlhttp.responseText);
My JWebUnit test file then tries the following assert:
assertElementPresentByXPath("//i...@src='images/icon_envelope.png']");
Here is the resulting (truncated) trace when the assert fails:
junit.framework.AssertionFailedError: Unable to locate element with xpath
"//i...@src='images/icon_envelope.png']" at
junit.framework.Assert.fail(Assert.java:47) at
junit.framework.Assert.assertTrue(Assert.java:20) at
net.sourceforge.jwebunit.junit.WebTester.assertElementPresentByXPath(WebTester.java:2034)
at
net.sourceforge.jwebunit.junit.WebTestCase.assertElementPresentByXPath(WebTestCase.java:1619)
Now I am reasonably good with XPath, but I also know how finicky it can be and
how easy it is to overlook something. Here are my questions:
* Am I even going about this the right way?
* Can JWebUnit handle dynamic elements created by javascript?
* Is this something HtmlUnit is better suited?
Thanks in advance for your help.
- Jeff
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users