Skip to content
/ .. / .. /
Find the XPath for Apptest





Finding XPaths for Apptest

Find the XPath
Find an Element XPath with UI Automator Viewer
Find an Element XPath with Selendroid

Find an Element XPath with UI Automator Viewer

To find an XPath using UI Automator Viewer, use the following steps:

  • Start the app to be tested on the Android device.

  • Start uiautomatorviewer and take a screenshot.

  • Locate the elements of interest on the screenshot using the cursor/mouse. This will reveal the resource ID and the tree structure on the right-hand side.

This information can then be used to construct an XPath.

Find an Element XPath with Selendroid

Finding an element's XPath can be done on a phone using Selendroid's Inspector. If a phone is connected to the computer and the test case is running, open a browser window and enter localhost:4444/inspector. A window similar to the one below will appear.

alt text

  • The left side shows the phone's app loading.

  • In the middle section of the window, there is a tree view of the page.

  • The right side shows the details. There is also the ID box (third from the bottom).

    • This box shows the name of an element so it can be addressed it properly in a UI Steps (in this case, home).
    • Because names may overlap, be careful when addressing an element via Id. If this happens, use the XPath Helper by pressing ESC.

alt text

The XPath Helper identifies elements. Its coding sometimes differs from intaQt's. For example, the XPath finder writes:

1
//id('left_drawer')/[4]

intaQt needs it to be:

1
id('left_drawer')/*[4].