Form.Find method return value

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Form.Find method return value

Post by atom » Mon Jul 20, 2009 7:21 pm

Hiya

Quick question about Form.Find method
If I have for example:

myForm.Find("descendants::form[@title='HelloWorld']")

and nothing is found, does the method return an empty list or does it return Nothing ?

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

Re: Form.Find method return value

Post by Ciege » Mon Jul 20, 2009 7:37 pm

You can catch the RanorexException and then have your method return anything you want...

Code: Select all

catch (RanorexException ex)
{
        Report.Debug("Unable to find window: " + WindowName);
        return null;
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: Form.Find method return value

Post by atom » Tue Jul 21, 2009 9:54 am

Hiya

According to the API guide there is no exception from Adapter.Find
But there is a difference between List.Count=0 and Nothing

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Form.Find method return value

Post by Support Team » Tue Jul 21, 2009 10:42 am

Hello Atom,

if you try to find just one element (FindSingle, FindChild, FindDescendant) and no element found, the 'ElementNotFoundException' will be called.
But if you try to find more elements (Find, FindChildren, FindDescendants) and no elements found you will be have an empty list (yourlist.Count=0) but no exception.


Regards,
Mhosen
Ranorex Support Team