Page 1 of 1

How to speed up the lookup for a ui element?

Posted: Mon May 21, 2018 8:05 pm
by hghesani
Hi

I am interested in learning how I can use ranrorex so that lookup for an element is quicker than it currently is. Essentially, I would like to know if the element with a certain charecteristic exists or not :

For eg, I am looking for an element with unknown row index and known text, and the code tries look for this item by looking if the item exists with different values of row id.
within for loop, search till you find:
{
RepoItem = ..?/?/row[@index=$rownumber]/cell[@text="<known text string>"];
if(RepoItem.Exists)
{
break;
}
}

I cannot use just the text string to identify that element, since there are multiple entries in the same table and I need to search for that cell within certain range of indices to find it. RepoItem.Exists, takes some time to confirm if the element exists or not, how can I shorten this time.

Please let me know

Re: How to speed up the lookup for a ui element?

Posted: Tue May 22, 2018 7:19 am
by odklizec
Hi,

Unfortunately, without seeing your app or at very least Ranorex snapshot (NOT screenshot) of the problematic table, there is not much anyone here can do or suggest. Any chance you can provide us with either working sample or snapshot?

Re: How to speed up the lookup for a ui element?

Posted: Tue May 22, 2018 6:42 pm
by hghesani
odklizec wrote:Hi,

Unfortunately, without seeing your app or at very least Ranorex snapshot (NOT screenshot) of the problematic table, there is not much anyone here can do or suggest. Any chance you can provide us with either working sample or snapshot?
Hi

Its a table with various elements coded using mfc. The absolute of the element being looked for would be

/form[@title='<knowntitle>' and @processname='<knownprocessname>'' and @class='<knownstring>']/?/?/row[@index='<unknownindex>']/cell[@text>'<known text name>']


If know the row index I can find this. This is the xpath I need to use to confirm if the element exists or not. It takes a long time to confirm that the element does not exist , if the index provided is not the correct one. I am trying to look for the element, with various values of @index so that i can find the right walue of @index, for which this element exists.

Would this help ?

Thanks,

Re: How to speed up the lookup for a ui element?

Posted: Thu May 24, 2018 8:10 am
by odklizec
Hi,

There is no way to speed-up the lookup for an element. I mean, the speed of search depends on the quality of xpath. If the xpath is unique enough, the speed of search should be relative quick. However, if the element does not exists, Ranorex tries to search for the element its entire Effective Timeout, which is a sum of all Search Timeouts of all parents above the actual element. The only way how to "speedup" Exists method is to add a timeout parameter, like this...

Code: Select all

...
if(RepoItem.Exists(30000))
...
But remember that too short timeout could return incorrect result, because if the timeout is too short, Ranorex may not find an existing element ;)

Re: How to speed up the lookup for a ui element?

Posted: Fri Jun 01, 2018 8:12 pm
by hghesani
Thanks, that certainly helps !!! Additional question, how does caching a ui element affect this ? Is there a way to enable/disable caching when code is executed or within a code module.

Thanks,

odklizec wrote:Hi,

There is no way to speed-up the lookup for an element. I mean, the speed of search depends on the quality of xpath. If the xpath is unique enough, the speed of search should be relative quick. However, if the element does not exists, Ranorex tries to search for the element its entire Effective Timeout, which is a sum of all Search Timeouts of all parents above the actual element. The only way how to "speedup" Exists method is to add a timeout parameter, like this...

Code: Select all

...
if(RepoItem.Exists(30000))
...
But remember that too short timeout could return incorrect result, because if the timeout is too short, Ranorex may not find an existing element ;)

Re: How to speed up the lookup for a ui element?

Posted: Mon Jun 04, 2018 8:05 am
by odklizec
Hi,

I'm not quite sure, if there is a way to globally disable cache for all (already generated) repo elements? I think you will have to do it element by element. The code to disable cache looks like this:

Code: Select all

repo.FolderName.UseCache=false;
Enabled cache should improve the speed of search for element. So if you disable it, it may slow the search ;)

Re: How to speed up the lookup for a ui element?

Posted: Tue Jun 05, 2018 7:50 am
by ethanscott
odklizec wrote:Hi,

I'm not quite sure, if there is a way to globally disable cache for all (already generated) repo elements? I think you will have to do it element by element. The code to disable cache looks like this:

Code: Select all

repo.FolderName.UseCache=false;
Enabled cache should improve the speed of search for element. So if you disable it, it may slow the search ;)
Will this involve the cache memory of the system or create a false cache using the permanent memory?

Re: How to speed up the lookup for a ui element?

Posted: Tue Jun 05, 2018 8:21 am
by odklizec
Hi,

To be honest, I don't have a clue? I guess it simply stops caching elements under pointed repo folder and every time the folder is accessed, Ranorex refreshes its content.