Does an object have to be in Repository to use Info? : Automation Tools

Does an object have to be in Repository to use Info?

Ranorex Spy, Recorder, and Studio.

Does an object have to be in Repository to use Info?

Postby winnicki » Thu Nov 03, 2011 11:33 pm

I'm doing web testing and I need to check if an object exists or not. Sometimes it does and other times it does not. I can use try / catch and then it just throws an exception when the path isn't found, but I read on your site that you can do something like this which I think is a better approach:

// Use the 'Info' object to check existence of the
// 'TextOnline' item which uses the following RxPath:
// statusbar/text[@accessiblename='Online']
// This way you can wait with the timeout specified for
// the item within the repository for the text 'Online'
bool statusTextConnected = repo.MyApp.TextOnlineInfo.Exists();

The thing is, I don't actually use the repository that Ranorex. I have my own repository class that contains getter methods for objects. The reason for this is that the Ranorex repository gets too disorganized.
So my question is.. can I still use the Info object on elements if they are not from the ranorex repository?
winnicki
 
Posts: 5
Joined: Wed Sep 14, 2011 6:54 pm

Re: Does an object have to be in Repository to use Info?

Postby Support Team » Fri Nov 04, 2011 1:07 pm

Hi,

You can use the Exists(...) methods of the Validation class, for additional information about the methods please take a look at our online API: Namespaces ► Ranorex ► Validate ► Exists()


Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Does an object have to be in Repository to use Info?

Postby winnicki » Fri Nov 04, 2011 10:17 pm

Perfect, thanks. I did see the Validate.Exists method but most of them are void however I found the one that does return bool and this is what I need.
winnicki
 
Posts: 5
Joined: Wed Sep 14, 2011 6:54 pm

Re: Does an object have to be in Repository to use Info?

Postby Support Team » Mon Nov 07, 2011 7:43 pm

There's more than one way to check for the existence of an object using its RanoreXPath, see this section in the Ranorex User Guide. You can also use the TryFindSingle method:
Element elem;
if (Host.Local.TryFindSingle("/yourPath", out elem))
    ; // element found

Form myApp = ...; // insert code to find the app form
Button button;
if (myApp.TryFindSingle<Button>("pathToButton", out button))
    ; // button found

Regards,
Alex
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation Tools

Who is online

Users browsing this forum: No registered users and 0 guests