Xamarin.uitest how to close app instance

∥☆過路亽.° 提交于 2021-01-27 18:32:40

问题


How to close and relaunch app in Xamarin.UI Test ? I want to restart app for each scenario in feature .

Platform: android

There is no quit() or close() session methods like we have in appium.


回答1:


Calling ConfigureApp.Android.StartApp() in your test will launch a new session of your application for you to interact with (just make sure to save the new object).

However, with the use of NUnit, methods tagged with [Setup] will run automatically before every method tagged with[Test]. That means most test suites only use the ConfigureApp.Android.StartApp() method once, in [Setup].




回答2:


Given you are on your are using Xamarin UI Test project,

You can use Finish() to close the application,

or

MoveTaskToBack(true) to minimize the application.

So that you can call them from your Test.cs, you'll need to write myBackdoorClose and myBackdoorMinimize functions (since Finish() and MoveTaskToBack(true) are only available in the App.cs context). How to do that, read here!




回答3:


You can actually use Xamarin.UITest.ConfigureApp.Android.StartApp(AppDataMode.DoNotClear) in your test. It will close the app and restart it without clearing the app's data, all while the test keeps running.

This is a cross-platform solution; you can use Xamarin.UITest.ConfigureApp.iOS.StartApp... too.



来源:https://stackoverflow.com/questions/42089998/xamarin-uitest-how-to-close-app-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!