Want to restart IOS application in a single Appium session without deleting/uninstalling it

Hello guys.
I want my application to be uninstalled and installed fresh when starting a new Appium session at the start of my test,and in between I want to restart my application (without deleting it) by calling driver.closeApp() followed by Driver.LaunchApp().(I want all these things to be happen in single Appium session)

Now I tried this using desiredcapabilities:FullReset=false and NoReset=true

but due to this,my application is getting restarted in between after calling driver.closeApp() followed by Driver.LaunchApp(),and it is not deleting my application too which is as per my expectations,but while starting Appium session at the start of the test,application will not get reinstalled because I have kept FullReset to False

If I want to achieve both i.e. Uninstalling/Installing while creating new Appium session at start of the test and in between test when I will close and relaunch app it should not delete/uninstall my application,which desiredcapabilities should I set?

Thanks and Regards,
Pranoday

1 Like

we manage it in testTG code when we start driver. we looking for variable in testNG xml, how it is needed to start client with reset or not.

we start appium server in code with most default settings like:

[appium, --log-level, error, --port, 4725, --session-override]

code itself is:

            if (devicePlatform.contains("fullReset"))
                capabilities.setCapability("fullReset", true);
            else {
                capabilities.setCapability("fullReset", false);
                capabilities.setCapability("noReset", true);
            }

where “devicePlatform” is variable taken from here example of xml:

    <test name="Install_new_client_on_device">
        <parameter name="devicePlatform" value="iOS fullReset"/>
        <parameter name="deviceName" value="iPad Air,iPhone 5s"/>
        <classes>
            <class name="com.xxxxxxxxxx.tests.xxxx.test.ios.doFullReset">
            </class>
        </classes>
    </test>
    <test name="some_test_name" preserve-order="true">
        <parameter name="devicePlatform" value="iOS"/>
        <parameter name="deviceName" value="iPad Air,iPhone 5s"/>
        <classes>
            <class name="com.xxx.tests.xxxx.test.ios.testWelcomeScreen"/>
            <class name="com.xxx.tests.xxxx.test.ios.testTermsAndConditions"/>
            <!-- and other tests -->
      </classes>
    </test>

Hello @Pranodayd,

Using a java client, the thing i will try is to:
1- Use NoReset=true
2- In the @After method i’ll use driver.closeApp() and driver.launchApp() (or driver.resetApp() that does both :stuck_out_tongue: )
3- In the @AfterClass i’ll use driver.removeApp(“bundle”).

When Appium will start over again, it will detect that the application is not installed and will do this job for you.

1 Like

Hi @sam_viz
I’ve tried

driver.removeApp("com.my.app");

but getting an exception

Exception in thread "main" org.openqa.selenium.WebDriverException: undefined status object (WARNING: The server did not provide any stacktrace information)

and the appium log :

info: --> POST /wd/hub/session/71a4c5ca-92b5-4e94-99f5-f8a795671d82/appium/device/remove_app {"bundleId":"com.my.app"}

info: [debug] Responding to client with error: {"status":1,"value":{"message":"undefined status object"},"sessionId":"71a4c5ca-92b5-4e94-99f5-f8a795671d82"}

info: <-- POST /wd/hub/session/71a4c5ca-92b5-4e94-99f5-f8a795671d82/appium/device/remove_app 500 1.802 ms - 109 

Any idea how to fix it ?

thanks

Hello @igal_epshtein,

Looks like you’re trying those methods on a simulator.

correct , but it seems that appium’s stuff has never confirmed it … moreover , the documentation doesnt mention it as well…
The exception which is thrown is meaningless

So if I understand correctly , there is no way to achieve the requested scenario which is being described above ?

anyone has tried it maybe ?

what exactly scenario you trying to achieve ?

if you want install fresh copy client and continue some tests just follow steps i mentioned.

removeApp make absolutely no sense with real iOS device (cause you can’t tap anywhere outside app on real device).

I want to restart the app several times without full reset during the tests execution and at the end of the execution to remove it from the device , just as @sam_viz has described

In your solution you are initializing the driver at the beginning of the execution and you cannot change the driver’s setting while it’s already running , am I right ?

We do almost same as you described except remove.
Just inside test when you started driver without FullReset do again driver.quit and open driver again without FullReset. This will restart application.

To remove application at the end do driver.quit then open driver with FullReset and do driver.quit. This will remove application from device.

@Aleksei , hat do you mean by “open driver again” ?
do you mean to initialise the driver from scratch ?

Yes. Server itself is always running.

@Aleksei , thanks for the hit , I’ll try , although it would be great if the removeapp will work , it may save a lot of refactoring …

@Aleksei I’ve tried your solution , and it works , (I even can uses driver.resetApp instead of driver.quit and creation new session) but one thing which was required on my side to be added is the “noReset” capability to be set to false , otherwise it didn’t work for me…

driver.resetApp - does not help with our application cause we store some data that not deleted in this case. that is why i gave 100% working solution with client reinstall via opening driver in fullReset mode.

actually it doesn’t matter rather you use resetApp or just driver.quit …
The thing is that I was needed to add “noReset” in order to make it work …

Hi @Aleksei
Implemented your solution.And it is satisfying my requirement.It requires creation of two sessions though.
Whatever solution we apply.We can not do it in single session.

Thanks guys.

Hi @Aleksei, @Pranodayd
Above solution - is it feasible while running in grid. I don’t star the appium server in code since we are running against grid nodes. How can I achieve while running against grid ?

Note: Grid nodes would always run with --full-reset flag since these nodes are common across different teams in our organisation. So, I dont want to disturb that flag in grid.
At the same time, when It is starting for the first time - I would like to start with full reset. However in between tests I would like to restart the app to ensure clean state.

Appium 1.5.1 = [DEPRECATED]

–full-reset false [DEPRECATED] - (iOS) Delete the entire simulator folder. (Android) Reset app state by uninstalling app instead of clearing app data. On Android, this will also remove the app after the session is complete.

@Aleksei so does full reset currently work on 1.5.1?