Xpath how to get the first element?


I’am trying to get the first element of my objects
I want to use something like : Mobile.tap(findTestObject(‘Plus1’), 1,FailureHandling.OPTIONAL )

In Object Spy I can find my “+” buttons (3 buttons) with resource_id attributes. I want to click the first one.

//[resource-id='fr.myobject:id/case_more] => returns my 3 elements
I try :
[resource-id='fr.myobject:id/case_more][1] => returns my 3 elements also.

How can I do to get the first one ?

Thank you

I need the first one :

Try with


Thanks a lot Helene, you saved my day !

This works :

1 Like