Reputation: 1484
Can someone help to find the right xpath for this?
I need to capture the country code, for that i need to identify the element. I tried following xpaths, with no luck.
The linerarlayout at index 1
//[@class='android.widget.LinearLayout' and @index=1]/.//[@resource-id='com.whatsapp:id/country_code' and @index=1]
//[@class='android.widget.LinearLayout' and @index=1]/..//[@resource-id='com.whatsapp:id/country_code' and @index=1]
//[@class='android.widget.LinearLayout' and @index=1]/../[@resource-id='com.whatsapp:id/country_code' and @index=1]
Upvotes: 1
Views: 176
Reputation: 89315
None of the XPath you posted is valid. Basically, predicate (expression in []
brackets) need to be applied on a context element, for example on a TextView
:
//android.widget.TextView[@resource-id='com.whatsapp:id/country_code']
The XPath above will find <android.widget.TextView>
element, anywhere in the page, where resource-id
attribute value equals "com.whatsapp:id/country_code"
. Assuming that resource-id
attribute is unique, that XPath should be enough to find the target TextView
.
Upvotes: 1