Mobile Automation testing using Robot Framework

Mobile Automation Testing using RobotFramework

RobotFramework is a generic automation framework designed for a great number of applications. It can be used for testing apps (WEB, mobile, desktop) and much more.

Test cases are simple text files with “robot” extension, and they can be edited in your favorite IDE (Notepad, PyCharm, etc.). Pycharm with robot plugin is great for writing Robot Framework test cases because it offers syntax highlight and other cool benefits that help you write the cases.

One of the best features of Robot Framework is that it uses a keyword-driven testing approach, so you don’t have to actually “touch” coding.

To drive applications using the Appium framework, the Robot framework’s Appium library is preferred. Here most of the capabilities of Appium are framed in form of keywords, which are easily understood by a tester who would want to read the scripts and understand what is exactly being performed in the particular test.

One of the renowned frameworks used for UI based automation for all three types of applications is Appium. To write a robust automation framework using Appium, the Robot framework library for Appium is recommended.

In our previous post, we tried to cover how you can use selenium library & Robot Framework and automate cross browser testing. In this blog post, I would like to cover on how you can execute your mobile automation tests using Appium & RobotFramework.

Getting started with Appium & RobotFramework

Installation of Appium Library using PIP

pip install robotframework-appiumlibrary

The relevant keyword documentation link for appium library in Robot framework can be found here: http://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html

Connection

Similar to our previous post, we will create our connection.robot or whatever the file name that you choose and have all the variables, settings, and keywords in the file. As you can see in image attached below, I have added AppiumLibrary as a resource and added some variables which would be valid for the scope of this file and any test cases that I may have and the keywords which help in creating a connection to local appium server. Feel free to modify the variables and values names accordingly.

Appium Connection

Now that connection method is already made, the next task is to identify and create Page Object model, for example, in the app that I would be working on here, it has login screen with username, password fields along with login button on login screen. So I go ahead and create a pageobject, loginScreen.robot, it would look something like this:

Login Screen Page object

In the image, you can notice I have used appium library as resource again and used some of the keywords from appium library, to identify and input some text/password and make action like click on button.

Next part is to create a test case itself. You can find one such test case in the image below:

Test case for Login Screen

As you can see in the image above, I have used the resources to create connection and to identify & perform actions based on Page Object model in this test. It will launch the application, and validate if elements are present, if yes, gives in the valid input and performs the button click action as expected.

As you would have noticed in our previous blog post and this one, creating tests using keywords is very trivial that too when you can develop these tests in any OS, and application using human readable language is one of the main advantages of RobotFramework.

Feel free to comment to this post or you can always drop an email to naik899@gmail.com.