Hi Clint, When I look at that source, it doesn't look like *any* object has an id of 'genTabViewId:genTabFrm:availableGroups:source::0'. There is an object with a @name of 'genTabViewId:genTabFrm:availableGroups:source::0', but that is an <input>...
Perhaps the id="" attribute is not escaped properly (and the engine has to drop it). The valid characters for an ID attribute in HTML 4.01 are /[a-z][a-z0-9:-_\.]*/i, so it's not that the id attribute is incorrect - likewise, <tr>s are allowed in HTML 4.01 to have id attributes. In fact, *none* of the elements in that XML source have an id attribute. Interesting. Jevon On Sat, Aug 18, 2012 at 1:19 AM, Parham, Clinton <cpar...@biosignia.com> wrote: > Hi Julien, > > Thank you for replying. > > I have attached the asXML dump of the page after Thread.sleep(10000) to > account for AJAX activity. > > When I open the dumped content in Chrome and enter the following into the > JavaScript console, the "tr" I'm trying to click is found: > $x("//tr[@id='genTabViewId:genTabFrm:availableGroups:source::0']") > > Looking forward to your perspective. > > Clint > > -----Original Message----- > From: Julien HENRY [mailto:henr...@yahoo.fr] > Sent: Friday, August 17, 2012 3:25 AM > To: Usage problems for JWebUnit > Subject: Re: [JWebUnit-users] clickElementByXPath failing > > Hi, > > I've just tested to locate a tr element by id using the same xpath expression > and it is working fine. Are you not encountering timing issue? If you are > using AJAX to update the page there could be different results depending on > execution speed. > > Concerning diference between getPageSource and asXml Jevon is right: > getPageSource returns the original source returned by the server while asXml > is a dump of the current state of the DOM. > > Could you please send us the result of asXml() when your test failed? > > Regards, > > Julien > > > ----- Mail original ----- >> De : "Parham, Clinton" <cpar...@biosignia.com> >> À : Usage problems for JWebUnit <jwebunit-users@lists.sourceforge.net> >> Cc : >> Envoyé le : Vendredi 17 août 2012 4h57 >> Objet : Re: [JWebUnit-users] clickElementByXPath failing >> >> When executing getElementsByXPath("//tr") I get back 88 matches. >> >> But it gets more interesting: >> >> The following (from my original clickElementByXPath) returns zero matches: >> getElementsByXPath("//tr[@id='genTabViewId:genTabFrm:availableGroups:source::0']"); >> >> But this returns what I'm looking for (only changed "tr" to >> "*"): >> getElementsByXPath("//*[@id='genTabViewId:genTabFrm:availableGroups:source::0']"); >> >> This is what the debugger returns when Inspecting the return value of the >> above >> statement - you can see it is a "tr": >> [IElement[name=tr wrapped=HtmlTableRow[<tr >> class="rich-picklist-source-row" >> id="genTabViewId:genTabFrm:availableGroups:source::0">]]] >> >> I would expect consistent results when calling both of these >> getElementsByXPath >> methods. What's going on? >> >> Thanks. >> >> -----Original Message----- >> From: jevon [mailto:je...@jevon.org] >> Sent: Thursday, August 16, 2012 8:56 PM >> To: Usage problems for JWebUnit >> Subject: Re: [JWebUnit-users] clickElementByXPath failing >> >> Hi, >> >> I can't look at the JWebUnit source right now, but it sounds like >> getPageSource() just dumps out the original source of the page, i.e. >> without Javascript DOM modifications, whereas page.asXml() dumps the >> runtime content of the page itself, i.e. after Javascript/AJAX has >> modified the page. Or perhaps the source page does not validate, thus >> some of the elements are lost. >> >> What happens if you execute getElementsByXPath("//tr")? >> >> Cheers >> Jevon >> >> On Fri, Aug 17, 2012 at 8:47 AM, Parham, Clinton <cpar...@biosignia.com> >> wrote: >>> Hello, >>> >>> We're using JWebUnit 3 to test a JSF web application that uses JBoss >> RichFaces AJAX enabled components. >>> >>> At one point in the test, a call to >> clickElementByXPath("//tr[@id='genTabViewId:genTabFrm:availableGroups:source::0']") >> is made but it fails with this: >>> >>> java.lang.AssertionError: Unable to locate element with xpath >> "//tr[@id='genTabViewId:genTabFrm:availableGroups:source::0']" >>> at org.junit.Assert.fail(Assert.java:91) >>> at org.junit.Assert.assertTrue(Assert.java:43) >>> at >> net.sourceforge.jwebunit.junit.WebTester.assertElementPresentByXPath(WebTester.java:2109) >>> at >> net.sourceforge.jwebunit.junit.WebTester.clickElementByXPath(WebTester.java:2673) >>> at >> com.xyz.util.EnrollmentUtil.setGeneralTabFields(EnrollmentUtiljava:165) >>> ... >>> >>> Just before making the clickElementByXPath call, we execute >> Thread.sleep(5000) to account for AJAX activity and then we dump the page >> content two ways to see what's going on: >>> [1] FileUtils.writeStringToFile(new File(filename), getPageSource()); >>> and >>> [2] HtmlUnitTestingEngineImpl engine = (HtmlUnitTestingEngineImpl) >> getTestingEngine(); >>> HtmlPage page = ((HtmlPage) engine.getCurrentWindow().getEnclosedPage()); >>> FileUtils.writeStringToFile(new File(filename), page.asXml()); >>> >>> The dumps are different which is quite surprising. When viewing the file >> generated by method [1] in Chrome, the "tr" element is not present. >> But it is present when viewing the file generated by method [2]. >>> >>> What is happening? >>> >>> >>> The contents contained herein may contain confidential information. If you >> are not the intended recipient, you are hereby notified that any disclosure, >> copying, distribution, printing or action taken on the contents is strictly >> prohibited. If you have received this email in error, please notify the >> sender >> immediately and delete this message. >>> >>> >> ------------------------------------------------------------------------------ >>> Live Security Virtual Conference >>> Exclusive live event will cover all the ways today's security and >>> threat landscape has changed and how IT managers can respond. Discussions >>> will include endpoint security, mobile security and the latest in malware >>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >>> _______________________________________________ >>> JWebUnit-users mailing list >>> JWebUnit-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/jwebunit-users >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> JWebUnit-users mailing list >> JWebUnit-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jwebunit-users >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> JWebUnit-users mailing list >> JWebUnit-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jwebunit-users >> > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > JWebUnit-users mailing list > JWebUnit-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jwebunit-users > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > JWebUnit-users mailing list > JWebUnit-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jwebunit-users > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ JWebUnit-users mailing list JWebUnit-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-users