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.
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.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies