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

Bug reports.
staceyb
Posts: 5
Joined: Fri Sep 27, 2013 9:23 pm

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

Post by staceyb » Fri Jan 24, 2014 9:42 pm

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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Fri Jan 24, 2014 10:19 pm

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.
Shortcuts usually aren't...

staceyb
Posts: 5
Joined: Fri Sep 27, 2013 9:23 pm

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

Post by staceyb » Sat Jan 25, 2014 10:44 pm

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?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Mon Jan 27, 2014 3:14 pm

".//" 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.
Shortcuts usually aren't...

staceyb
Posts: 5
Joined: Fri Sep 27, 2013 9:23 pm

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

Post by staceyb » Thu Feb 06, 2014 12:37 am

Thanks krstcs for your reply to this.

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

Thanks,
Stacey

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

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

Post by Support Team » Mon Feb 10, 2014 4:59 pm

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