Robot Framework for Python: Local Mobile Automation with TestGrid Device Cloud

You are here:
< All Topics

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.


  • 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

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


Here is a simple Python robot framework that I have set up using TestGrid Devices Farm.


Provide a list of any prerequisites, such as Python, Robot Framework, Appium, etc., that users must install in order to use your project.


Give detailed instructions on how to install the dependencies for your project.

Step 1: Install the necessary libraries in step one. 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




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
######## ---- Auther : KISHAN GODHANI

*** Settings ***
Library           AppiumLibrary

*** Variables ***
${REMOTE_URL}           http://{Your_Server_Domain}
${PLATFORM_NAME}        Android   # Android or iOS
${PLATFORM_VERSION}     11.0   # Specify the version of the platform
${DEVICE_NAME}          Pixel 4   # Android or iOS device name
${UDID}                 09201JE773    # Device udid
${SYSTEM_PORT}          4001    # TestGrid Device Cloud Devices System Port
${AUTOMATION_NAME}      UiAutomator2    # Automation Name
${APP_PACKAGE}    # App Package / Bundle ID
${ADB_EXECTIMEOUT}      9990000    # ADB Timeout
${TG:USERTOKEN}         6d6x8sdvdcdffvfgfbtoxaamgalqnsc3t06b   # 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 60 seconds
    Sleep    60s

    # 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:

As simple as that! Happy Testing 🙂

Table of Contents