Page 1 of 1

How do i use validate.Exists(element,message,boolean)

Posted: Mon Apr 27, 2009 8:35 am
by marcushe
Working Evironment: win7 ,Ranorex2.02
Step:

To judge whether a form exist , we can use
Try
{
....Form action
}
Catch()
{
}
.
But seems validate.Exists also offer a way . So i use Exists like this
if (Ranorex.validate.Exists(repo.SimpleModel.Self,"xx",false)==false)
{
}

According to usage in UserGuide , set boolean to false should not provoke an exceptioin . Actually, when program run to if() , and the form does not exist ,it will throw out an exception , which state the form does not exist

Posted: Mon Apr 27, 2009 4:32 pm
by Ciege
See the code I pasted in this thread: http://www.ranorex.com/forum/waiting-fo ... -t775.html

It may help you out a bit on how to deal with the potential exception if a window/form does not exist.

Solved incompletely

Posted: Tue Apr 28, 2009 3:57 am
by marcushe
I use Validate.Exists(repo.SimpleMode.self,"{0}",false) , it can pass.
But if repo.SimpleMode not exist ,before invoke Validate.Exists return, Ranorex still throw out an exception.

Posted: Tue Apr 28, 2009 12:21 pm
by Support Team
Unfortunately, the Validate.Exists method does not really work as expected when calling it as you described:
Validate.Exists(repo.SimpleMode.self,"{0}",false)
The problem why Ranorex throws an exception is, because of the statement repo.SimpleMode.Self specified as first parameter. The Ranorex Repository tries to resolve the RanoreXPath expression behind the repository object automatically and throws an 'ElementNotFoundException' before getting a chance to do the exists validation. We'll try to offer a better solution with the future releases.

best regards,
Christoph
Ranorex Support Team