Confessions of an Evangelist

How to record a UI Test on Android with Xamarin tools

I had a question today about how the recorder works for with the Xamarin Tools in Visual Studio 2017. I’ve had mixed success with getting it to work, so I thought I’d document the steps that make it work. The trick is you need to be running a version of the APK that is not using the shared runtime (a default when you do a debug build). For that reason I use the release build to record the test. Here’s the basic flow:

1. Create new cross platform project with the blank template
2. Build & run it on my device (first in debug but then again in release)
3. add the UI Test project to the solution
4. In the Android project show all files and navigate to the bin/release folder and copy the path
5. In the Test.cs file at the top of the class near the [TestFixture(Platform.Android)] line click on record new test and then select the APK - make sure to put in the path of the signed release version of the apk
6. Wait until you notice the app running on the device
7. When you tap the screen, swipe left or right you'll see the [Test] method NewTest() gets new code added to it.

        public void NewTest()
            app.Tap(x => x.Class("PageRenderer"));
            app.Screenshot("Swiped left");


Comments are closed