[ptt-users] Xpath issue

Olivier Dony olivier.dony at denali.be
Fri Sep 28 01:07:41 PDT 2007


On Sep 27, 2007, at 11:41 AM, bl8cki wrote:

> Really thanks for your quick answer.
>
> So if i understand you right ... when i make for example a new  
> functional test in TestMaker and there i include a test
> that was made with testgen4web i can use real xpath expressions.
> I put in mytest.testgen4web something like this:
>
> <action type="click" step="4">
>   <xpath><![CDATA[//a/span[text()="Name" and @class="name"]]]></xpath>
>   <value><![CDATA[]]></value>
> </action>
>
> and when i run this functional test with the mytest.testgen4web  
> test case, i look at the
> LocalTest Node Output and there i see:
>
> oldXpath  //a/span[text()="Name" and @class="name"]: newXpath "//// 
> span[text()="Name" and @class="name"]"
> which is not valid (and the 'a' is gone) and because of this  
> org.jaxen.XPathSyntaxException: Location path cannot end with //
>
> What can i do? And am i doing things right?

Yes, this is what I meant, but apparently there is another issue  
here :-(
When you change the XPath produced by TestGen4Web, it is still run  
through the conversion layer of TestMaker, to make sure it is really  
XPath.

This is done by TestGenForWeb.normalizeXPath(). You can have a look  
at it if you're interested:
    http://cvs.pushtotest.com/cgi-bin/cvsweb.cgi/tm5/TestMaker/src/ 
com/pushtotest/testmaker/XSTest/client/TestGenForWeb.java?annotate=HEAD

The converter doesn't care whether the expression is real XPath or  
pseudo-XPath, and applies its algorithm anyway.
So you can indeed modify the XPath produced by TG4W, but I guess you  
need to make it look like pseudo-XPath.

I hope this will be improved in the future, but if you need to make  
it work right now you should be able to, by following a few rules,  
such as:
   - use "*/" instead of "//" at the beginning of your XPath
   - do not refer to elements without predicates,
     e.g /a/ will be replaced by a single "/", while "/a[1]/" will be  
preserved
   - never use forward slash "/" characters within your predicates

Thus you might have better luck with something like:
       */a[true()]/span[text()="Name" and @class="name"]


Cheers,



--
Olivier Dony,

Denali s.a., "Bridging the gap between Business and IT"
Rue de Clairvaux 8, B-1348 Louvain-la-Neuve, Belgium
Office: +32 10 43 99 51  Fax: +32 10 43 99 52
www.denali.be

Legal Notice: This message may contain confidential and/or privileged  
information. If you are not the addressee or authorized to receive  
this for the addressee, you must not use, copy, disclose or take any  
action based on this message or any information herein. If you have  
received this message by mistake, please advise the sender  
immediately by return e-mail and delete this message from your  
system. Thank you for your cooperation.




More information about the Users mailing list