我正在尝试使用以下代码片段向后滚动,但会引发错误
代码段
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
有人请帮忙
答案 0 :(得分:0)
我建议使用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();