简体   繁体   English

是否可以通过在 Android 上使用 Appium 滑动来从最近的应用程序屏幕中杀死一个应用程序?

[英]Is it possible to kill an app from recent apps screen by swiping using Appium on Android?

I am trying to use Touchaction by by defining start point and endpoint, but it does not seem to work.我试图通过定义起点和终点来使用 Touchaction,但它似乎不起作用。 Any suggestions?有什么建议么?

public static void swipeVertical(AppiumDriver driver, double startPercentage, double finalPercentage, double anchorPercentage, int duration) throws Exception {

    Dimension size = driver.manage().window().getSize();
    int anchor = (int) (size.width * anchorPercentage);
    int startPoint = (int) (size.height * startPercentage);
    int endPoint = (int) (size.height * finalPercentage);
    new TouchAction(driver).press(anchor, startPoint).waitAction(duration).moveTo(anchor, endPoint).release().perform();

    //In documentation they mention moveTo coordinates are relative to initial ones, but thats not happening. When it does we need to use the function below
    //new TouchAction(driver).press(anchor, startPoint).waitAction(duration).moveTo(0,endPoint-startPoint).release().perform();
}

swipeVertical(driver,0.9,0.1,0.5,3000);

Key presses on appium are done by appium 上的按键是由

driver.press_keycode(code)

All required codes can be found here 所有必需的代码都可以在这里找到

  • 187 - KEYCODE_APP_SWITCH 187 - KEYCODE_APP_SWITCH

Try this, not sure whether it solves试试这个,不知道能不能解决

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - 从最近的应用程序中滑动应用程序时停止服务 - Android - Service stops when swiping app from recent apps 如何在同一测试中使用Appium在Android中从内存中强制关闭/强制关闭/杀死应用程序 - How to hard close/force close/kill the app from memory in Android using Appium in the same test 如何使用 appium 在 android 设备上关闭/终止应用程序? - How to close/kill an app on android device using appium? 从Android中的最新应用中刷出应用后,服务停止 - Service stopped when app is swiped out from recent apps in Android 当应用程序从android中的最新应用程序列表中删除时,服务停止 - Service stopped when the app removes from recent apps list in android 如何使用 appium 在具有 recyclerview 的 android 本机应用程序中滚动屏幕 - How to scroll screen in android native app having recyclerview using appium Android:从最近使用的应用程序按钮关闭应用程序时未调用OnDestroy - Android: OnDestroy isn't called when I close the app from the recent apps button 从 Android 中的最近应用程序列表中删除应用程序是否会导致它禁用警报管理器在 Android 应用程序中设置的任何警报? - Does removing an app from the recent apps list in Android cause it to disable any alarms that have been set by the alarm manager in an Android app? 如何在Android Studio中以编程方式锁定近期应用中的应用 - How to lock app in recent apps programmatically in android studio 使用 Appium 在 Android 本机应用程序中滚动的问题 - Issue with Scrolling in Android Native app using Appium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM