Question: is there a way to get the elements "passing", while scrolling?

The following code scrolls a list view very slowly so that I can get new elements that show when the scroll is over.

/**
* Scroll from the position of a given element to the border of the screen
/
fun iosScrollScreenFromOnePointToBorder(
driver: MobileDriver<
>,
originPoint: Point,
swipeDirection: SwipeDirection
) {
val borderEdge = 10
val screenSize = driver.manage().window().size

    // should not click outside the screen border. For some reason on iOS, clicks near the border won't work, so
    // the origin point is reworked to half the size of the screen
    if (originPoint.x >= screenSize.width / 2)
        originPoint.x = screenSize.width / 2
    if (originPoint.y >= screenSize.height / 2)
        originPoint.y = screenSize.height / 2

    val destinationPoint = when (swipeDirection) {
        SwipeDirection.DOWN -> Point(originPoint.x, screenSize.height - borderEdge)
        SwipeDirection.UP -> Point(originPoint.x, borderEdge)
        SwipeDirection.LEFT -> Point(borderEdge, originPoint.y)
        SwipeDirection.RIGHT -> Point(screenSize.width - borderEdge, originPoint.y)
        else -> throw IllegalArgumentException("Diretion '$swipeDirection' not supported")
    }

    IOSTouchAction(driver)
        .press(PointOption.point(originPoint.x, originPoint.y))
        .waitAction(WaitOptions.waitOptions(Duration.ofMillis(200)))
        .moveTo(PointOption.point(destinationPoint)).perform()

}

The above operation indeed scrolls correctly, but is very slow. I wonder if there is a way to count or retrieve / cache elements or “elements DOM” while a scroll or swipes takes place, I mean, store elements while they are moving because of the scroll / swipe. Something like this:

// gets all the elements ‘passing’ while scrolling. The elements need to match the given xpath
elementsListWhileScrolling = getElementsWhileScrollingToTheEnd(By.xpath(“//XCUIElementTypeOther”))

I see this is iOS and normally with iOS we can grab all elements. Also outside screen.

If you need just count or check texts - no need to scroll.

Hey @Aleksei

I noticed that on iOS the elements only show when on screen, although some of them are retrievable. I noticed that in a list view with 30+ elements, with 2 showing on screen only. An operation with getElements would return ~8 elements and the others only scrolling.

possibly our app loading elements dynamically while user scrolling. no need to load many items immediately.