The_Amol
The_Amol

Reputation: 309

Locating Child element of the web element from a list of elements for android application using selenium xpath

I am locating element for android application and have one query. I am storing list of web elements as below

List<WebElement> trackingsList =  tracking.getTrackingElements();

getTrackingElements() is function that is returning list of WebElements and is returning elements fine, this is checked. now I want to get a child element of the webelement at position trackingList.get(0) using xpath. enter image description here so i tried like

trackingsList.get(0).findElement(By.xpath("//android.widget.LinearLayout"))

but it is not working. any help really appreciated.

Upvotes: 2

Views: 903

Answers (1)

Florent B.
Florent B.

Reputation: 42528

To get the targeted element by class name :

trackingsList.get(0).findElement(By.className("android.widget.LinearLayout"));

And by tag name:

trackingsList.get(0).findElement(By.tagName("LinearLayout"));

Upvotes: 2

Related Questions