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

i use it as driver start key. in such case it is working with minor issue - https://github.com/appium/appium/issues/6307

Wow. It seems insanely difficult to accomplish the simple tasks of installing the app at the beginning of a test run, closing it at the end of each test, opening it at the beginning of each test, and un-ininstalling it at the end of the test run.

If anyone knows how to accomplish this extremely common scenario (in code and/or server settings) using the iOS simulator or an iOS device, Iā€™d LOVE to hear about it.

An example of the insanity:

//This closes the app and shuts down the simulator!!!
driver.closeApp();

//This restarts the simulator and RE-INSTALLS the app!!!
driver.launchApp();

@jblaze
Hi,
I using Appium 1.5.3.
Iā€™m using the same commands as you, driver.launchApp(); doesnā€™t re-install the application.
About you approche, re-open and closing the application between each scenario, i do it.
Iā€™m using a command line to open the server: (can be remote server using SSh tool such as http://www.jcraft.com/jsch/) before each scenario.
And after just killing the processs.
About the Appium driver:
I actually create a new driver each time.
It worked for me, but please pay attention, It will make your execution time much longer (craeting new driver takes between 12-30 sec)

In case you want to re-install the application, you can use ideviceinstaller
Hope i helped you.
Eitan.

But closeApp followed by launchApp closes the simulator, re-opens it, and RE-INSTALLS the app!

Iā€™d love to know how to close and re-open the app WITHOUT re-installing. Please, someone! Iā€™ve lost about 30 hours trying to figure this out!!!

1 Like

how you understand that APP was really ā€œre-installedā€ ? in mine case it is just starting.

maybe you start driver with ā€œfullReset = trueā€ option?

find out. uninstall APP happens on driver.closeApp() :slight_smile: when:

  • fullReset = true
    or
  • noReset = false

When ā€œnoReset=trueā€ + ā€œfullReset=falseā€ driver.closeApp() does not uninstall app but just close it. even without closing Simulator.

I know it restarted because I modified some data in the app while it was running before I called closeApp and launchApp

I created issue in Appium github. Let see if it will be fixed. In the mean time you can close Simulator instead closeApp()

@Aleksei
If I click on contact Us link from Contact page of my application , mail client will open. I am unable to click on back button to come back to my app.
I can navigate back in android using ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);
there is no similar way in IOS to navigate back. So I am trying to re-launch my app but it is going to my appā€™s home page but actually I want go to the contact page from where I clicked the external link.
I have tried below but it is not working as expected.Could you please guide me?
capabilities.setCapability(ā€œfullResetā€, false);
capabilities.setCapability(ā€œnoResetā€, true);

why? execute:

System.out.println(driver.getPageSource())

identify back button on Mail client and tap on it.

@Aleksei i am able to identify element but tap is not happening.No error in console.So click may be happening somewhere else.I have checked number of elements for the x-path which i use.Only one element is there.Also only one context which is native.

@deepakkg88 write you code how you tried to tap on it ? Is it Real device or Simulator?

@Aleksei.It is real device.I tried below 6 ways.

1 .new TouchAction((IOSDriver)driver).tap(driver.findElement(By.xpath("//UIAButton[contains(@label,ā€˜Back to appā€™)]")));

  1. new TouchAction((IOSDriver)driver).tap(driver.findElement(By.xpath("//UIAStatusBar/UIAButton")));

  2. new TouchAction((IOSDriver)driver).tap(6, 0);
    4 new TouchAction((IOSDriver)driver).press(driver.findElement(By.xpath("//UIAButton[contains(@label,ā€˜Back to appā€™)]")));

5 WebElement element=driver.findElement(By.xpath("//UIAButton[contains(@label,ā€˜Back to appā€™)]"));
org.openqa.selenium.Point location=element.getLocation();
Dimension size1=element.getSize();
int x1=(int) (location.getX()+size1.getWidth()/2.0);
int y1=(int) (location.getY()+size1.getHeight()/2.0);
TouchAction ta = new TouchAction(driver);
ta.tap(x1, y1).perform();

6.driver.findElement(By.xpath("//UIAButton[contains(@label,ā€˜Back to appā€™)]")).click();

@deepakkg88 on real device i hardly believe you can tap outside test app due to Apple restriction. on Simulator - not problem.
In 2021 not problem any more

This is exactly what I am seeing - oddly, when I restart my computer - the first few times launchApp() does not reset the app but later on it, it does!! Itā€™s driving me crazy

You cant reset the app when using XCUITest directly eitherā€¦its just the way it is :frowning:

https://appium.io/docs/en/writing-running-appium/other/reset-strategies/#reset-strategies

Are you specifically looking to reset the data? Or just stop the app and re-launch it? We actually started launching the Settings app so we could uninstall our previous versions of our apps (our debug version affects our release version but they use different package name etcā€¦). This gave us leeway to uninstall, launch, or other things our app under test.

I use
driver.terminateApp( bundleId)
driver.activateApp(bundleId)

1 Like

This works for me too. Thanks!

read this, might help someone