The Problem is that scrollIntoView swipes don and then up to find the element. But when you can refresh the site by swiping down, it only scrolls down once. Why is it like that, and is there a different possibility? Code Snippet:
await driver.$(`android=${`new UiScrollable(new UiSelector().scrollable(true)).setSwipeDeadZonePercentage(0.4) .scrollIntoView(new UiSelector().resourceId("resource-id of the element"))`}`);
var j = 0;
var i = 0;
for (; i < 100; i++) {
sleep(500);
await driver.$(`android=${`new UiScrollable(new UiSelector().scrollable(true)).setSwipeDeadZonePercentage(0.4) .scrollForward()`}`);
sleep(500);
var list = await driver.findElements("id", "resource-id of the element");
if(list.length != 0) {
j += 1;
if (j == 3) {
await driver.$('//android.widget.ImageView[@resource-id="resource-id of the element"]').click();
sleep(500);
i = 100
}
}
if(i == 99) {
console.log("error message")
}
}