2015-10-11 28 views
1

我有LinearLayouts。所以我想索引那些内容为“产品列表”的线性布局。使用appium获取线性布局索引

所以我所做的就是:

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'product_list'的屏幕上显示线性布局的索引。

回答

0

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