Cannot compute child count in ListView, RecyclerView or any other scrollable view in Android with Appium

I agree. This is a pretty major pain when writing tests with Appium.

I can understand some of the difficulties with implementing some feature to count the number of items in a list view, however. Robotium and Espresso (white box, instrumented tests in general) have the advantage of being white box tests, so they can query the adapter backing the list view directly for the information of the child elements (and they can also control the list view to scroll to exact positions). OTOH, UiAutomator was intended for black box tests, since the benefit of UiAutomator was to switch between various different apps in different processes. Unfortunately, this also meant that UiAutomater loses the ability to query adapters and list views for the number of data items.

If I know my UiAutomator well, UiCollection and UiScrollable will scroll through the list and search the child elements that match a particular UiSelector and not necessarily count all the child elements of the list.

1 Like