无法使用 TouchActions 滚动

Unable to use TouchActions to scroll

我能够使用我使用触摸操作编写的滚动方法,但现在我 运行 它时出现编译错误。我现在应该使用什么或如何解决编译问题?

public void scrollDown() {

    AndroidDriver androidDriver = ((AndroidDriver)((WebDriverFacade) getDriver()).getProxiedDriver());
    TouchAction touchAction = new TouchAction(androidDriver);

    Dimension size = androidDriver.manage().window().getSize();
    int startX = size.width / 2;
    int startY = (int) (size.height * 0.60);
    int endY = (int) (size.height * 0.30);
    touchAction.longPress(startX, startY).moveTo(startX, endY).release().perform(); // error on this line pointing to startX and startY within longpress()
}

下面是编译错误

method io.appium.java_client.TouchAction.longPress(io.appium.java_client.touch.offset.PointOption) is not applicable
  (actual and formal argument lists differ in length)

您缺少持续时间参数

new TouchAction(driver).press(ElementOption.element(element1)) .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3))).moveTo(ElementOption.element(element2)).release().perform();<br>

您可以使用以下方法刷屏

public void verticalSwipeByPercentages(double startPercentage, double endPercentage, double anchorPercentage, AppiumDriver<MobileElement> driver) {
    Dimension size = driver.manage().window().getSize();
    int anchor = (int) (size.width * anchorPercentage);
    int startPoint = (int) (size.height * startPercentage);
    int endPoint = (int) (size.height * endPercentage);

    new TouchAction(driver)
            .press(PointOption.point(anchor, startPoint))
            .waitAction(WaitOptions.waitOptions(ofSeconds(1)))
            .moveTo(PointOption.point(anchor, endPoint))
            .release().perform();
}