Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close/kill an app on android device using appium?

To kill/close app I tried driver.close(), driver.closeApp(), driver.quit() but the app keeps running on the background. Should one of these commands really close the application? If so, the how? If not - could someone offer an alternative solution?

like image 566
Chechy Thehost Avatar asked Dec 03 '22 15:12

Chechy Thehost


1 Answers

None of the method that you are calling removes the app from background while using appium. This is what they refer to :

((AppiumDriver)driver).closeApp(); // Close the app which was provided in the capabilities at session creation   

((AppiumDriver)driver).close(); // from *RemoteWebDriver.java*, used to close the current browser page  

((AppiumDriver)driver).quit(); // quits the session created between the client and the server

so what you could possibly try and do is :

((AppiumDriver)driver).resetApp(); // Reset the currently running app for this session

OR try a combination of these two :

((AppiumDriver)driver).removeApp(<package name>); // Remove the specified app from the device (uninstall)
((AppiumDriver)driver).installApp(<path to apk>); // Install an app on the mobile device
like image 164
Naman Avatar answered Dec 06 '22 11:12

Naman