Retrieving a list of elements using FindDescendants() : Automation API

Retrieving a list of elements using FindDescendants()

Class library usage, coding and language questions.

Retrieving a list of elements using FindDescendants()

Postby BruceBalen » Tue Jun 30, 2009 9: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
BruceBalen
 
Posts: 9
Joined: Thu Jun 18, 2009 10:57 pm

Re: Retrieving a list of elements using FindDescendants()

Postby Ciege » Tue Jun 30, 2009 10: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...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Retrieving a list of elements using FindDescendants()

Postby BruceBalen » Tue Jun 30, 2009 11: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?
BruceBalen
 
Posts: 9
Joined: Thu Jun 18, 2009 10:57 pm

Re: Retrieving a list of elements using FindDescendants()

Postby Ciege » Wed Jul 01, 2009 12:01 am

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...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Retrieving a list of elements using FindDescendants()

Postby BruceBalen » Wed Jul 01, 2009 6:52 pm

Ciege does it again! Thank you so much. Moving on now.
BruceBalen
 
Posts: 9
Joined: Thu Jun 18, 2009 10:57 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests