Page 1 of 1

Why the difference in search times?

Posted: Wed Feb 17, 2010 10:09 pm
by Ciege
With the following two lines of code why the difference in search times?

#1

Code: Select all

Ranorex.Table HDTable = HDReportsForm.FindSingle(".//element[@controlname='gridItems']/table[@accessiblerole='Table']", 180000);
#2

Code: Select all

Ranorex.Table HDTable2 = HDReportsForm.FindSingle(".//table[@accessiblerole='Table']", 180000);
All things being equal,
#1 routinely takes around 2 minutes to find the table in my AUT.
#2 routinely takes less than 20 seconds to find the table in my AUT.



Similarly, if I do this, the element and table are usually found in less than 20 seconds.

Code: Select all

Ranorex.Core.Element HDElement = HDReportsForm.FindSingle(".//element[@controlname='gridItems']", 180000);
Ranorex.Table HDTable = HDElement.FindSingle(".//table[@accessiblerole='Table']", 180000);
Thanks!

Re: Why the difference in search times?

Posted: Tue Feb 23, 2010 4:08 pm
by Support Team
hey Ciege,

Sorry for the late answer.

Searching for
".//element[@controlname='gridItems']/table[@accessiblerole='Table']"
looks through *everything* for the element with controlname gridItems, and then looks beneath for the matching table. If one is found, the search is complete.

Splitting it up (like you do in the last sample), causes the search for the gridItems element to be finished after a single matching element has been found.

This behavior is caused by the fact that the steps in the RxPath match a set of items, not only a single item, and the "FindSingle" optimizes only the last step, because there might be different "gridItem" elements somewhere...

There is currently room for improvement, so stay tuned :D

Generally, "//" should be used with great care because this is usually very expensive. So splitting up the search if you are looking for a single element with "//" is a really good idea (if "//" is not the last step in the search)

Michael
Ranorex Team