1

I am having LinearLayouts. So I want index of those Linear Layouts which have content-desc as "product-list".

So what I did was :

 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"));
    }

But am not able to get index like this :

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

How to do it ? I want index for the Linear Layouts that are currently visible on screen with content-desc 'product_list';

GitCoder
  • 121
  • 2
  • 13

2 Answers2

0

You just cannot read the 'index' attribute by appium, it's a framework limitation. For now at least.

-1

Instead of using attribute "name" please use "content-desc" and run it again.

Gaurav
  • 1,332
  • 11
  • 22