1

我需要在 RecyclerView 中获取每个 FrameLayot div 值。

如图所示

我使用了代码

List<WebElement> ulElement = driver.findElements(By.id("pager"));

int sz = ulElement.size();

System.out.println(sz);

但得到结果为 1 而不是 9

4

2 回答 2

0

我通过拆分视图得到了结果

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());
于 2018-10-12T10:18:26.467 回答
0

如果你想得到 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 个匹配的元素。我希望这能够帮到你。

于 2018-08-09T11:50:09.613 回答