Page 1 of 1

Validate.NotExists works differently than expected

Posted: Wed Dec 16, 2009 10:47 am
by Marianne Jacobsen
I have a scenario where I'd like to use Validate.NotExist but it works in a way that I didn't expect. This might of couse be by design but I wanted to ask anyway.

So Validate.Exists returns as soon as the control exists or times out. So I would expect Validate.NotExist to do the exact opposite - e.g. return as soon as the control does not exist (this might be right away) or time out (if the controls exists the entire timespan). But this is not how Validate.NotExist works - if the control/element doesn't exist it will wait the entire duration for the control and then return.

Hope you understand my explanation.

If this is how it's intended to behave then just ignore my post :)

Re: Validate.NotExists works differently than expected

Posted: Wed Dec 16, 2009 4:39 pm
by Ciege
I don't know exactly but I assume this is correct.
The entire AUT (or even the entire local host) need to be search for the control. This can take some time, thus checking until timeout.

Assume this. If it takes 10 seconds to find a specific control in your AUT, but Validate.NotExist just looks for 9 seconds it could return a TRUE that the control does not exist, even if it does exist. So by checking until the end of the timeout is prudent in making sure that the control does not exist and cannot be found within the timeout selected.

With Validate.Exist Ranorex only has to find the control. As soon as it does find it we have a valid state and the search can be called off immediately.

Make any sense?

Re: Validate.NotExists works differently than expected

Posted: Wed Dec 16, 2009 4:42 pm
by Ciege
Just a follow up...

If you already know the RanorexPath to the object that was validated by .Exist you do not *need* to use the .NotExist method. You can write your own method that just checks the .Valid or .Visible (or some other) property of the known RanorexPath yourself. This will be a very quick check and can return true/false to you almost immediately.

Re: Validate.NotExists works differently than expected

Posted: Thu Dec 17, 2009 4:49 pm
by Support Team
As Ciege already pointed out, the Validate.NotExists behavior is by design.

You can easily create your own version of NotExists by using the Adapter.TryFindSingle method without specifying a timeout, that way Ranorex will only search once for the specified element and return true if it exists, false otherwise.

Regards,
Alex
Ranorex Support Team