如何使用 webdriverio 和 appium 按住并向下滚动

how to press tap and hold and scroll down using webdriverio and appium

如何使用 webdriverio 和 appium 按住并向下滚动。我使用了普通卷轴,但似乎没有任何效果。我可以手动按住并滑动,但以下命令不起作用

这是我尝试过的,但是,我无法用它实现任何目标:

browser.touchAction([
                { action: 'longPress'},
                { action: 'moveTo', x: -10, y: 0},
                { action: 'release'}
            ])
        }

我使用以下内容向下滚动我的 appium python 项目

for each in range(1, 2):
            driver.swipe(500, 1700, 500, 1000, 400)

根据需要的滑动次数更改for循环

public static void fingerSwipe(int startX, int startY, int endX, int endY, long timeInMillis){
    PointerInput touchAction = new PointerInput(PointerInput.Kind.TOUCH, "touchAction");
    Interaction moveToStart = touchAction.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), startX, startY);
    Interaction pressDown = touchAction.createPointerDown(PointerInput.MouseButton.LEFT.asArg());
    Interaction moveToEnd = touchAction.createPointerMove(Duration.ofMillis(timeInMillis), PointerInput.Origin.viewport(), endX, endY);
    Interaction pressUp = touchAction.createPointerUp(PointerInput.MouseButton.LEFT.asArg());

    Sequence swipe = new Sequence(touchAction, 0);
    swipe.addAction(moveToStart);
    swipe.addAction(pressDown);
    swipe.addAction(moveToEnd);
    swipe.addAction(pressUp);

    driver.perform(Arrays.asList(swipe));
}

我使用 selenium 交互包使用 JAVA 和 appium 执行滑动。 尝试在 Appium 版本的 WebDriverIo 中使用类似于上述代码的内容 - 1.15.0 及更高版本。您只需要根据要执行的滑动来传递输入参数。

'long timeInMillis'为滑动的时间段

我用过这个:

  await browser.touchPerform([
    { action: 'press', options: { x: 500, y: 1280 }},
    { action: 'wait', options: { ms: 1000}},
    { action: 'moveTo', options: { x: 500, y:  347}},
    { action: 'release' }
  ]);