BUG: .Exists() does not respect Search Timeout setting

Bug reports.
carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

BUG: .Exists() does not respect Search Timeout setting

Post by carsonw » Wed Sep 11, 2013 9:40 pm

Not sure if this is a bug or a feature (and I don't believe it's specific to 4.1), but it doesn't make a lot of sense to me.

The follow code will wait two seconds for the object to be present

Code: Select all

bool receiptButtonVisible = Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.Self.TryFindSingle(Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.ButtonViewReceiptInfo.Path,  new Ranorex.Duration(2000), out receiptButton);       
With a Search Timeout of 2000ms on the repository properties for item Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.ButtonViewReceipt, the following code will wait about 30 seconds:

Code: Select all

bool receiptButtonVisible = Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.ButtonViewReceiptInfo.Exists();
Am I misunderstanding how search timeout works? If I am, is there a way to change the wait time for Exists()?

If I'm not, then it seems like a bug - thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: BUG: .Exists() does not respect Search Timeout setting

Post by Support Team » Thu Sep 12, 2013 5:21 pm

Hello,

The 'Search Timeout' property defines the amount of time an element will be searched for before an exception is thrown. You would also need to consider the 'Effective Timeout' of your repository item.
The 'Effective Timeout' is a total of all 'Search Timeouts' in the repository hierarchy.

Please take a look at our User Guide for more information.

Regards,
Markus (T)
.
Image

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: BUG: .Exists() does not respect Search Timeout setting

Post by carsonw » Fri Sep 13, 2013 5:41 pm

Right - but the effective time out works like this, right:

The parent item has a time out of 30 seconds.
The child item has a time out of 5 seconds.

My effective timeout is 35 seconds.

If I'm searching for the child item AND the parent item exists but the child time item does not, then I would expect .Exists() to time out after 5 seconds.

This is not what's happening.

mojohlic
Posts: 31
Joined: Thu Oct 11, 2012 4:37 pm

Re: BUG: .Exists() does not respect Search Timeout setting

Post by mojohlic » Fri Sep 13, 2013 11:02 pm

I didn't see an answer about this ... anybody?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: BUG: .Exists() does not respect Search Timeout setting

Post by Support Team » Tue Sep 17, 2013 4:42 pm

Hello,

The reason for that behavior is the caching functionality in Ranorex.
If there are no relevant repository items cached for the button ('ButtonViewReceipt'), Ranorex uses the absolute path in order to search the element.
There could be several reasons that Ranorex is not able to find an element (in your case the button 'ButtonViewReceipt'). For example, it could be that the parent element cannot be found or that the button itself cannot be found. Ranorex cannot decide at this point which element cannot be found and that's the reason that Ranorex searches until the effective timeout is reached.

For example, if you check the existence of the parent element before you check if the button is available you will see that Ranorex will stop searching after the search timeout of the button item is reached (in your case 5 seconds). The reason is that the parent element was already added to the cache.

Please try to use the following code:
Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.SelfInfo.Exists();  
bool receiptButtonVisible = Repositories.History.Instance.PagePaymentHistory.FramePaymentDetails.ButtonViewReceiptInfo.Exists();
I hope I could clarify the situation.

Regards,
Markus (T)
.
Image

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: BUG: .Exists() does not respect Search Timeout setting

Post by carsonw » Tue Sep 17, 2013 10:17 pm

Ok - I checked the settings in our repository and "Use Cache" is set to true for the parent item (and it's timeout is set to 30s) - I checked the time out of the ButtonReceipt and it's set to 2000ms (so the effective timeout is 32 seconds).

I know for certain that the parent item is visible (it's the whole page itself) and that the child item is not... yet still it's waiting for the entire time.

It seems strange to have to check for the parent exists first to get it into the cache.. and on more complicated repositories this could become cumbersome (which if it's three rooted folders level down for example, do I have to add that exists for each level?). Shouldn't that step be unnecessary by virtue of having Use Cache" set to true?

I guess I think of Ranorex working like this:
Parent item exists? TRUE - no need to wait 30 seconds, I know this instantly
Child item exists? FALSE - I will look for 2 seconds to if it's there. No need to wait the 30 seconds for the parent item as I know it's TRUE.

I'm assuming it doesn't actually work that way, but if that's the case then what's the intended use of Use Cache?

We use this quite a bit for negative testing (fields appearing/disappearing and so forth), so you can imagine it takes are tests a LOT longer to run than it should.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: BUG: .Exists() does not respect Search Timeout setting

Post by Support Team » Wed Sep 18, 2013 4:23 pm

Hello,
I know for certain that the parent item is visible (it's the whole page itself)
This does not mean that the item and the path to the item was added to the cache.
Only if the parent item or an item within the parent folder was used and found during the test the parent folder is added to the cache.
It seems strange to have to check for the parent exists first to get it into the cache.
This is only necessary if no item was used during the test and the parent doesn't exist in the cache.
which if it's three rooted folders level down for example, do I have to add that exists for each level?
No, if one of the child elements was found all repository level down should be added to the cache.
Parent item exists? TRUE - no need to wait 30 seconds, I know this instantly
Child item exists? FALSE - I will look for 2 seconds to if it's there. No need to wait the 30 seconds for the parent item as I know it's TRUE.
Only if the parent item was added to the cache Ranorex knows that this item already exists. If Ranorex has never searched the Parent element Ranorex has no idea which item cannot be found. That's the reason that Ranorex uses the effective timeout in order to search for the item.
I'm assuming it doesn't actually work that way, but if that's the case then what's the intended use of Use Cache?
If the setting "Use Cache" is disabled no items will be added to the cache and Ranorex will use the effective timeout for each element.

I hope I could answer your questions.

Regards,
Bernhard
.
Image

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: BUG: .Exists() does not respect Search Timeout setting

Post by carsonw » Wed Sep 18, 2013 5:13 pm

Ok thanks - yes this does shed some light on the functionality, but I must admit I find the implementation a bit disappointing.

This means that I have tie my code the repository more closely than I'd like and I have to take some steps that seem unnecessary to me.

Essentially, I have to always look for at least the topmost item in the repository, or the immediate parent of the child I'm looking for. However, if my repository structure changes, then I also have to update my .exists() accordingly (i.e. look for a different parent). Basically the calls in my code now depend on the structure of my repository and I don't think that's right.

Aside from that, it does feel a bit counterintuitive. I understand how it works now that you've explained it, however you would think having rooted folders would mean finding the parent first and then finding the children beneath, instead of still using the absolute path each time. When I explained the functionality to my team the response was universal - it doesn't seem that Use Cache has much value then. I don't know if I would agree with that, it's probably more accurate to say that it doesn't work in the way we had expected (doesn't mean it's wrong), and the functionality it provides is more limited than we had hoped.

Given this information, we would have to change our approach a little bit if we are to use the timeouts in the way that we had wanted. At least now I understand why the waits have always been so long...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: BUG: .Exists() does not respect Search Timeout setting

Post by Support Team » Fri Sep 20, 2013 4:24 pm

Hello,

I am glad that I could clarify how Ranorex works. I understand that in your case another approach would be better, but Ranorex was designed to find elements and to execute actions on that items above all.
We will discuss the issue internally and we will analyze if there is a way in order to provide a feature in a future version.
However, thank you for your input!

Regards,
Bernhard
.
Image

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: BUG: .Exists() does not respect Search Timeout setting

Post by carsonw » Mon Sep 23, 2013 5:14 pm

Thanks so much for your help! I was able to convey the correct functionality to my team, so we're adjusting our approach accordingly.

If you find a better (different?) way to approach it and implement, be sure and let us know! :)