Reset iOS device between tests?

3,049 views
Skip to first unread message

Simon Howlett

unread,
May 13, 2013, 4:49:09 PM5/13/13
to appium-...@googlegroups.com
dumb question.. is there a way i can reset simulator state at the end of each test in python, i close down the session, but values from the test are cached it appears?

bootstrap online

unread,
May 13, 2013, 5:21:51 PM5/13/13
to Simon Howlett, appium-...@googlegroups.com
Have you tried mobile: reset?
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Simon Howlett

unread,
May 13, 2013, 5:31:59 PM5/13/13
to appium-...@googlegroups.com, Simon Howlett
i suspect i am missing something, i have 

self.driver.execute_script("mobile: reset") in tear down, which appears to reopen the app and the close out. though it doesn't reset/uninstall

bootstrap online

unread,
May 13, 2013, 5:53:05 PM5/13/13
to appium-...@googlegroups.com
Are you using the latest version of Appium? By default reset should be
enabled and on iOS that clears the simulator plist files associated
with the app under test. If reset is disabled then mobile: reset won't
reset the app.

https://github.com/appium/appium/blob/bdaf4192a6166201bd84fb543c8e7c840e521c38/app/ios.js#L333

On Mon, May 13, 2013 at 5:31 PM, Simon Howlett

Simon Howlett

unread,
May 13, 2013, 5:55:54 PM5/13/13
to appium-...@googlegroups.com
latest version, yep. pulled down and built today. i'll do some digging ;)

Leslie Chong

unread,
Aug 5, 2013, 8:40:16 PM8/5/13
to appium-...@googlegroups.com
Did you ever figure this out? I'm trying to do the same thing and not having luck.

I start the appium server with no params (since it sounds like allowing reset is allowed by default), and then tried adding self.driver.execute_script("mobile: reset") to the teardown. I see the command is received in the appium server log:
debug: Request received with params: {"script":"mobile: reset","args":[]}

but it doesn't actually reset mobile. The next test starts the app with the old app data.

Thank you!

bootstrap online

unread,
Aug 5, 2013, 11:16:51 PM8/5/13
to Leslie Chong, appium-...@googlegroups.com
mobile reset works on the iOS simulator and Android emulator/physical
devices. For physical iOS devices, it's not implemented yet.
> Visit this group at http://groups.google.com/group/appium-discuss.

Roberto Bertini Renzetti

unread,
Sep 12, 2013, 2:08:26 PM9/12/13
to appium-...@googlegroups.com
Another possibly dumb question: to what extent does the "mobile: reset" actually reset?

I'm testing an app that does an "In-App Purchase" and I want to make sure that the simulator does not have an user "signed-up" already so that every time I run the test I get the same alert dialogs from the system after a purchase.

I can reset the iOS simulator from its UI (iOS Simulator->Reset Contents and Settings...) to achieve that but it seems to me that if I do a "mobile: reset" on the teardown the next time I run the test it still remembers the user sign in from a previous session...

Is there another "mobile: ...." command that can sign out the user? I could run this command before running my tests :-)

Thanks
Roberto

bootstrap online

unread,
Sep 12, 2013, 2:14:07 PM9/12/13
to Roberto Bertini Renzetti, appium-...@googlegroups.com
On the iOS simulator, it only deletes the plist file for your app.
That's enough to sign me out of the app I test on. Maybe your app will
require even more files to be deleted?

Alex Arkanov

unread,
Oct 7, 2013, 4:00:14 PM10/7/13
to appium-...@googlegroups.com, Roberto Bertini Renzetti
are there any plans to implement the reset option for iOS physical devices in the near future?

Thank you,

bootstrap online

unread,
Oct 7, 2013, 4:06:35 PM10/7/13
to Alex Arkanov, appium-...@googlegroups.com, Roberto Bertini Renzetti
The solution for physical devices is to automatically
uninstall/install the app each time. I don't know of any other way. I
think this is already supported in appium via fruitstrap, however I
haven't tested it.

Brent LaVelle

unread,
Oct 7, 2013, 4:26:44 PM10/7/13
to appium-...@googlegroups.com
I found that logging out and calling the quit method on my driver (Selenium::WebDriver) instance when tests finished worked more than 90% of the time.  I now run this shell command: adb shell am force-stop com.vacationrentals.homeaway
seems to work all of the time.  The app being tested is com.vacationrentals.homeaway

bootstrap online

unread,
Oct 7, 2013, 4:35:00 PM10/7/13
to Brent LaVelle, appium-...@googlegroups.com
On Android it's easy because the adb commands work on real devices in
addition to the emulator. iOS physical devices aren't so fortunate.
> Visit this group at http://groups.google.com/group/appium-discuss.
Reply all
Reply to author
Forward
0 new messages