CreateAdapters for ListItem

Class library usage, coding and language questions.
vadim
Posts: 14
Joined: Tue Apr 16, 2013 8:22 am

CreateAdapters for ListItem

Post by vadim » Wed Apr 24, 2013 12:32 pm

Hi,

I have WPF application and I want to create list of adapters for ListItems.
I have a repository element (repo.MyApp.MyList) with RxPath:
/form[@name='MyApp']/element[@classname='SomeView']/list[@classname='ListView']/listitem
When I explore this element in Ranorex Spy, I see several ListItem elements.

I have the following code block, where I expect to get list of all ListItem elements:
IList<Ranorex.ListItem> list = repo.MyApp.MyListInfo.CreateAdapters<Ranorex.ListItem>();
But returned list contains only one (first) element.
The similar code for Buttons return full Button List.

Please let me know where there can be mistake in my code.

Thanks,
Vadim

vadim
Posts: 14
Joined: Tue Apr 16, 2013 8:22 am

Re: CreateAdapters for ListItem

Post by vadim » Wed Apr 24, 2013 12:54 pm

I found workaround how to get all Elements of a list.
IList<Ranorex.ListItem> list = repo.MyApp.Find<Ranorex.ListItem>(".//ListItem");
But I'm still interesting what is wrong in my first example.

Cheers,
Vadim

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

Re: CreateAdapters for ListItem

Post by Support Team » Wed Apr 24, 2013 8:52 pm

vadim wrote:But I'm still interesting what is wrong in my first example.
I don't see anything that's "wrong". Could it be that there is just one direct child ListItem in the list and the other ListItems are descendants (no direct children)?

Regards,
Alex
Ranorex Team
.
Image

vadim
Posts: 14
Joined: Tue Apr 16, 2013 8:22 am

Re: CreateAdapters for ListItem

Post by vadim » Thu Apr 25, 2013 9:46 am

Hi Alex,

As far as I see all ListItems are children of List element.
If update RxPath to:
/form[@name='MyApp']/element[@classname='SomeView']/list[@classname='ListView']/child::listitem
Then all ListItems are visible in Ranorex Spy.

Cheers,
Vadim

Samuel
Posts: 14
Joined: Tue Nov 12, 2013 10:50 am
Location: Germany (BW)

Re: CreateAdapters for ListItem

Post by Samuel » Thu Dec 19, 2013 3:11 pm

@vadim: Thank you :!:

I encountered the exact same problem and was able to solve it with vadims workaround.
Accessing ComboBoxes is indeed a bit tricky. It seems the list items that are inside the combobox can not be found by Ranorex Spy unless the ComboBox has been dropped down at least once (after it has been dropped down finding the elements is possible even if the box has been closed again).

The Items by the way can not just be found using the ComboBox itself once it´s dropped down, but they are also represented inside a Container 'DropDownScrollViewer', which does not belong to the original application, but to a independent /form[@classname='Popup']. If I track one ListItem with Spy, then Spy will show the item in the container from the popup form. If there were multiple items inside the menu, Spy however won´t show other ListItems inside this container.

Problematic is, that even if the list items can be found by Ranorex Spy using a rXcode like

Code: Select all

//combobox[@automationid='SA20131210115604']/?/?/listitem
and trying to create adapters using

Code: Select all

IList<Ranorex.ListItem> itemList =  repo.AddScripDialog.Popups.AllScriptListItemsInfo.CreateAdapters<Ranorex.ListItem>();
only the first ListItem will be added to the adapter with no apparent reason.

Based on vadims solution I also changed the rXpath to:

Code: Select all

//combobox[@automationid='SA20131210115604']
And the adapter creation to

Code: Select all

IList<Ranorex.ListItem> itemList = repo.AddScripDialog.Popups.AllScriptListItemsInfo.Find<Ranorex.ListItem>(".//ListItem"); 
and voila, all the ListItems appeared.