How can I deal with app state

On a new device when starting our (iOS native) app, you’re guided through an onboarding flow where you create your account. This only happens once and your credentials are then stored in the iOS KeyChain.

The problem with this is in the world of tests this type of behaviour is unwanted. We want each test to start from a fresh state with 100% isolation from other tests (no dependencies).

How can I achieve that using Appium?

Even if I restart Appium, the simulator seems to remember the previous state/session.

Also, the simulator is not being shutdown after a test-session.

I’m using python (3.7.3) and pytest (4.5.0).
Appium 1.13.0
I’m on a mac, OSX 10.14.4
Xcode 10.2.1

@BeyondEvil many things depends on your app. e.g. if you manually uninstall app and install again and your app will grab last state from KeyChain -> all you can do is LOGOUT in test code before starting new onboarding.

Thanks @Aleksei, I was afraid that was going to be the answer. So there’s no way of forcing a “clean” state. For example by restarting the simulator? Is it possible to scrub/clean/delete the KeyChain?

On iOS simulator it is possible to use mobile: clearKeychains for this purpose ( Also setting fullReset cap to true will reset the simulator completely

1 Like

@BeyondEvil i suggest you use “@BeforeMethod” with testNG and write code to logout your user. At some point anyway you will migrate to real device.