使用appium获取线性布局的索引

时间:2015-10-11 14:15:08

标签: android selenium xpath appium selendroid

我正在使用LinearLayouts。所以我想要那些具有content-desc的线性布局的索引为" product-list"。

所以我做的是:

 List<WebElement> allIdsOnCurrentScreen = driver.findElements(By.xpath("//*[@class='android.widget.LinearLayout']"));
 for(int i=0;i<allIdsOnCurrentScreen.size();i++){
        if(allIdsOnCurrentScreen.get(i).getAttribute("name").toString()=="product_list")
            System.out.println(allIdsOnCurrentScreen.get(i).getAttribute("index"));
    }

但我无法获得这样的索引:

System.out.println(allIdsOnCurrentScreen.get(i).getAttribute("index"));

怎么做?我希望屏幕上当前可见的线性布局的索引包含content-desc&quot; product_list&#39 ;;

2 个答案:

答案 0 :(得分:0)

您只是无法通过appium读取'index'属性,这是一个框架限制。至少现在。

答案 1 :(得分:-1)

请使用“content-desc”并再次运行,而不是使用属性“name”。