Page 1 of 1

Retrieving a list of elements using FindDescendants()

Posted: Tue Jun 30, 2009 8:59 pm
by BruceBalen
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

Re: Retrieving a list of elements using FindDescendants()

Posted: Tue Jun 30, 2009 9:27 pm
by Ciege
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>();

Re: Retrieving a list of elements using FindDescendants()

Posted: Tue Jun 30, 2009 10:57 pm
by BruceBalen
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?

Re: Retrieving a list of elements using FindDescendants()

Posted: Tue Jun 30, 2009 11:01 pm
by Ciege
Try

Code: Select all

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

IList is a system component not a Ranorex component.

Re: Retrieving a list of elements using FindDescendants()

Posted: Wed Jul 01, 2009 5:52 pm
by BruceBalen
Ciege does it again! Thank you so much. Moving on now.