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

标签 java android appium kill

为了终止/关闭应用程序,我尝试了 driver.close()、driver.closeApp()、driver.quit(),但该应用程序一直在后台运行。 这些命令之一真的应该关闭应用程序吗?如果是这样,如何?如果没有 - 有人可以提供替代解决方案吗?

最佳答案

在使用 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

所以你可以尝试做的是:

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

或者尝试将这两者结合起来:

((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

关于java - 如何使用 appium 关闭/杀死 android 设备上的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37178914/

相关文章:

java - 进入 Debug模式后 Eclipse 会阻止编辑

java - 在 JasperServer 和 iReport 中查看报告时出错

android - 将驱动程序添加到 Android 设备内核

Android 使用 Intent 显示网页

android - adb 等待设备超时/非阻塞?

java - TestNG 并行测试未在 2 个真实的 android 设备上运行。

ios - Appium - iOS - 应用程序路径必须是绝对路径或压缩文件的 URL

java - 可修改列表的接口(interface)

java - JPA - 如果不存在则创建实体?

appium - 运行 Appium-doctor 时收到警告