Getting index of Linear Layouts using appium

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 and getting error when I run this :

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

How to do it ?

Yes u cannot read every attribute of element node u see in uiautomator using get attribute method of selenium…

name will read content-desc of node
and value will read text of node

This may be a limitation of framework or appium might not have implemented these…

@amitjaincoer191 So I can’t read index of Linear Layout ?

Yes you cannot read index attribute value but u can click element using it something like…

new UISelector.index(1)

@amitjaincoer191 Is there no way to get it ? Actually I want to make enuse by the index that I had reached end of page after swipping to the bottom.

Sorry I Dont know…
But if u know @index=35 end of page is reached then u can try like this

driver.findElement(By.xpath("//class name[@index=‘35’]")).size() greater then 0

@amitjaincoer191 Can I get resource ids of all available fields present under a layout ? Like if say one Linear Layout is having three textfields having resource ids say textField1,textField2,textField3 and second linear layout contains resource ids textField1,textField2 only

@amitjaincoer191 Help for this : Find if the Layout has particular text view or not . I had described my problem in detail here