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

**URL:** <https://discuss.appium.io/t/what-is-best-way-to-use-xpath-to-find-out-an-element/1212>\
**Category:** Support\
**Created:** [October 30, 2014, 7:43pm UTC](https://discuss.appium.io/t/what-is-best-way-to-use-xpath-to-find-out-an-element/1212 "2014-10-30T19:43:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![laxmi](https://discuss.appium.io/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@laxmi](https://discuss.appium.io/u/laxmi)\
**Post date:** [October 30, 2014, 7:43pm UTC](https://discuss.appium.io/t/what-is-best-way-to-use-xpath-to-find-out-an-element/1212/1 "2014-10-30T19:43:27Z")

</div>

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

1. Using entire xpath from Root layout

Ex:  
[//android.widget.FrameLayout](https://android.widget.FrameLayout)[1]/android.view.View[1]/android.widget.FrameLayout[2]/android.view.View[1]/android.widget.RelativeLayout[1]/android.widget.HorizontalScrollView[1]/android.widget.LinearLayout[1]

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…
