What is best way to use xpath to find out an element

I am using below ways to click on dynamic elements using xpath in android.

  1. Using entire xpath from Root layout


  1. Or using UiSelector:

ex: ‘-android uiautomator’, ‘new UiSelector().clickable(true).className(android.widget.TextView).index(1)’).click()

Both ways are working fine, but just curious to know which one is best option to search element faster…

1 Like