简体   繁体   中英

How to hard close/force close/kill the app from memory in Android using Appium in the same test

This is my scenario

  1. Launch the app and perform some steps
  2. Hardclose/Forceclose/Kill the app from memory/Should not run in background
  3. Launch the app again
  4. Perform some steps
  5. Assertion step

How to achieve this?

I have tried the following methods

  1. resetApp() - it uninstall the app and install app again.
  2. closeApp() - it just close the app but app is still running in the background.
  3. adb shell am force-stop <packagename> - it just close the app but app is still running in the background.

But for my scenario it should delete from the background and app should not uninstall in Android in the same test (middle of the test).

You can try it, I think it will serve your purpose, use below line from where you want to launch the app again

Activity activity = new Activity("appPackage", "appActivity");
driver.startActivity(activity);

Try below code and add this to the capability :

capabilities.setCapability(MobileCapabilityType.NO_RESET,"false");

It should work as per your requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM