Loading...
Loading...
Guide AI agents in creating AppiumLibrary tests for iOS and Android native apps, hybrid apps, and mobile browsers. Load when asked about mobile testing, Appium, or mobile app automation.
npx skill4agent add manykarim/robotframework-agentskills robotframework-appium-skill# Install the library
pip install robotframework-appiumlibrary
# Install Appium server (requires Node.js)
npm install -g appium
# Install platform drivers
appium driver install uiautomator2 # Android
appium driver install xcuitest # iOSappium # Start with defaults
appium server # Alternative
appium --port 4724 # Custom porthttp://127.0.0.1:4723*** Settings ***
Library AppiumLibraryOpen Application http://127.0.0.1:4723
... platformName=Android
... platformVersion=13
... deviceName=emulator-5554
... automationName=UiAutomator2
... app=${CURDIR}/app.apk# 1. accessibility_id (RECOMMENDED - stable)
Click Element accessibility_id=login_button
# 2. id (resource-id)
Click Element id=com.example:id/login_button
Click Element id=login_button # Short form if unique
# 3. xpath
Click Element xpath=//android.widget.Button[@text='Login']
# 4. android UIAutomator2 selector
Click Element android=new UiSelector().text("Login")
# 5. class name
Click Element class=android.widget.ButtonOpen Application http://127.0.0.1:4723
... platformName=iOS
... platformVersion=17.0
... deviceName=iPhone 15
... automationName=XCUITest
... app=${CURDIR}/MyApp.app
... udid=auto # For real devices# 1. accessibility_id (RECOMMENDED - stable)
Click Element accessibility_id=loginButton
# 2. name
Click Element name=Login
# 3. ios predicate string
Click Element ios=type == 'XCUIElementTypeButton' AND name == 'Login'
# 4. ios class chain (fast) - NOTE: use chain= prefix for class chains
Click Element chain=**/XCUIElementTypeButton[`name == 'Login'`]
# 5. xpath
Click Element xpath=//XCUIElementTypeButton[@name='Login']
# 6. class name
Click Element class=XCUIElementTypeButtonClick Element locator
Click Text visible_text
Input Text locator text_to_enter
Clear Text locator
Tap locator duration=0:00:01 # Long press (replaces removed Long Press)${text}= Get Text locator
${attr}= Get Element Attribute locator attribute_name
${count}= Get Matching Xpath Count //android.widget.ButtonWait Until Element Is Visible locator timeout=10s
Wait Until Page Contains text timeout=10s
Wait Until Page Contains Element locator timeout=10sElement Should Be Visible locator
Element Should Be Enabled locator
Page Should Contain Text expected_text
Page Should Contain Element locator
Element Text Should Be locator expected_textCapture Page Screenshot filename.png
Capture Page Screenshot ${OUTPUT_DIR}/screenshots/screen.png${source}= Get Source
Log ${source}# Scroll (locator is the element to scroll to/within)
Scroll Down locator
Scroll Up locator
# Swipe (start_x, start_y, end_x, end_y, duration as timedelta)
Swipe start_x=500 start_y=1500 end_x=500 end_y=500 duration=0:00:01 # Swipe up
# Long press (use Tap with duration; Long Press was removed in v3.2.0)
Tap locator duration=0:00:02
# Tap at coordinates
Tap With Positions 500 800# Automatically scrolls to find element!
Click Element android=new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text("Settings"))# Check current context
${context}= Get Current Context
Log Current: ${context}
# List all contexts
@{contexts}= Get Contexts
Log Many @{contexts}
# Switch to webview
Switch To Context WEBVIEW_com.example.app
# Switch back to native
Switch To Context NATIVE_APPOpen Application http://127.0.0.1:4723
... platformName=Android
... deviceName=emulator-5554
... automationName=UiAutomator2
... browserName=Chrome
Go To Url https://example.com
Input Text id=username admin
Click Element css=button[type='submit']Open Application http://127.0.0.1:4723
... platformName=iOS
... deviceName=iPhone 15
... automationName=XCUITest
... browserName=Safari
Go To Url https://example.com# Close app and end session
Close Application
# Background/foreground
Background Application 5 # Background for 5 seconds
# NOTE: Quit Application was removed in v3.0.0 - use Close Application instead
# NOTE: Reset Application was removed in v3.2.0 - use Close Application + Open Application insteadappium:Open Application http://127.0.0.1:4723
... platformName=Android
... appium:automationName=UiAutomator2
... appium:app=/path/to/app.apk
... appium:deviceName=emulator-5554
... appium:autoGrantPermissions=trueplatformNameappium:Open Application http://hub-cloud.browserstack.com/wd/hub
... platformName=Android
... appium:deviceName=Google Pixel 7
... appium:platformVersion=13.0
... appium:app=bs://your_app_hash
... bstack:options={"userName": "${BS_USERNAME}", "accessKey": "${BS_ACCESS_KEY}"}Open Application https://ondemand.us-west-1.saucelabs.com:443/wd/hub
... platformName=iOS
... appium:deviceName=iPhone 14
... appium:platformVersion=16
... appium:app=storage:filename=MyApp.ipa
... sauce:options={"username": "${SAUCE_USERNAME}", "accessKey": "${SAUCE_ACCESS_KEY}"}| Removed Keyword | Version Removed | Alternative |
|---|---|---|
| v3.2.0 | |
| v3.0.0 | |
| v3.2.0 | Use W3C Actions via Execute Script |
| v3.0.0 | Use W3C Actions via Execute Script |
| v3.2.0 | |
| v3.0.0 | |
| v3.0.0 | |
| N/A | |
# Example: Use Execute Script to perform pinch/zoom via driver
Execute Script mobile: pinchOpen {"elementId": "${element_id}", "percent": 0.75}| Need | Reference File |
|---|---|
| Android locator strategies | |
| iOS locator strategies | |
| Device capabilities setup | |
| Gestures and scrolling | |
| iOS-specific features | |
| Android-specific features | |
| Complete keyword list | |
| Common issues and solutions | |