06 Apr 2017

Appium – Mobile App Automation

Appium, Testing 0 Comment

                 This article will show you how to run first automation script for testing android mobile app using appium server.

Before that,  we need to create a new maven project and update the pom file with below mentioned Selenium dependency. I am assuming you are familiar with Java project creation in Eclipse. Let me include a brief step by step guide to creating a project.

  • Open Eclipse ( I’m using : Neon.1a Release (4.6.1) )
  • Click on File > new > Maven Project

  • Click on Next > Click on Next >

Where Artifact Id is your project name, Group Id is your project path folder structure

  • Click on Finish

Once the project is created, copy the below dependencies in the pom.xml file.

Just we created the maven project with updated pom.xml file and we need to launch some tools.

  1. UiAutomator viewer  —  Used to find out android mobile app elements (id, classname, XPath).
  2. Appium server  — inform the appium server which kind of session we are interested in (via Desiredcapabilities ).
  3. Real Device / Emulator.

UiAutomator viewer: Which is used to find out android mobile app elements like id. Classname, XPath.

If you want to open the UiAutomator viewer, Go through this path

Ex: C:\Users\akumar\AppData\Local\Android\sdk\tools

  • Connect your android device to PC via USB cable
  • Enable your device in “Debugging mode”.   
  • Click on uiautomatorviewer > Click on this image button to refresh the device screen in Automator viewer.

  • Make sure before click on above image button, we need to launch our android mobile with our app (Which we want to test the app).

Ex; Here I’ m using the  “ dialer “ android app for making a call to someone

  • After that, we need to click on image button which I have marked as red color.

  • clicking on the each node gives you properties of UI element in the lower panel

By the above Image will show you how to take android mobile app elements ( id, text, classname ).

    • text attribute can be used as “name”
  • a resource-id attribute can be used as “id”
    • class attribute can be used as “className”
  • a content-desc attribute can be used as “AccessibilityId”

If you want XPath, you can write manual XPath using below syntax

Locating Android App Element By XPath:

  1. XPath using class and text attribute:

Ex: Take Calculator android app:

Syntax:   //class_name[@Attribute=’Value’]


IMP :-  I will show you one example about Dialer app testing, just copy the code and paste it inside your java class.

Then Start appium server, below steps, show you how to start appium server on command prompt

  1. Navigate to C: -> Program Files -> Appium -> node_modules folder.

 Ex: C:\Program Files (x86)\Appium\node_modules

  1. Press and hold Ctrl + Shift Keys of keyboard and press mouse right click.
  2. Select “Open command Window here” from the context menu.
  3. It will open a command prompt with navigation to given node_modules folder path.
  4. Type command ” node appium ” In command prompt and press enter then appium server will start.

Note: All set for running our script, make sure before running our script we need to launch first appium server.

Thank you for reading this article!