AppiumDriver IOS: Reset driver options doesn't cater for IOS application with 2 possible start screens and certificates

Problem Summary:
We want a way to test iphone app using persistent certificates at all times but need a way to reset the app fully without wiping the whole simulator folder

Background:
We currently have an app where certificates(IOS profile added to Setting > Profiles) are required to connect to our test environments.

There is also a 2 different start points for our app.
1 - Registration - Enter username/password etc then you will be asked to create a PIN for easy access in future
2 - If you have already registered and open up the app then you will be asked to enter your PIN skipping registration screens

We currently run a couple of hundred scenarios on android requiring users with different credentials (username/passwords) to register and perform actions on different screens

We are now trying to rerun the same scenarios across IOS but have a problem:
The 2 different server options for IOS do not allow us to keep the certificates and reset the application to the initial registration start point.

Full Reset option on:
This will delete the entire simulator folder including the certificates which will mean connection to our environment is not allowed.
The reset will restart the app to the Registration screen which is what we wanted.
The certificates/profiles are actually deleted when session is initialised.

No Reset option on:
This will not delete the certificates
If the user has completed registration then the app will be reset to the PIN screen and not the Registration screen which we wanted

Neither reset option on:
This will delete the entire simulator folder including the certificates which will mean connection to our environment is not allowed.
The reset will restart the app to the Registration screen which is what we wanted.

We are also unable to use the driver removeApp or installApp methods as we have to run on a simulator as the simulator needs to pick up the network connection from
an Ethernet connection on Mac.

This all works on Android as the certs are not uninstalled after a full reset

Any help would be much appreciated

Hi,

I have a similar setup as you where I need the test app to be reset so that I can register with different users and verify the numerous flows in the app.

ios.js file inside Devices folder is where this is all happening.

runSimReset method which is called among the async series of tasks when you launch the session for iOS would delete the entire simulator folder thus getting rid of all the SSL profiles and the app data and any other app which your test app has a dependency on (in short it flushes out every thing user related from the simulator).

IOS.prototype.runSimReset = function (cb) {
if (this.args.reset || this.args.fullReset) {
logger.debug(“Running ios sim reset flow”);
// The simulator process must be ended before we delete applications.
async.series([
this.endSimulator.bind(this),
function (cb) {

if (this.args.reset) { this.cleanupSimState(cb); }

else {
cb();
}
}.bind(this),
function (cb) {
if (this.args.fullReset && !this.args.udid) {
this.deleteSim(cb);
} else {
cb();
}
}.bind(this)
], cb);
} else {
logger.debug(“Reset not set, not ending sim or cleaning up app state”);
cb();
}
};

As seen above (the bold part of the code) if argument is reset, Appium would clean sim state getting rid of all user related data on the simulator.

FIX: replace this.cleanupSimState(cb) with this.clearAppData(cb);
This would just reset the app data instead of cleaning sim state.
With this fix you could also use driver.resetApp() method which does the exact same thing.

I am pretty new to iOS automation with Appium so not very sure if this is the right way of doing it. Hence, would love if someone from Appium’s team could verify this fix at their end.

Cheers,
Camy

Thanks - this sorted my issue.

I would be very keen for this to be included as an appium setting or capability.

Deleting the whole simulator folder seems a bit extreme to me.

Cheers
Dec