Page 1 of 1

Form.Find method return value

Posted: Mon Jul 20, 2009 7:21 pm
by atom
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 ?

Re: Form.Find method return value

Posted: Mon Jul 20, 2009 7:37 pm
by Ciege
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;
}

Re: Form.Find method return value

Posted: Tue Jul 21, 2009 9:54 am
by atom
Hiya

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

Re: Form.Find method return value

Posted: Tue Jul 21, 2009 10:42 am
by Support Team
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