scrollIntoView 在找到元素之前停止

scrollIntoView stops before finding the Element

问题是 scrollIntoView 滑动然后向上滑动以找到元素。但是,当您可以通过向下滑动来刷新网站时,它只会向下滚动一次。为什么会这样,是否有不同的可能性? 代码片段:

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")
    }
  }