Appium - 获取 UiScrollable 中的所有项目(包括不可见)
我需要使用 Appium 验证列表中(在 UiScrollable 内)所有 项目的文本。 以下方法对我不起作用:
driver.findElements(MobileBy.id("com.author.app:id/title"))
- 仅返回当前可见的元素(不执行滚动直到列表末尾)我知道即使一个项目不可见,也可以验证该项目(在整个列表中执行滚动)
WebElement element = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable("
+ "new UiSelector().scrollable(true)).scrollIntoView("
+ "new UiSelector().textContains(\"MyText\"));"))
但这只是针对一个预定义的项目。
- 我知道有一些方法,例如 getChildByText/getChildByDescription ,但它们需要一些文本(当我需要获取所有项目时)。
那么有没有办法获取所有列表项(包括滚动到当前不可见的项目)?
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/getChildByDescription
but 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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以做到这一点。它将根据您的元素可见性向上或向下滚动
There are two ways to do it . It will scroll up or down depending on your elements visibility