How to Swipe CarouselView with Xamarin.UITest

Takeshi Fujimoto
2 min readJun 27, 2021

CarouselView’s UI structure

If you show the UI tree of Xamarin.Forms CarouselView control with Repl() method, you will notice the class names are different in each platforms (iOS/Android).

  • iOS : Xamarin_Forms_Platform_iOS_CarouselTemplatedCell
  • Android : CarouselViewRenderer

Therefore, you need to query to specify the carousel view element in your app by using AppQuery.Class. This is the code snippet of IApp.SwipeRightToLeft method to swipe the carousel view.

Sample codes

By using Microsoft demo app, I wrote the sample codes that swipe CarouselView on GitHub.

In this sample code, the panel on the center of the screen will be swiped until the specific monkey name panel will be shown on the screen.

You can use IApp.WaitFor method to swipe the panel until the panel that you want will appear on the screen. When you use IApp.WaitFor method, you would have to change the query to check the monkey name.

In iOS app, the UILabel class, which is the descendant of the Xamarin_Forms_Platform_iOS_CarouselTemplatedCell class has the text of the monkey name.

Reps iOS

In Android app, the monkey name is set in the text property of the LabelRenderer control.

Repl Android

Here is the sample codes where the Xamarin.Forms CarouselView control is swiped with Xamarin.UITest.

Sample codes to swipe CarouselView control in Microsoft sample

Links

--

--

Takeshi Fujimoto
0 Followers

.NET App Engineer in Fukuoka, Japan.