segment-pixel
For the best experience, try the new Microsoft Edge browser recommended by Microsoft (version 87 or above) or switch to another browser � Google Chrome / Firefox / Safari
OK
brand-elementsbrand-elementsbrand-elementsbrand-elementsbrand-elementsbrand-elements
brand-elementsbrand-elements

The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency.
-Bill Gates

Mobile applications are a new window to user solutions across businesses. With every user need shifting to mobile, the numbers of mobile apps are increasing. Therefore, the increasing competition to deliver quality apps is on the rise.

Testing mobile applications is becoming a key process before rolling out app releases to users. Hence, mobile test automation is the need of the hour to facilitate thorough testing of mobile apps efficiently in less amount of time.

Robot framework is an open source test automation framework used for Acceptance-Test Driven Development (ATDD) implemented using Python. It has an ecosystem which consists of various test libraries and tools that adhere to the keyword-driven approach of Robot framework.

One of the external test libraries for mobile test automation is Appium Library which uses Appium to communicate with Android and iOS applications. This blog is a walkthrough of how Robot framework communicates with Appium to bring out the best of Robot framework and Appium to mobile test automation with the help of a demo on running a test suite for testing a basic Android application.

Robot Framework

Robot Framework is a generic test automation framework released under Apache License 2.0. Robot has standard test libraries and can be extended by test libraries implemented either with Python or Java.

Key Features of Robot Framework

  • Ensures business keyword-driven, tabular, and easy to understand syntax for test case development
  • Allows creation of reusable higher-level keywords from the existing keywords
  • Allows creation of custom keywords
  • Provides Platform and application independence
  • Supports standard and external libraries for test automation
  • Allows tagging to categorize and select test cases for execution
  • Provides easy-to-read reports and logs in the HTML format

Setup of the Robot Framework

Robot framework requires installation of the following on the system:

  • Java (JRE and JDK)
  • Python
  • Robot framework package (pip install)
  • Python IDE (PyCharm)

Appium Library

Appium Library is one of the external libraries of Robot framework for mobile application testing which only supports Python 2.x. It uses Appium (version 1.x) to communicate with Android and iOS applications.

Here most of the capabilities of Appium are framed into keywords, which are easy to understand and help understand the purpose of the test case by reading the script.

Key Features of Appium

Following are the key features of Appium:

  • No requirement of recompilation or modification of app to be tested
  • No need of an application source code
  • Easy-to-write tests across any language using any framework
  • Standard automation specification and API
Setup

To use Appium library with Robot framework for mobile application test automation requires installation of the following on the system:

  • Node js
  • Robot framework Appium library package (pip install)
  • Appium Desktop Client (Appium Server)
  • Android SDK (for Android apps)
  • Xcode (for iOS apps)

Robot - Appium Interaction

A basic flow of Robot framework’s interaction with the application under test is illustrated in the following diagram.

Interaction of Robot Framework With the Application Under Test Fig 1: Interaction of Robot Framework With the Application Under Test

 

Test Suites consisting of test cases written using Robot’s keyword-driven approach are used to test the mobile application (Android/iOS). Appium server, Robot’s Pybot and Appium-Python Client play a significant role in this interaction.

Appium Server: Appium is an open source engine running on Node.js. It is mainly responsible for the interaction between the app’s UI and Robot’s Appium library commands. It needs to be up and running to facilitate this interaction.

Pybot: This is a Robot framework module used to trigger the test scripts written in Robot framework format. Pybot reads the different framework files from framework’s code base and executes the tests by interacting with Appium Library. On completion of test case/suite execution, Pybot generates report and log files with complete details of the test run.

Appium-Python Client: Appium-Python Client facilitates the interaction between Appium library and Appium server using JSON Wire Protocol. This client initiates a session with the Appium server in ways specific to Appium library, resulting in a POST /session request to the Appium server, with a JSON object.

The Appium server then starts an automation session and responds with a session ID. This session ID is used in sending further commands to the server. This is illustrated in the below flow diagram.

Fig 2: Flow Diagram of Robot – Appium Interaction Fig 2: Flow Diagram of Robot – Appium Interaction

 

Example of Robot Framework Appium Library

The following example is for testing the Calculator App on an Android device using Robot framework’s Appium library.

Test Suite

A test suite is a .robot file which can be written and executed using a python IDE. The basic skeleton of a test suite written using robot framework’s syntax consists of the following sections.

Fig 3: Basic skeleton of Test Suite Fig 3: Basic Skeleton of Test Suite

 

  • Settings: This section consists of the test suite documentation, imports of libraries and resource files, suite and test level setup and teardown. (Fig 4)
  • Variables: This section consists of all the variable declarations for the variables used in the test suite. (Fig 4)
  • Keywords: This section consists of the higher level keywords formed using in built keywords from robot’s standard libraries and Appium library. (Fig 5)
  • Test Cases: This section consists of all the test cases that belong to the test suite. (Fig 5)
Fig 4: Settings and Variables section of test suite Fig 4: Settings and Variables Section of Test Suite

 

Fig 5: Keywords and Test Cases section of test suite Fig 5: Keywords and Test Cases Section of Test Suite

 

UIAutomator

UIAutomator is a tool used to obtain the locators of all the elements on a particular android application. It is a part of the android SDK. The locators in the form of xpaths were obtained using UIAutomator for the calculator app (Fig 6)

Fig 6: UIAutomator screenshot for Calculator App for Android Fig 6: UIAutomator Calculator App Screenshot for Android

 

Test Reports and Logs

The above test suite can be executed using the following command on python terminal: pybot -d Results\TestSuite  TestSuite.robot  

On execution of the test suite, report and log files are created in the form of HTML documents. These files have a detailed summary of the test case execution and all the necessary statistics related to the test case execution. (Fig 7, 8)

Fig 7: Report of the execution of Test Suite for Calculator App Fig 7: Report of Test Suite Execution for Calculator App

 

Fig 8: Log of the execution of Test Suite for Calculator App Fig 8: Log of Test Suite Execution for Calculator App

 

In conclusion, the Appium library of Robot framework facilitates automation of test cases for mobile applications with a simple tabular syntax. This is easy to read and is platform independent, without altering the source code of the application under test.

The keyword-driven approach of Robot framework ensures the reusability and readability of the test cases, thus making the automation framework robust and tester friendly.

Get Started

vector_white_1
Think Tomorrow
With Xoriant
triangle triangle triangle triangle triangle
Is your digital roadmap adaptive to Generative AI, Hyper cloud, and Intelligent Automation?
Are your people optimally leveraging AI, cloud apps, and analytics to drive enterprise future states?
Which legacy challenge worries you most when accelerating digital and adopting new products?

Your Information

1 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Your Information

3 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Your Information

4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.