Find, FindSingle and 'partial' ranorexPaths

Ask general questions here.
jpando
Posts: 1
Joined: Thu Oct 25, 2012 5:16 pm

Find, FindSingle and 'partial' ranorexPaths

Post by jpando » Thu Oct 25, 2012 5:29 pm

There is something that I want to do, but I don't know if it's possible. I have a WebDocument (although the general question could also apply to a Form, I think) that I've gotten via the command:

WebDocument myWebDocument = "/dom[@domain='172.22.33.44']";

Now I want to find a flex element that is deep in the hierarchy of the dom. I know the element I'm looking for is unique in the sense that it has a unique ID attribute. What I'd LIKE to do is issue a command like:

Ranorex.FlexElement elem = myWebDocument.FindSingle["checkbox[@id='myUniqueID']");

However, this doesn't work. It only seems to work if I put in the long path ("body/flexobject/container/container/container...").

So, is there a way to just really zero in on the element the way I've described (with less than a full path), regardless of the container hierarchy?

Thanks!

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Find, FindSingle and 'partial' ranorexPaths

Post by artur_gadomski » Fri Oct 26, 2012 7:43 am

Try:
Ranorex.FlexElement elem = myWebDocument.FindSingle[".//checkbox[@id='myUniqueID']");
And read this to learn more about RxPath:
http://www.ranorex.com/support/user-gui ... xpath.html

EDIT:
Fixed example according to input from Support.
Last edited by artur_gadomski on Fri Oct 26, 2012 11:08 am, edited 1 time in total.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Find, FindSingle and 'partial' ranorexPaths

Post by Support Team » Fri Oct 26, 2012 9:15 am

IMHO you have a small error in your sample, relative paths must not start with a "/", because that makes paths absolute, not relative. If you want to use the "//" operator, make sure to use ".//" which signals that you want to use the operator relatively.

You sample should be:
Ranorex.FlexElement elem = myWebDocument.FindSingle<Ranorex.FlexElement>(".//checkbox[@id='myUniqueID']");
Regards,
Alex
Ranorex Team