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

Ask general questions here.
marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

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

Post by marcushe » Mon Apr 27, 2009 8:35 am

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Mon Apr 27, 2009 4:32 pm

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.

marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

Solved incompletely

Post by marcushe » Tue Apr 28, 2009 3:57 am

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.

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

Post by Support Team » Tue Apr 28, 2009 12:21 pm

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