Robot Framework for Python: Local Mobile Automation with TestGrid Device Cloud
Running Your Local Robot Code for Mobile Automation
An all-purpose open-source automation framework is called Robot Framework. Robot Framework can be used in conjunction with almost any other tool to build robust and adaptable automation solutions, like Selenium and Appium. Robot Framework has no licensing fees and is available for free use.
Robot Framework uses human-readable keywords in an easy-to-read syntax. Libraries written in Python, Java, or many other programming languages can increase their capabilities. The Robot Framework is surrounded by a vibrant ecosystem of tools and libraries that are created as independent projects.
Prerequisites:
- Login details for TestGrid and the Device Cloud link
- Robot Framework Configuration (using pip/pip3 in Python)
- To add your preferred remote device URL and UDID, copy and paste them into the ${url} and ${udid} variables in your robot code from the TestGrid device cloud. The remaining API capabilities in your robot code will not change.
Furthermore, TestGrid Device Cloud allows for the real-time viewing of remote execution of code.
You can find detailed steps at https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary
An Example of a TestGrid Project Using the Python Robot Framework and Appium
A brief description of the sample project
List of Contents:
- Introduction
- Prerequisites
- Installation
- Configuration
- Running Tests
- Folder Structure
Introduction:
Here is a simple Python robot framework that I have set up using TestGrid Devices Farm.
Prerequisites:
Provide a list of any prerequisites, such as Python, Robot Framework, Appium, etc., that users must install in order to use your project.
Installation:
Give detailed instructions on how to install the dependencies for your project.
Step 1: Install the necessary libraries in step 1. Verify that the Appium Library and Robot Framework are installed. Pip can be used to install the Appium Library.
To install the Python appium required library, run the following command:
pip install robotframework-appiumlibrary
If your machine is running a local Appium server,
Step 2: Configure the Appium Server Make sure your computer is running and has Appium installed. With npm, you can install it:
Use the Terminal to Run the Below Command
npm install -g appium
Launch the Appium server. Use the Terminal to Run the Below Command
appium
Use TestGrid’s Appium Public URL with users, as it has its own device cloud farm. Locate the necessary desired capability for any device by going to the Device Cloud Tab, then edit the TC file.
Step 3: Write a test script for the robot framework. Write a simple test script and create a new Robot Framework test file (such as appium_test.robot).
Below is a simple example:
######## ---- Python Version 3.9 ######## ---- Author : KISHAN GODHANI *** Settings *** Library AppiumLibrary *** Variables *** ${REMOTE_URL} http://{{your_server_domain}}.testgrid.io/appium_{{port}}/wd/hub ${PLATFORM_NAME} Android # Android or iOS ${PLATFORM_VERSION} 14 # Specify the version of the platform ${DEVICE_NAME} Pixel 7 # Android or iOS device name ${UDID} {{udid}} # Device udid ${SYSTEM_PORT} {{port}} # TestGrid Device Cloud Devices System Port ${AUTOMATION_NAME} UiAutomator2 # Automation Name ${APP_PACKAGE} com.android.chrome # App Package / Bundle ID ${APP_ACTIVITY} com.google.android.apps.chrome.Main ${ADB_EXECTIMEOUT} 9990000 # ADB Timeout ${TG:USERTOKEN} {{user_token}} # Passed User token here *** Test Cases *** Open Application Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} udid=${UDID} systemPort=${SYSTEM_PORT} automationName=${AUTOMATION_NAME} appPackage=${APP_PACKAGE} appActivity=${APP_ACTIVITY} adbExecTimeout=${ADB_EXECTIMEOUT} tg:userToken=${TG:USERTOKEN} # Your test steps here # Wait for 30 seconds Sleep 30s # Get page source ${page_source}= Get Source Log Page Source: ${page_source} Close Application Close Application
Step 4: Run Your Test In the terminal, navigate to the directory containing your test file and run the test:
Run the below command on Terminal
robot appium_test.robot
pip install -r requirements.txt
Folder Structure:

Demo Video Link : Robot_Python_Demo_AppiumMobileAndroid.mov
As simple as that! Happy Testing 🙂