Guides
Appium with Robot Framework
Run a Robot Framework AppiumLibrary suite against an Android build on SpawnDroid, with the remote URL, capabilities and a full test case.
Robot Framework's AppiumLibrary drives an Appium session through keyword
tests. The library reads the same UiAutomator2 capabilities as a Python suite.
Install
pip install robotframework robotframework-appiumlibraryThe suite
*** Settings ***
Library AppiumLibrary
Suite Setup Open Test Application
Suite Teardown Close Application
Test Teardown Run Keyword If Test Failed Capture Page Screenshot
*** Variables ***
${REMOTE_URL} %{SPAWNDROID_WD_URL}
${UDID} %{SPAWNDROID_UDID}
${APP_PACKAGE} %{SPAWNDROID_APP_PACKAGE}
*** Test Cases ***
Add Item To Cart
Click Element accessibility_id=Add to cart
Wait Until Page Contains Element id=com.acme.checkout:id/total timeout=20s
*** Keywords ***
Open Test Application
Open Application ${REMOTE_URL}
... platformName=Android
... automationName=UiAutomator2
... udid=${UDID}
... appPackage=${APP_PACKAGE}
... autoGrantPermissions=trueOpen Application sets remote_url first, then the capabilities as keyword
arguments. Do not pass app; the build is already installed on the session.
Run it
export SPAWNDROID_WD_URL='https://stream.spawndroid.io/ci/sess_…/token/wd/hub'
export SPAWNDROID_UDID='emulator-5554'
export SPAWNDROID_APP_PACKAGE='com.acme.checkout'
robot --outputdir reports checkout.robotRobot writes output.xml, log.html and report.html. The raw
output.xml is not JUnit XML; convert it with rebot --xunit if the CI surface
expects JUnit:
rebot --xunit reports/junit.xml --outputdir reports reports/output.xmlSelectors and waits
accessibility_id=Add to cartmatches the content description.id=package:id/namematches the full Android resource id.Wait Until Page Contains Elementwaits for the next screen. AvoidSleep; a fixed wait is the most common source of flakiness.Capture Page Screenshoton failure attaches evidence to the Robot log. For SpawnDroid's retained screen recording, run the suite as a hosted CI session.
In CI
- uses: kl3jvi/spawndroid/actions/android-test@v1
with:
api-key: ${{ secrets.SPAWNDROID_API_KEY }}
app-path: app/build/outputs/apk/debug/app-debug.apk
command: robot --outputdir reports checkout.robotRun it on SpawnDroid
Start free with one runner and 200 device-minutes a month, or read the cloud Appium guide.
Was this page helpful?