TryFindSingle or TryFindFirst - Feature

Bug reports.
jainaakash
Posts: 48
Joined: Thu Jun 10, 2010 12:06 pm

TryFindSingle or TryFindFirst - Feature

Post by jainaakash » Thu Nov 18, 2010 6:59 am

Hi Ranorex Team,

I just realized that the TryFindSingle returns the first element found or false if no element is found.
I assumed the function to return false if it failed to find a single (unique) element and return TRUE ONLY if it finds a single(unique) element. So, for me this function is actually TryFindFirst and NOT TryFindSingle.

For example,
if we have two forms with names abc and abcd,
tryfindsingle - /form[@name~'abc.*']
will return true and will identify the first form found. This is not I would have expected from the method. The problem is I would not know in somecases, if the incorrect input was selected using tryfindsingle with regular expressions / wildcards.

Hope you understood my concern. Any inputs / thoughts are appreciated.
Let me know if you need more details.

Thanks and Regards,
Aakash

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: TryFindSingle or TryFindFirst - Feature

Post by artur_gadomski » Thu Nov 18, 2010 8:45 am

Isn't Find() what you're looking for? As I understand it returns a list of elements found. Then all you need to do is check if Count == 1.

jainaakash
Posts: 48
Joined: Thu Jun 10, 2010 12:06 pm

Re: TryFindSingle or TryFindFirst - Feature

Post by jainaakash » Thu Nov 18, 2010 1:19 pm

Thats fine, I am able to get the list and check for what I want to look.
My actual concern / question is on the behaviour of TryFindSingle.

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

Re: TryFindSingle or TryFindFirst - Feature

Post by Support Team » Thu Nov 18, 2010 3:52 pm

Hi,

TryFindSingle aborts the search when an element is found which fits to your RxPath. So it depends on the chosen RxPath to search for it. We cannot change this method to another name, because this would be a breaking change and many of our customers shout "Why you changed the name". To overcome this issue please use the solution from artur.

Regards,
Peter
Ranorex Team