如何使用appium关闭/杀死Android设备上的应用程序?

Che*_*ost 4 java android kill appium

要杀死/关闭应用我试过,driver.close(), driver.closeApp(), driver.quit()但应用程序继续在后台运行.其中一个命令是否真的关闭了应用程序?如果是这样,怎么样?如果没有 - 有人可以提供替代解决方案吗?

Nam*_*man 5

在使用appium时,您调用的方法都不会从后台删除应用程序.这是他们所指的:

((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
Run Code Online (Sandbox Code Playgroud)

所以你可能尝试做的是:

((AppiumDriver)driver).resetApp(); // Reset the currently running app for this session
Run Code Online (Sandbox Code Playgroud)

或尝试这两者的组合:

((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
Run Code Online (Sandbox Code Playgroud)


Emn*_*mna 3

我会建议 :

  • 重置应用程序()

  • 关闭应用程序()

  • 删除应用程序()

    你可以参考这个链接:Java-client Appium