Appium Can';t使用UIAutomator2向后滚动

Appium Can';t使用UIAutomator2向后滚动,appium,ui-automation,Appium,Ui Automation,我试图使用下面的代码段向后滚动,但它抛出错误 代码片段 try { getTLDriver().findElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).setAsVerticalList().flingToBeginning(5);")); } catch(Exception e){ e.printStackTrace(); } 错误: org.openqa.seleniu

我试图使用下面的代码段向后滚动,但它抛出错误

  • 代码片段

    try {
    
        getTLDriver().findElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).setAsVerticalList().flingToBeginning(5);"));
    }
    catch(Exception e){
         e.printStackTrace();
    }
    
  • 错误:

    org.openqa.selenium.InvalidSelectorException: Could not parse expression `new UiScrollable(new UiSelector()).setAsVerticalList().flingToBeginning(5)`: Last method called on a UiScrollable object must return a UiObject object
    

有人愿意帮忙

我建议使用
TouchAction
在Android中执行滚动,例如:

Dimension screenSize = driver.manage().window().getSize();
TouchAction action = new TouchAction((PerformsTouchActions) driver);
action.press(point(screenSize.width / 2, screenSize.height / 2))
   .waitAction()
   .moveTo(point(screenSize.width / 2, screenSize.height / 4))
   .release()
   .perform();