Try this something like this, you can also scrollIntoView to a resourceID
@AndroidFindBy(uiAutomator = “new UiScrollable(new UiSelector()).scrollIntoView(text(“yourText”))”)
public MobileElement yourElementName;
Or something like this, for me works perfectly:
public void swipeUpUntilTextExists(String expected, int times) {
int i = 0;
do {
swipeUp();
i++;
if (i == times)
break;
} while (!driver.getPageSource().contains(expected));
}
public void swipeUp() {
Dimension size = driver.manage().window().getSize();
int starty = (int) (size.height * 0.8);
int endy = (int) (size.height * 0.2);
int startx = (int) (size.width / 2.2);
try {
log.info("Trying to swipe up from x:" + startx + " y:" + starty + ", to x:" + startx + " y:" + endy);
new TouchAction(driver).press(point(startx, starty)).waitAction(waitOptions(ofSeconds(3)))
.moveTo(point(startx, endy)).release().perform();
} catch (Exception e) {
log.info("Swipe did not complete succesfully.");
}
}
You can calculate and change the starting, ending points in swipeUp method in such way to swipe left, right or down.