How to count the elements in a scrollable list using appium


Hi All,

I am very new to Appium and facing an issue while using it
I have a mobile application which I am trying to automate using Appium. The app has a "scrollable list ". I want to count the number of elements present in it.
How can I achieve this ?

Thanks in Advance
Sushanta Dasgupta


Use java list and get the count…

If u want to iterate write a custom code to iterate until an element is visible and then scroll for next set of elements,.



Thanks for replying.

I have already tried that and my problem is slightly different
In my mobile application, I have a scollable list. For example - If my screen can show only 10 items, I have 20 items in my list. So, I need to scroll the list to see and count all the items.
So, when I first get the scrollable list on my screen I count the items which are being displayed and then scroll

Process that I follow -

  1. Launch the app and get the list
  2. count the no of elemnts which are being displayed in the list
  3. Scroll the list element by element (i.e. Scroll the list for one element only)
  4. Increase the count and scroll again
  5. Repeat steps 3 and 4 till I get end of list

I am facing an issue in step 3 and 4

Issue is :
I know the exact length of my element, which means I know how much to scroll to bring the element in my visible list.
Length : 110
I have used swipe function to perform the scroll which looks like this : driver.swipe(200,1194,200,1084,1000);

But, the issue is that it does not scroll the exact amount every time. Sometimes, it scrolls and pulls only half element, sometimes 80% of the element. As a result of this the count I get is incorrect.

So my doubts here are -

I. Is there any method which can scroll properly ?

II. Is there any method which can scroll the list by itself and count the list of all the elements present in a scrollable list ?

Thanks in Advance,
Sushanta Dasgupta


Hi @Sushanta_Dasgupta: did you get a solution for this?



Hi…Were you able to resolve this?Please reply ASAP facing the same issue


Just a thought , instead of swiping indefinitely , Consider swiping from last element visible on the listview to the top element visible , and slow the swiping as much as possible by giving a wait option .

List objList=driver.findElements(By.xpath("//[@resource-id=‘your_id’]/child::"));

		Point p1=getPoint(objList.get(objList.size()-1));
		Point p2=getPoint(objList.get(0));
	        new TouchAction<>(driver)
	                .press(PointOption.point(p1.x, p1.y)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(5000)))
	                .moveTo(PointOption.point(p2.x, p2.y)).release().perform();
        private Point getPoint(WebElement element)
    		return element.getRect().getPoint();

Here 5 seconds of wait make sure that swipe action get ample time to do the swipe from p1 to p2 .
each iteration you may count the element’s till end ( ofcourse by removing repeated element’s from top)