webdriverio / appium-boilerplate

Boilerplate project to run WebdriverIO tests with Appium to test native applications on iOS and Android
MIT License
455 stars 261 forks source link

Reset cache between tests (particularly on iOS) #156

Open jamesmcn1 opened 1 year ago

jamesmcn1 commented 1 year ago

Hey guys, we are looking for a neat way to clean app data cache between tests.

I have read around various solutions none of which for for me:

  1. use fullReset: true and noReset:false capabillity - This restarts the device without the app installed.
  2. browser.reset() or browser.resetApp() - only works for Android

Anyone got any suggestions for this?

jamesmcn1 commented 1 year ago

Answering my own question: brower.reset() works on iOS simulators as long as you provide the filepath to the .app file as a capabillity. Eg:

        "appium:app": '/Users/BLAH/Library/Developer/Xcode/DerivedData/...........',

this combined with fullReset: false and noReset: false provides the desired behaviour

christian-bromann commented 1 year ago

@jamesmcn1 we received this questions a lot, would you mind helping to get something written in our docs? Maybe we can start with a Mobile Testing section and add a FAQ page in there. Wdyt?

wdio-bot commented 11 months ago

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

govza commented 2 months ago

For cucumber this hook surprisingly does job for me, with default fullReset and noReset

async beforeScenario() {
    await driver.reloadSession();
  },
wswebcreation commented 2 months ago

For cucumber this hook surprisingly does job for me, with default fullReset and noReset

async beforeScenario() {
   await driver.reloadSession();
 },

@govza

Great suggestion, but....., please keep in mind that you "completely" release the session (see it as a delete session) and in the case of (physical) devices you give the device back to be cleaned. Depending on the vendor, this cleaning process might take a while, which would negatively impact the test execution. If this is not an issue for you then no problem at all, this is just extra context for people who want to try your suggestion