Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

Appium

AppiumLibrary is a Mobile App testing library for Robot Framework.

Locating or specifying elements

All keywords in AppiumLibrary that need to find an element on the page take an argument, either a locator or a webelement. locator is a string that describes how to locate an element using a syntax specifying different location strategies. webelement is a variable that holds a WebElement instance, which is a representation of the element.

Using locators

By default, when a locator is provided, it is matched against the key attributes of the particular element type. For iOS and Android, key attribute is id for all elements and locating elements is easy using just the id. For example:

Click Element id=my_element

New in AppiumLibrary 1.4, id and xpath are not required to be specified, however xpath should start with // else just use xpath locator as explained below.

For example:

Click Element my_element Wait Until Page Contains Element //*[@type="android.widget.EditText"]

Appium additionally supports some of the Mobile JSON Wire Protocol locator strategies. It is also possible to specify the approach AppiumLibrary should take to find an element by specifying a lookup strategy with a locator prefix. Supported strategies are:

StrategyExampleDescriptionNote
identifierClick Element | identifier=my_elementMatches by @id attribute
idClick Element | id=my_elementMatches by @resource-id attribute
accessibility_idClick Element | accessibility_id=button3Accessibility options utilize.
xpathClick Element | xpath=//UIATableView/UIATableCell/UIAButtonMatches with arbitrary XPath
classClick Element | class=UIAPickerWheelMatches by class
androidClick Element | android=UiSelector().description('Apps')Matches by Android UI Automator
iosClick Element | ios=.buttons().withName('Apps')Matches by iOS UI Automation
nspClick Element | nsp=name=="login"Matches by iOSNsPredicateCheck PR: #196
chainClick Element | chain=XCUIElementTypeWindow[1]/*Matches by iOS Class Chain
cssClick Element | css=.green_buttonMatches by css in webview
nameClick Element | name=my_elementMatches by @name attributeOnly valid for Selendroid

Using webelements

Starting with version 1.4 of the AppiumLibrary, one can pass an argument that contains a WebElement instead of a string locator. To get a WebElement, use the new Get WebElements or Get WebElement keyword.

For example:

@{elements} Get Webelements class=UIAButton Click Element @{elements}[2]

Importing

AppiumLibrary can be imported with optional arguments.

timeout is the default timeout used to wait for all waiting actions. It can be later set with Set Appium Timeout.

run_on_failure specifies the name of a keyword (from any available libraries) to execute when a AppiumLibrary keyword fails.

By default Capture Page Screenshot will be used to take a screenshot of the current page. Using the value No Operation will disable this feature altogether. See Register Keyword To Run On Failure keyword for more information about this functionality.

Examples:

LibraryAppiumLibrary10# Sets default timeout to 10 seconds
LibraryAppiumLibrarytimeout=10run_on_failure=No Operation# Sets default timeout to 10 seconds and does nothing on failure