【问题标题】: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());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-19
      • 2016-05-11
      • 2019-11-18
      • 2014-10-08
      • 2020-04-02
      • 2016-03-19
      • 2019-05-24
      • 2017-11-26
      相关资源
      最近更新 更多