[ptt-users] TestGen4Web and HTMLunit: difference in behaviour?
Dominique de Waleffe
dominique.dewaleffe at denali.be
Fri Jul 6 06:03:56 PDT 2007
Continuing my explorations of TM5-B2,
In the script I recorded, tg4w wrote:
<xpath><![CDATA[*/TABLE[1]/TBODY[1]/TR[3]/TD[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/*/A[@CDATA="Select
Project"]]]></xpath>
as selector. When I run the script in Firefox with recorder, it runs
successfully, however, when run through htmlunit, I get a null pointer
exception in the click action ( TestGenForWeb.java:153: prints Elem null)
I suspect the difference of behaviour (in this case) may be linked to
the treament of white space around the text of interest. Could the
translation of @cdata=value be more liberal in what it matches as text?
at least, stripping the white space around the contents.
So it looks like the behaviour is different and thus the xpaths recorded
are not reliable when run under htmlunit. This is annoying...
I then tried to record the xpath directly using xpather (FF extension)
and plug it into the script definition. This lead to an other type of
problem: the normalizeXpath() is not very robust when presented an XPATH
not coming from TG4W (it fails if an element does not have a [, or if
values are delimited with single quotes).
Examples:
1)
oldXpath
*/div[@id="PageContainer"]/div[@id="content"]/*/tr[3]/*/td[1]/table/tbody/tr/td/span/a
newXpath "//div[@id="PageContainer"]/div[@id="content"]//tr[3]//td[1]//////"
Error getting page Expected one of '.', '..', '@', '*', <QName>
org.jaxen.XPathSyntaxException: Expected one of '.', '..', '@', '*', <QName>
2)
if the path contains div[@id='PageContainer'] then the line
sb.append(subPart.substring(subPart.indexOf("="),atIndex+1));
throws an invalid index exception (since we have been looking for ")
Any ideas on how to address this issue globally?
D.
--
Dominique de Waleffe
More information about the Users
mailing list