A pragmatic approach to QA and OPS

Getting Started with Test Script

In order to write our first test case, let’s fire up Appium installed in last video




Now click on the Lens icon to start a inspector session as shown.




Now, we’ll need to establish a connection of Appium with the .apk and the simulator. To do so, in the inspector session, add a new Desired Capabilities


A sample set of DesiredCapabilities is given in the picture. The four given above are absolute must for establishing a connection. Here

app is the absolute location of the signed .apk file that we got in earlier steps.

platformName is the name of the target platform that your simulator is created against.

platformVersion is the version of Android that you’re targeting.

deviceName is the name of your device/simulator.

Once done, hit the Start Session button to establish the connection.





Element Hierarchy

In order to interact with elements in Appium, we need to find them first, so that we can use the various locators strategies to find the suitable locator for the element that we want to work with.


There are two approaches to see the hierarchy tree for elements for using in Appium


Approach 1 :

Using Appium Desktop


Once you open the inspector session, the Appium Inspector will mirror the screen on the Android simulator. You can then use the options provided at top get the elements in the hierarchy tree.



Approach 2

Using UIAutomatorViewer

Inside the tools/bin of your Android SDK, you’ll find the .bat file for UIAutomatorViewer. Double click on it to start it.




Click on this icon to take a screenshot of the screen of the simulator



Now click on any co-ordinate and it will show the elements in hierarchy tree


Note : Do not try to take a screenshot of a device screen or simulator, when Appium server is running. This may cause the UIAutomatorViewer failing to take a screenshot. Always switch off the Appium server before taking the screenshot.


Finding Elements


Appium gives slightly different selectors than Selenium. The following can be used as selectors for Android

  • By Name
  • By ClassName
  • By Xpath
  • By AccessibilityID
  • By AndroidUIAutomator
  • By ID


There is a very detailed tutorial here on this blog. Please read through this post which will explain how to use the selectors.


In our next tutorial, we’ll try to create a simple test script to run few open the app and perform something.

Next tutorial in this series here.

%d bloggers like this: