我正在尝试进行滑动,直到该元素在Android应用程序屏幕上可见,但是该元素未出现在屏幕上,并且代码给出错误,表明它无法执行滑动并未能通过测试。 / p>
public void moveToAndroidElement(By element, int tentativas, Direction direction) {
TouchAction press;
AndroidElement elemento = driver.findElement(element);
int y;
int count = 0;
boolean elementFound = false;
while(count < tentativas && !elementFound) {
y = elementMiddleGetY(element);
System.out.println("Element position:" + y + " ScreenSize: " + screenY);
if(y > getScreenY()) {
swipe(getScreenMiddleX(), getScreenMiddleY()-100, getScreenMiddleX(), 0, 1000);
press = new TouchAction(driver).press(screenMiddleX, screenMiddleY).waitAction(250).release();
press.perform();
count++;
} else {
elementFound = true;
break;
}
}
assertTrue(elementFound);
}