maestro icon indicating copy to clipboard operation
maestro copied to clipboard

`clearState` command doesn't reliably clear UserDefaults on iOS

Open AtomicGeorge opened this issue 1 year ago • 3 comments
trafficstars

Describe the bug Launching an app with clearState or calling clearState directly doesn't reliably clear UserDefaults in an iOS app.

To Reproduce

  1. Write a value to UserDefaults in an iOS app.
  2. Quit the app
  3. Launch an app with maestro using
- launchApp:
    appId: "com.example.app"
    clearState: true

or -clearState followed by -launchApp 4. Observe that UserDefaults still contains the previously written value. Expected behavior userDefaults should be cleared and the app should be launched as though it had not been used previously

Environment information (please complete the following information):

  • Maestro version: 1.34.1
  • Platform: iOS 17.0.1
  • Framework: Native iOS
  • Device model and OS version: iPhone 15 iOS 17.0.1
  • Simulator
  • Host: Mac M1

Workspace (if applicable) MaestroUserDefaultsTestApp.zip

Additional context A workaround I've found is using -clearState before running launchApp with the clearState option set to true as far as I can tell this should delete everything twice which seems to ensure that the app is fairly reliably launched with a completely clear state.

AtomicGeorge avatar Nov 22 '23 12:11 AtomicGeorge