Ask a Question

Access UI elements inside Xamarin.Forms.ListVIew.

SOLVED
hacka87
Contributor

Access UI elements inside Xamarin.Forms.ListVIew.

Hello!

 

I am working on automated tests for an Instrumented Application using the Xamarin.Forms on Android.

 

After entering the Assemblies for Xamarin Forms in the code of the app by the developers, I can't manage to have access to elements that are contained by the listView, nor with ObjectSpy, nor I can't find a suitable method to access them by code. I am using FullNames to get the elements. Is there another way besides using the Aliases to have access to the items in such a listview? I have tried also with Children, there is no wItem(index) way to do it, there is no SelectItem like in another listView. I need to get the content of the list view and test each element and also do a touch on it, without having to switch to Aliases and this approach. Also FindAll methd does not have any result.

 

  var navigationpage;
  Mobile.SetCurrent("Moto G (5)");
  navigationpage = Aliases.Device.Process////.navigationpage.mainpage.navigationpage;
  navigationpage.page.stacklayout.contentpresenter.absolutelayout.stacklayout.grid.listview.TouchItemXY(0, 690, 157);
  navigationpage.deviceconnectionpage.stacklayout.stacklayout.label.Touch(683, 119);

 

            for (var i = 0; i < listview.wItemCount; i++)
            {
                Log.Message(list.Children);
            }

 

Best Regards,

10 REPLIES 10
Marsha_R
Champion Level 3

Hello!

 

All the steps above have been followed.

I can get access to elements from the UI with Object Spy, but not those of the ListView that are somehow hidden.

Yes. I have the list of Properties fields and Methods.

The ListView does not have any visible children. I tried with VisibleDescendants that Collection.

 

Object Spy only takes the ListView and that is all, for other controls in separate containers it works Ok.

I can't find anything with FindAll.

Marsha_R
Champion Level 3

If you experience issues when working with Xamarin.Forms controls, select File > Install Extensions from the TestComplete main menu and check whether the plugins are active. (You can find the plugins in the Mobilegroup.) If some plugin is not available, run the TestComplete installation in the Repair mode.

 

And your plugins are active?

 

ListViewObjectSpy.PNGObjMappingListView.PNGPlugins.PNG

Also I managed to get the BindingContext working and access the leent from tehre. Is there a way for Object Spy to see what is inside the ListVIew? I saw some tutorials that sometimes the items inside the list view are hidden and accessed with the TouchItem(). I tried it like this, but is there a way to get the items with Object Spy? Unfotunately I cannot find another way than using the BindingContext.

Marsha_R
Champion Level 3

Try recording a keyword test and using the controls you want to find.  See if TC ends up giving them an object name in the test.

 

If that doesn't help, you can contact Support directly at this link:

https://support.smartbear.com/message/?prod=TestComplete

 

 

I created a ticket for their Support team.

I found out the problem.

TestComplete can test applications created with Xamarin.Forms version 2.5.0.

 

We use Xamarin.Forms version 3.2.

 

cancel
Showing results for 
Search instead for 
Did you mean: