我的Appium测试具有水平滑动手势,但是执行滑动手势时速度很慢。有什么可行的方法吗?建议将不胜感激。
我已经添加了一些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();
}
,我也尝试此代码,但其输出相同 如您所见,我增加了一些持续时间。.
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();
答案 0 :(得分:0)
还有其他方法可以执行滑动/滚动:
使用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);
使用Swipe可用的SeeTest Appium Extension命令,如:
seetest.swipe("Right", 10, 500);