繁体   English   中英

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

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

我试图通过定义起点和终点来使用 Touchaction,但它似乎不起作用。 有什么建议么?

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);

appium 上的按键是由

driver.press_keycode(code)

所有必需的代码都可以在这里找到

  • 187 - KEYCODE_APP_SWITCH

试试这个,不知道能不能解决

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM