2

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.

The_Amol
  • 309
  • 3
  • 15

1 Answers1

2

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"));
Florent B.
  • 41,537
  • 7
  • 86
  • 101
  • Thank @florent-b for reply.. but i am getting this error after using this.. "org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (Original error: Cannot use xpath locator strategy from an element. It can only be used from the root element) " – The_Amol Mar 31 '16 at 16:37
  • Have you tried with the by class name? : trackingsList.get(0).findElement(By.className("android.widget.LinearLayout")); – Florent B. Mar 31 '16 at 16:45