Retrieving a list of elements using FindDescendants()

Class library usage, coding and language questions.
BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Retrieving a list of elements using FindDescendants()

Post by BruceBalen » Tue Jun 30, 2009 8:59 pm

I have been trying to extract the list of Text elements contained in an element using the FindDescendants() method. I used the syntax I found in examples posted here by the support team, but I'm getting an error nonetheless.
I am working in C#. here is the code:

Code: Select all

List<Text> nodeList = repo.FormAmdocs_Interactive__Cata.ElementTree.FindDescendants<Text>();
Here is the error:

The non-generic type 'Ranorex.List' cannot be used with type arguments (CS0308)

I know this should be really simple, but I've been banging my head against this wall for an hour. Please help!

-Bruce

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

Re: Retrieving a list of elements using FindDescendants()

Post by Ciege » Tue Jun 30, 2009 9:27 pm

Instead of "List" I belive you need to use "IList".

This is my code for finding forms:

Code: Select all

IList<Ranorex.Form> allForms = Host.Local.FindChildren<Ranorex.Form>();
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...

BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Re: Retrieving a list of elements using FindDescendants()

Post by BruceBalen » Tue Jun 30, 2009 10:57 pm

Right the definition for findDescendants() says it returns IList, but if I do it that way, I get a different error:

The type or namespace name 'IList' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

So, I just need to use the appropriate namespace, but everything I read looks like this should be covered by using Ranorex.Core. My brain may just be a bit slow today, but can someone tell me if there's a namespace I need to use?

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

Re: Retrieving a list of elements using FindDescendants()

Post by Ciege » Tue Jun 30, 2009 11:01 pm

Try

Code: Select all

using System.Collections.Generic;
That is what I use.

IList is a system component not a Ranorex component.
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...

BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Re: Retrieving a list of elements using FindDescendants()

Post by BruceBalen » Wed Jul 01, 2009 5:52 pm

Ciege does it again! Thank you so much. Moving on now.