List/ListItem - Access top level only from multiple levels

Class library usage, coding and language questions.
neilw
Posts: 6
Joined: Mon Mar 11, 2013 3:02 am
Location: Australia

List/ListItem - Access top level only from multiple levels

Post by neilw » Fri Nov 08, 2013 6:07 am

I have 2 levels of Lists
First Level is 'Licences' of which there are 2 Records
Below each Licence Record there are multiple Class records. In the example shown below, the first Licence has 1 Class recird and the 2nd Licence has 30 Class records.
Making a total of 33 records.

I am trying to access ONLY the top 2 Licence Records of which I will then iterate through each of these and check all the Classes associated.

My code shown below to access the 'Licence' records has a count of 33 and not 2 which I expected. This appears to be due to all list records are being collected from both the 'Licence' level and the 'Class' level.

Is there a way to access on only the 'top' level of these lists without the lower level is not included?

i.e. When extarctin a list is there a way to limit the amount of levels Ranorex searches?

Code: Select all


//Create 'List' of all Licences displayed
RepoItemInfo info =  repo.BSA_Build.EnterpriseSearch.Tabs_Upper.Licences.SelfInfo;
RxPath listPath = info.AbsolutePath;
			
List listLicences = listPath + "/list";
IList<ListItem> itemsLicences = listLicences.Items;   // <=== This collects both levels but only want top level

Report.Info("Cycle Through Licences Displayed: '" + itemsLicences.Count + "'");   //33 - Should ONLY be 2
			
//Loop through all Licences
foreach(ListItem item in itemsLicences)
{
         //Other code goes here...
}

Attachments
20131111_LicenceClass_1.jpg
20131111_LicenceClass_1.jpg (48.9 KiB) Viewed 939 times
20131111_LicenceClass_2.jpg
20131111_LicenceClass_2.jpg (86.13 KiB) Viewed 939 times
Last edited by neilw on Mon Nov 11, 2013 3:36 am, edited 3 times in total.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: List/ListItem - Access top level only from multiple levels

Post by krstcs » Fri Nov 08, 2013 2:21 pm

Could you post a snapshot of your Application Under Test? Without that, we have no way of knowing what the issue is.
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: List/ListItem - Access top level only from multiple levels

Post by Support Team » Mon Nov 11, 2013 8:06 am

Hi,
thanks for the screenshots.
The more interesting point to solve your issue would be the structure of your list/listitems in the Ranorex Spy.
Please have a look if the layering there looks the same as in your application.
Maybe you can post a Ranorex Snapshot too.

Regards,
Larissa
Ranorex Team
.
Image