java - 是否可以通过在 Android 上使用 Appium 滑动来从最近使用的应用程序屏幕中终止应用程序?

标签 java android appium

我尝试通过定义起点和终点来使用 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)

All required codes can be found here

  • 187 - KEYCODE_APP_SWITCH

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

关于java - 是否可以通过在 Android 上使用 Appium 滑动来从最近使用的应用程序屏幕中终止应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61294707/

相关文章:

android - 如何让我的 ViewPager 一次只加载一个页面,即 setOffscreenPageLimit(0);

Android PopupWindow 不关闭

android - By和MobileBy的区别

ios - 适用于 iOS native 设备功能的 Appium 自动化

android - 通知不会在 Android 10 中取消

java - 在 MAC 中以编程方式启动 appium 1.5.3 服务器的命令行是什么?

java - 数组的随机洗牌

java - 从Mysql上传/下载word文件

java - JTextArea 按回车添加不必要的新行

java - 我可以直接从 RecyclerView 获取实体房间数据并将其保存到房间数据库吗?