【问题标题】:appium not getting elements inside RecyclerViewappium 没有在 RecyclerView 中获取元素
【发布时间】:2019-01-16 11:36:53
【问题描述】:
我需要在 RecyclerView 中获取每个 FrameLayot div 值。
AS Shown in the image
我使用了代码
List<WebElement> ulElement = driver.findElements(By.id("pager"));
int sz = ulElement.size();
System.out.println(sz);
但是得到的结果是 1 而不是 9
【问题讨论】:
标签:
automated-tests
appium
appium-android
appium-desktop
【解决方案1】:
如果你想得到 9 的结果,你应该使用下面的代码:
List<WebElement> ulElement = driver.findElements(By.xpath("//android.support.v7.widget.RecyclerView[@index='0']/give_the_class_name_of_framelayout"));
int sz = ulElement.size();
System.out.println(sz);
你必须给定位器这样的值,这样它就会返回 9 个匹配的元素。希望对您有所帮助。
【解决方案2】:
我通过拆分视图得到了结果
WebElement parentElement = driver.findElement(By.id("com.mathrubhumi.silverbullet:id/mlist"));
List<WebElement> childElement = parentElement.findElements(By.id("com.mathrubhumi.silverbullet:id/rootview"));
System.out.println(celement.size());