Create XPath in APPIUM

Price: INR 8,999.00
Price: INR 14,999.00
Was: INR 16,999.00

Let’s see, How can you create XPath in Appium. In the previous tutorial, You have seen How to locate the App Elements using UI Automator.


Now question is, What kind of Locators you can use in APPIUM, Is APPIUM accept all locators?

The answer is NO. APPIUM doesn’t support all Locators.APPIUM doesn’t support locator named “tagName”.


So if any element doesn’t have ID then how can you locate that element. The answer is using XPath. We will see, How can you create the XPath for the App Elements.


Create XPath in Appium

To create the XPath for App Element or Elements. You need to follow some steps –

  • The first step, Connect your device to your PC.

  • Check using DDMS in eclipse that device is connected properly or not.

  • Start the UI Automator using UIAutomator.bat file.

  • Now open your application in your mobile phone.

  • Now click on the icon Device Screen Shot in UI Automator.

  • Now click on the Element, for which you want to create the XPath.

Find Element using UI Automator


I am using the Android App ‘CarWale’ for example. You can see, as you clicked on the “FIND CARbutton. Button got highlighted and in the Properties, We got all properties of this button. Like text, class, ID and Package.


Resource-Id is the ID of this Element and Class is the Class of this element. In Android class always starts with android.widget

Basic Syntax for XPath – //Class Name[@attribute=’Value of attribute’]

So for ‘FIND CAR’ button XPath would be like –

  • XPath on the basis of ID

  • If ID is not present and we want to create XPath using present text then XPath would be like –
    //android.widget.Button[text()=’FIND CAR’]


You can use this XPath to locate the FIND CAR button and use this in your Test Script. Sometimes XPath doesn’t work with APPIUM, So we need to use UI Automator Properties directly, We will see How can we perform this in coming tutorials.

0 Comment

Leave a Reply