Page 1 of 1

Find, FindSingle and 'partial' ranorexPaths

Posted: Thu Oct 25, 2012 5:29 pm
by jpando
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!

Re: Find, FindSingle and 'partial' ranorexPaths

Posted: Fri Oct 26, 2012 7:43 am
by artur_gadomski
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.

Re: Find, FindSingle and 'partial' ranorexPaths

Posted: Fri Oct 26, 2012 9:15 am
by Support Team
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