Connect:    



Event Calendar

Some useful links

Online Courses

Articles


A software architect, Azure expert, and former Microsoft evangelist, Mike Benkovich dedicates huge amounts of his time to helping his fellow developers and burgeoning programmers learn about new technologies and platforms. Mike’s website equips developers with tips and resources to help them get to grips with technologies including cloud, data and devices, and he produces online courses covering areas like Azure enterprise development and serverless computing. Mike is also a chronic sharer of puns, so head over to his Twitter feed if you’re after a laugh (or a groan).

BenkoBLOG by Tags


Blog Roll...
Conferences
Regional User Groups

Blog

How to record a UI Test on Android with Xamarin tools

@MikeBenkovich 07/10/2017

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.

        [Test]
        public void NewTest()
        {
            app.SwipeLeftToRight();
            app.Tap(x => x.Class("PageRenderer"));
            app.SwipeLeftToRight();
            app.SwipeLeftToRight();
            app.ScrollDown();
            app.ScrollUp();
            app.SwipeLeftToRight();
            app.SwipeRightToLeft();
            app.Screenshot("Swiped left");
        }