Salman Arshad
Salman Arshad

Reputation: 59

Android application xpath with content desc - handle the line break

Objective: To click on Access for all guest users. I am unable to find this element.

uiautomatorviewer shows the following screenshot. enter image description here

Content description is following copy/pasted "Access for all guest users Provider not listed? Stay tuned, we will be adding more TV providers shortly."

Notice: the line break after user. I believe this is why my xpath is not working.

My xpath is: "//android.view.View[@content-desc ='Access for all guest usersProvider not listed? Stay tuned, we will be adding more TV providers shortly.']"

I cannot use index instead of content-desc because of the object in layers above have the same class and index.

Using tap to a specific might solve the problem but is not a good solution. any ideas on how to handle that linebreak.

Upvotes: 0

Views: 2937

Answers (1)

Anish Pillai
Anish Pillai

Reputation: 1023

If you notice the XML hierarchy, you will notice that your element is inside a WebView (3rd node from top). So its not getting identified. You have to first switch to WebView and then use your code.

The way you mentioned the xpath should work, once you switch to WebView.

Upvotes: 2

Related Questions