App closes after running appium test

I have installed appium 1.4.16 and created a test case using eclipse and maven.

I am running my test from command line using
mvn test

Once the test is finished what I am seeing is that it closes the app. I am running the app in the iOS simulator.

I am not sure why it is doing that when I am not explicitly closing it.

Here are the capabilites i am setting:
capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, “1.0”);
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “iOS”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “9.2”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “iPad 2”);
capabilities.setCapability(“autoAcceptAlerts”, true);
capabilities.setCapability(“sendKeyStrategy”, “grouped”);
capabilities.setCapability(“fullReset”, false);
capabilities.setCapability(“noReset”, true);
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

and once the test is finished the regular afterTest and afterClass looks like
@After
public void tearDown() throws Exception {
if (null != driver) {
driver.quit();
}
}

@AfterClass
public static void afterClass() {
    if (service != null) {
        service.stop();
    }
}

plz note tht i have a single test class with just one test case.

Another odd behavior:
after running the test case if i try to launch the app again using command line as
xcrun instruments -w 2E755803-3DFD-4722-B6B7-25498BCFF551

then the app launches with a white canvas with no contents at all. Launching by manual clicking the app icon in the simulator works fine though.

any help on this please

Yes, driver.quit() will close the application (or at least remove it from the foreground in the context of mobile operating systems). The documentation specifies that this is the intended behavior.

I do not know of a way to end a web driver session without closing all windows. What particular reason do you have for needing the application to remain in the foreground?

1 Like

thanks for responding. We are in a situation where we invested on another automation tool and that automation tool has one of the big limitation of not able to close system notifications automatically.

So, we are planning to use a hybrid where we want to use appium to login and then continue with the another tool to do the testing.

I wrote a shell script for it where as a first step it does mvn test and then once it is finished. I want to start with another automation tool. However, as app is closed once appium finishes so i want to first launch the app and then start the operation.

Hmm… I haven’t dealt with iOS system notifications in a long time, so I’m not really rusty on the details. Can your second automation tool launch the application itself? Do the notifications pop up still for your second automation tool even after the first automation run with Appium?

My thinking is that if you log in using Appium, the login credentials are likely to be stored in the application’s private data directories, so when you launch the application a second time with your second automation tool, your test user is already logged in.

1 Like

yes exactly avoiding system notification is the reason to use appium here. and after first run using appium we want to continue with 2nd tool for real testing.

Basically, monkey talk is the second automation tool here. i could not find so far if it can launch app so i thought to use xcrun command line to launch the app.

basically i am not sure why xcrun launch the blank canvas and manually click and launch works fine.