Forum Xamarin Test Cloud (Read Only)


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is there a method to close an app in UITest?

Is there a method to close an app in UITest?

In my test case I want close my App.


  • I'm in need of this same scenario and I've yet to find any way of doing this short of executing:
    adb shell am force-stop

    The above doesn't work in my scenario since I need our application to cleanly close.

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    We do it using a backdoor - so expose a method on your app class with an Export attribute and Invoke it from your test:

    In this we do an Environment.Exit(0) which kills the app.

    In the UI test code this will throw an exception as the HTTP server loses it's connection so just wrap the invoke in a try/catch and ignore the exception.

Sign In or Register to comment.