简体   繁体   English

滑动手势非常慢,…如何在android中加快我的滑动手势?

[英]Swipe gesture is very slow,…how to speed up my Swipe Gesture in android?

I have horizontal swipe gesture for my Appium test but when it is executed to the swipe gesture is very slow. 我的Appium测试具有水平滑动手势,但是执行滑动手势时速度很慢。 Is there any posible way to do it? 有什么可行的方法吗? Suggestion will be really appreciated. 建议将不胜感激。

i already add some waitAction() but it does not help 我已经添加了一些waitAction()但没有帮助

  public void horizontalSwipeRightToLeft(AndroidDriver driver){
        Dimension deviceDim = driver.manage().window().getSize();
        int height = deviceDim.getHeight();
        int width = deviceDim.getWidth();
        int y = (int) (height*0.20);
        int startX = (int) (width*0.80);
        int endX = (int) (width*0.20);
        TouchAction swipe = new TouchAction(driver);
        swipe.longPress(point(startX,y))
                .moveTo(point(endX,y)).release()
                .perform();
    }

and i also try this code but its the same output as you can see i added some duration.. 并且我也尝试了这段代码,但是它的输出与您看到的一样,我增加了一些持续时间。

TouchAction swipe = new TouchAction(driver);
        swipe.longPress(LongPressOptions.longPressOptions()
                .withPosition(point(startX,y))
                .withDuration(Duration.ofMillis(250)))
                .moveTo(point(endX,y)).release()
                .waitAction(WaitOptions.waitOptions(Duration.ofMillis(100)))
                .perform();

There are alternative approaches to perform swipe/scroll: 有其他方法可以执行滑动/滚动:

  1. Using mobile:shell command like: 使用如下的mobile:shell命令:

     Map<String, Object> args = new HashMap<>(); args.put("command", "input"); args.put("args", Lists.newArrayList("swipe", "startX","startY","endX","endY")); driver.executeScript("mobile: shell", args); 
  2. Using Swipe command available via SeeTest Appium Extension like: 使用可通过SeeTest Appium Extension可用的Swipe命令,例如:

     seetest.swipe("Right", 10, 500); 

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

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