Can anybody help me to get xpath of an element

Hello everyone,

I am automating an android application. For inspecting elements i am using uiautomatorviewer. And the element do not have any id associated with it so i was trying to get the xpath of that element. But as far as i know, we need classname in order to create xpath for inspecting any element and the element which i am trying to inspect does not have any classname. I can not share the screenshot/hierarchy of the element which i am trying to inspect as i can not share the application but i found an example of the scenario which i am facing and that is in messenger application. I am attaching the scenario, please have a look to it.
Any help would be welcomed.


it looks like webview. try to switch into webview. better never use xpath. try to check upper elements - do they have any ID?

@Aleksei most of the elements do not have ID’s.
And in order to switch into webview, i must have the locator for the element. But i am unable to locate the elements in webview.

does the (2)ViewGroup have an ID? in most cases they should have and you can declare it as a list and then clin on 0, 1 or 2. Can you click on it and share the screenshot?
or you could try fo find the element by partial content description using People, Chat or Discover string.
But it’s not the best solution.

wrong. just walk what “driver.context” i available on this screen and if it contains WEBVIEW → switch to it