I want to count no of stores in my screen

Hi Guys,

In my app, there is 2 LinearLayout view in one screen i.e Top view is Map view and Bottom view is Store List view.
So i want to count no of stores listed in the bottom (LinearLayout 2) view .So kindly help me any one know the answer for this.

I tried scrollTo (text) but its not scroll in the page only …

If i scroll the 2nd LinearLayout view its not scrolling

scrollTo(text) is working in all page except this page

Please let me know if you need some more info

You can retrieve references to each of your Linear Layouts using the class name locator strategy (this is usually done through the use of By.className() method in Java). Your bottom linear layout should be the second one in the list of elements returned. Beware, if you have nested linear layouts in your top layout, or any other layouts in places you don’t expect, it will throw off the index of the linear layout you want to work with. A better solution is to ask your developers to add in a content-description ID to the linear layout you want to test so you can retrieve the layout using the AccessibilityId locator strategy instead.

I’m not quite sure what application is this, but in your list, if there is 1 list element per store, then you simply need to count the number of items in your list. This is actually rather difficult for Android UiAutomator and Appium tests because there is not a consistent way to differentiate one list item from another. You could try to retrieve some text elements from the list, but then you’ll have to find a way to build a list of elements within your test.

As for scrolling the list, you’ll have to retrieve the size and position of the list element sitting in your second layout. You can then use your driver’s swipe() method to scroll through the list (check your library’s documentation for the details of this method). scrollTo() could work, but there are many use cases where scrollTo’s generic implementation is not special enough for those use cases.