'Appium - get all items in UiScrollable (including not visible)
I need to verify text for all items in list (inside UiScrollable) using Appium. Following approaches are not working for me:
driver.findElements(MobileBy.id("com.author.app:id/title"))- returns only currently visible elements (do not perform scroll till the end of list)I know the way for verifying one item even when it's not visible (scroll is performed through the whole list)
WebElement element = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable("
+ "new UiSelector().scrollable(true)).scrollIntoView("
+ "new UiSelector().textContains(\"MyText\"));"))
But it's just for one predefined item.
- I know there are some methods like
getChildByText/getChildByDescriptionbut they require some text (when I need to get all items).
So is there any way to get all list items (including scroll to items that are not currently visible)?
Solution 1:[1]
There are two ways to do it . It will scroll up or down depending on your elements visibility
ThreadLocalDriver.getTLDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+element+"\").instance(0))"));
ThreadLocalDriver.getTLDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches(\"" + element + "\").instance(0))"));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Snehal Gajbhiye |
