Page 1 of 1

Does // start from root of DOM or from adapter before it?

Posted: Fri Jan 24, 2014 9:42 pm
by staceyb
Hi,

Have a question about Ranorex path syntax and was wondering if below is by design
or is it a bug.
Using Track in Ranorex on an element on my page the following
path was associated with my element.

Ranorex spy created:
body/div[4]/form[@id='aspnetForm']//div[@id='widget_UsersLoggedIn']

Normally I would use:
body/div[@class='container_16 wrapper']/.//div[@id='widget_UsersLoggedIn']

The documentation says:
//button
identifies all buttons that are descendants of the root element, i.e. all buttons in all levels of the element tree

So does // always start from the root element even when // is in the middle of a ranorex path or does it
refer to the adapter before the //?

Thank you,
Stacey

Re: Does // start from root of DOM or from adapter before it?

Posted: Fri Jan 24, 2014 10:19 pm
by krstcs
In this case the "root" element is the adapter just before the "//" in the path.

Root in this case is used to refer to the parent (usually a repository folder) of the object. Each object is rooted from it's parent object, so all children of an object (a folder or base object such as a /dom) share a common root.

Re: Does // start from root of DOM or from adapter before it?

Posted: Sat Jan 25, 2014 10:44 pm
by staceyb
Thanks for your reply.
So to clarify further in the case of
Ranorex spy created:
body/div[4]/form[@id='aspnetForm']//div[@id='widget_UsersLoggedIn']

The root element is orm[@id='aspnetForm']

and my ranorex path of
body/div[@class='container_16 wrapper']/.//div[@id='widget_UsersLoggedIn']

could be changed to:
body/div[@class='container_16 wrapper']//div[@id='widget_UsersLoggedIn']
and the root element would be div[@class='container_16 wrapper'], correct?

Re: Does // start from root of DOM or from adapter before it?

Posted: Mon Jan 27, 2014 3:14 pm
by krstcs
".//" means the same thing in this context as "//". XPath is not like directory pathing, so you can't think of it the same way.

Everything is pathed from the element in the path just to the left, so in the example you posted, it means exactly the same thing.

The ".\\" requires a search for div to start from the parent "form" object, where as the "\\" doesn't. So the "\\" can be used without having to have a parent, but the ".\\" requires a parent in the absolute path (either a parent in the object's direct path, or a repository parent).

At least that is my understanding.

Re: Does // start from root of DOM or from adapter before it?

Posted: Thu Feb 06, 2014 12:37 am
by staceyb
Thanks krstcs for your reply to this.

Was wondering if Ranorex support could also confirm for our team at lynda.com.

Thanks,
Stacey

Re: Does // start from root of DOM or from adapter before it?

Posted: Mon Feb 10, 2014 4:59 pm
by Support Team
Hello staceyb,
As krstcs already mentioned, “//” starts the search from (his parent) the element left of “//”, whereas “.//” finds all elements which are descendants of the current element.
In both cases your root element is div[@class=’container_16 wrapper’] and the search will be started from this point.

Regards,
Markus