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';