1

My scenario is, I'm switching from one app to another in an Android phone.

While switching from one app to the other, I want to clear all data or do a hard reset of the app I'm switching from. Also before the new app starts (using driver.activateapp) I want all data to be cleared.

I tried driver.resetapp but, it only reets the first app and not the next one which I'm opening.

How can I do this?

2 Answers 2

0

Solution :

  • For your scenario, You want to clear app data for second app.
  • So you need to write any method where it will clear app data for second app while switching the application

How to do it?

  • Option 1 : You can achieve it using adb shell pm clear <your-app-pkg>
  • Option 2 : You can start your appium server with flag --full-reset initially and or while switching after creating driver you can execute method driver.resetApp()
  • Option 2 was clearing app data of first app because you call it right after driver got initialised for app one. Tweak a little and call it after you initialise driver for second app
0
capabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
capabilities.setCapability(MobileCapabilityType.NO_RESET, false);

Have you try this in your one of before methods ?

https://stackoverflow.com/questions/58766977/how-to-reset-application-in-appium

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.