Reputation: 1280
I am doing an automation project in seleium and I need to get the number of elements that my action bar contains.
I am getting using appium and UI automator for this.
Below is the screenshot of the element.
Now, I wish to get the list(or count) of the children elements of the the DriverLayout.
I am using
String actionbarlayout = "android.support.v4.widget.DrawerLayout";
WebElement li = driver.findElementByClassName(actionbarlayout);
Any idea how can I get the nodes/elements list from li
?
Thanks a lot.
Upvotes: 1
Views: 2329
Reputation: 1023
Why do you want to find the list of all the items in the actionbarLayout? I feel that finding the count of all similar elements makes more sense. For example, you can find the list of all the elements of type TextView. The code for that would be -
List<WebElement> allTextViews = li.findElements(By.ClassName("android.widget.TextView"))
for(WebElement element : allTextViews) {
System.out.println(element.getAttribute("name")); //This returns the content-desc property
}
Upvotes: 4