Mobile Automation in Robot Framework with Appium Library

Robot Framework supports mobile automation through the AppiumLibrary, which acts as a bridge to the Appium Server. This allows automation of Android and iOS apps, whether they are native, hybrid, or mobile web applications.

Tip for beginners: Before starting with Robot Framework mobile automation, it is recommended to go through a basic Appium tutorial to understand mobile application automation concepts.

Appium tutorial link: https://www.qafeast.com/appium

1. Setup Requirement

Install Required Tools

     - Python (latest version)
     - Robot Framework: pip install robotframework
     - AppiumLibrary: pip install robotframework-appiumlibrary
     - Appium Server
           - Install Nodejs: npm install -g appium
           - Start Appium Server: appium
     - Android SDK / ADB
           - Install Android Studio and configure ANDROID_HOME environment variable.
           - Make sure your device is detected: adb devices
     - Device or Emulator
           - You can use a real Android device or an emulator from Android Studio.

2. Desired Capabilities

Desired capabilities tell Appium which device, platform, and application to automate.

Example – Android Configuration

*** Variables ***
${REMOTE_URL}     http://127.0.0.1:4723/wd/hub
${PLATFORM}       Android
${DEVICE_NAME}    emulator-5554
${APP_PACKAGE}    com.android.calculator2
${APP_ACTIVITY}   com.android.calculator2.Calculator


REMOTE_URL → Appium server endpoint
PLATFORM → Mobile OS (Android or iOS)
DEVICE_NAME → Device ID or emulator name
APP_PACKAGE / APP_ACTIVITY → Identifiers for Android apps

3. Writing the First Mobile Test

Example – Launch and Validate Calculator App

*** Settings ***
Library    AppiumLibrary
*** Variables ***
${REMOTE_URL}     http://127.0.0.1:4723/wd/hub
${PLATFORM}       Android
${DEVICE_NAME}    emulator-5554
${APP_PACKAGE}    com.android.calculator2
${APP_ACTIVITY}   com.android.calculator2.Calculator
*** Test Cases ***
Open Calculator And Perform Addition
    Open Application    ${REMOTE_URL}    platformName=${PLATFORM}    deviceName=${DEVICE_NAME}    appPackage=${APP_PACKAGE}    appActivity=${APP_ACTIVITY}
    Click Element       id=com.android.calculator2:id/digit_2
    Click Element       id=com.android.calculator2:id/op_add
    Click Element       id=com.android.calculator2:id/digit_5
    Click Element       id=com.android.calculator2:id/eq
    ${result}=          Get Text    id=com.android.calculator2:id/result
    Should Be Equal     ${result}    7
    Close Application


Test Flow Explanation:

     - Connects to the Appium Server
     - Opens the Calculator app on the Android device
     - Clicks the digits and operator buttons
     - Retrieves and verifies the calculation result
     - Closes the app session

4. Common Mobile Automation Keywords

Below are frequently used AppiumLibrary keywords:

Keyword

Description

Open Application

Launches an app using desired capabilities

Click Element

Taps on a button or UI element

Input Text

Enters text in an input field

Get Text

Retrieves text displayed on screen

Swipe

Swipes across the screen (useful for scrolling)

Wait Until Page Contains

Waits for an element or text to appear

Close Application

Closes the currently opened app

Capture Page Screenshot

Captures a screenshot for debugging

 

 

Related Tutorials