Reputation: 193
I am unable to identify element using xpath. I tried different types of xpath but could not identify it.
I want to identify the element "Bills" shown in the below pic. I don't have ID, so I am using xpath. I used below xpaths.
xpath=//android.app.ActionBar$Tab/TextView[@text='Bills'] and xpath=//android.app.ActionBar$Tab1/TextView[@text='Bills']
Please help me. I am struck here.
Upvotes: 4
Views: 3338
Reputation: 933
Use this :
xpath=(//android.widget.TextView[@text='Bills'])[1]
Its clear that there is index for this element from the UI Automator Viewer
Note:Group Index starts from 1.
Upvotes: 0
Reputation: 157
You should use "class" of each selector for your xpath:
xpath=//android.widget.TextView[@text='Bills']
and if this wouldn't work, it means that you should add some previous classes (in higher hierarchy) in front of this one for this xpath to be unique.
Upvotes: 2
Reputation: 944
Some times above xpath won't work.. it could be start from their parent elements like below,for eg:
Xpath=//android.widget.linerlayout[1]/android.widget.linerlayout[1]/android.widget.TextView[@text='Bills']
Upvotes: -1
Reputation: 733
Since you don't seem to have any other element with the same properties, it might work if you remove the problematic part from the xpath and try with just:
xpath=//TextView[@text='Bills']
Upvotes: 0