Keywords
Keyword | Arguments | Documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Background App | seconds=5 |
Puts the application in the background on the device for a certain duration. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Capture Page Screenshot | filename=None |
Takes a screenshot of the current page and embeds it into the log. filename argument specifies the name of the file to write the screenshot into. If no filename is given, the screenshot is saved into file appium-screenshot-<counter>.png under the directory where the Robot Framework log file is written into. The filename is also considered relative to the same directory, if it is not given in absolute format. css can be used to modify how the screenshot is taken. By default the bakground color is changed to avoid possible problems with background leaking when the page layout is somehow broken. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Clear Text | locator |
Clears the text field identified by locator. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Click A Point | x=0, y=0,duration=100 |
Click on a point |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Click Button | index_or_name |
Click button |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Click Element | locator |
Click element identified by locator. Key attributes for arbitrary elements are index and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Click Element At Coordinates | coordinate_X,coordinate_Y |
click element at a certain coordinate |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Click Text | text,exact_match=False |
Click text identified by By default tries to click first text involves given If there are multiple use of |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Close All Applications |
Closes all open applications. This keyword is meant to be used in test or suite teardown to make sure all the applications are closed before the test execution finishes. After this keyword, the application indices returned by Open Application are reset and start from 1. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Close Application |
Closes the current application and also close webdriver session. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Attribute Should Match | locator, attr_name,match_pattern,regexp=False |
Verify that an attribute of an element matches the expected criteria. The element is identified by locator. See introduction for details about locating elements. If more than one element matches, the first element is selected. The attr_name is the name of the attribute within the selected element. The match_pattern is used for the matching, if the match_pattern is
The regexp defines whether the string match is done using regular expressions (i.e. BuiltIn Library's Should Match Regexp or string pattern match (i.e. BuiltIn Library's Should Match) Examples:
NOTE: On Android the supported attribute names are hard-coded in the AndroidElement Class's getBoolAttribute() and getStringAttribute() methods. Currently supported (appium v1.4.11): contentDescription, text, className, resourceId, enabled, checkable, checked, clickable, focusable, focused, longClickable, scrollable, selected, displayed NOTE: Some attributes can be evaluated in two different ways e.g. these evaluate the same thing:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Name Should Be | locator, expected | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Should Be Disabled | locator,loglevel=INFO |
Verifies that element identified with locator is disabled. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Should Be Enabled | locator,loglevel=INFO |
Verifies that element identified with locator is enabled. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Should Be Visible | locator,loglevel=INFO |
Verifies that element identified with locator is visible. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. New in AppiumLibrary 1.4.5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Should Contain Text | locator, expected,message= |
Verifies element identified by If you wish to assert an exact (not a substring) match on the text of the element, use Element Text Should Be. Key attributes for arbitrary elements are New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Should Not Contain Text | locator, expected,message= |
Verifies element identified by
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Text Should Be | locator, expected,message= |
Verifies element identified by In contrast to Element Should Contain Text, this keyword does not try a substring match but an exact match on the element identified by
New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Element Value Should Be | locator, expected | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Activity |
Retrieves the current activity on the device. Android only. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Appium SessionId |
Returns the current session ID as a reference |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Appium Timeout |
Gets the timeout in seconds that is used by various keywords. See Set Appium Timeout for an explanation. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Capability | capability_name |
Return the desired capability value by desired capability name |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Contexts |
Get available contexts. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Current Context |
Get current context. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Element Attribute | locator, attribute |
Get element attribute using given attribute: name, value,... Examples:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Element Location | locator |
Get element location Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Element Size | locator |
Get element size Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Matching Xpath Count | xpath |
Returns number of elements matching One should not use the xpath= prefix for 'xpath'. XPath is assumed.
If you wish to assert the number of matching elements, use Xpath Should Match X Times. New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Network Connection Status |
Returns an integer bitmask specifying the network connection type. Android only. See set network connection status for more details. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Source |
Returns the entire source of the current page. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Text | locator |
Get element text (for hybrid and mobile browser use xpath locator, others might cause problem) Example:
New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Webelement | locator |
Returns the first WebElement object matching Example:
New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Webelements | locator |
Returns list of WebElement objects matching Example:
This keyword was changed in AppiumLibrary 1.4 in following ways:
New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Window Height |
Get current device height. Example:
New in AppiumLibrary 1.4.5 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get Window Width |
Get current device width. Example:
New in AppiumLibrary 1.4.5 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Go Back |
Goes one step backward in the browser history. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Go To Url | url |
Opens URL in default web browser. Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hide Keyboard | key_name=None |
Hides the software keyboard on the device. (optional) In iOS, use key_name to press a particular key, ex. Done. In Android, no parameters are used. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Input Password | locator, text |
Types the given password into text field identified by locator. Difference between this keyword and Input Text is that this keyword does not log the given password. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Input Text | locator, text |
Types the given text into text field identified by locator. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Input Value | locator, text |
Sets the given value into text field identified by locator. This is an IOS only keyword, input value makes use of set_value See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Install App | app_path,app_package |
Install App via Appium Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Landscape |
Set the device orientation to LANDSCAPE |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Launch Application |
Launch application. Application can be launched while Appium session running. This keyword can be used to launch application during test case or between test cases. This keyword works while Open Application has a test running. This is good practice to Launch Application and Quit Application between test cases. As Suite Setup is Open Application, Test Setup can be used to Launch Application Example (syntax is just a representation, refer to RF Guide for usage of Setup/Teardown):
See Quit Application for quiting application but keeping Appium sesion running. New in AppiumLibrary 1.4.6 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Lock | seconds=5 |
Lock the device for a certain period of time. iOS only. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Log Source | loglevel=INFO |
Logs and returns the entire html source of the current page or frame. The loglevel argument defines the used log level. Valid log levels are WARN, INFO (default), DEBUG, TRACE and NONE (no logging). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Long Press | locator |
Long press the element |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Long Press Keycode | keycode,metastate=None |
Sends a long press of keycode to the device. Android only. See press keycode for more details. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Open Application | remote_url,alias=None,**kwargs |
Opens a new application to given Appium server. Capabilities of appium server, Android and iOS, Please check http://appium.io/slate/en/master/?python#appium-server-capabilities
Examples:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Page Should Contain Element | locator,loglevel=INFO |
Verifies that current page contains locator element. If this keyword fails, it automatically logs the page source using the log level specified with the optional loglevel argument. Giving NONE as level disables logging. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Page Should Contain Text | text,loglevel=INFO |
Verifies that current page contains text. If this keyword fails, it automatically logs the page source using the log level specified with the optional loglevel argument. Giving NONE as level disables logging. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Page Should Not Contain Element | locator,loglevel=INFO |
Verifies that current page not contains locator element. If this keyword fails, it automatically logs the page source using the log level specified with the optional loglevel argument. Giving NONE as level disables logging. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Page Should Not Contain Text | text,loglevel=INFO |
Verifies that current page not contains text. If this keyword fails, it automatically logs the page source using the log level specified with the optional loglevel argument. Giving NONE as level disables logging. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pinch | locator,percent=200%,steps=1 |
Pinch in on an element a certain amount. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Portrait |
Set the device orientation to PORTRAIT |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Press Keycode | keycode,metastate=None |
Sends a press of keycode to the device. Android only. Possible keycodes & meta states can be found in http://developer.android.com/reference/android/view/KeyEvent.html Meta state describe the pressed state of key modifiers such as Shift, Ctrl & Alt keys. The Meta State is an integer in which each bit set to 1 represents a pressed meta key. For example
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pull File | path,decode=False |
Retrieves the file at path and return it's content. Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pull Folder | path,decode=False |
Retrieves a folder at path. Returns the folder's contents zipped. Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Push File | path, data,encode=False |
Puts the data in the file specified as path. Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Quit Application |
Quit application. Application can be quit while Appium session is kept alive. This keyword can be used to close application during test case or between test cases. See Launch Application for an explanation. New in AppiumLibrary 1.4.6 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Register Keyword To Run On Failure | keyword |
Sets the keyword to execute when a AppiumLibrary keyword fails. keyword_name is the name of a keyword (from any available libraries) that will be executed if a AppiumLibrary keyword fails. It is not possible to use a keyword that requires arguments. Using the value "Nothing" will disable this feature altogether. The initial keyword to use is set in importing, and the keyword that is used by default is Capture Page Screenshot. Taking a screenshot when something failed is a very useful feature, but notice that it can slow down the execution. This keyword returns the name of the previously registered failure keyword. It can be used to restore the original value later. Example:
This run-on-failure functionality only works when running tests on Python/Jython 2.4 or newer and it does not work on IronPython at all. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Remove Application | application_id |
Removes the application that is identified with an application id Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Reset Application |
Reset application. Open Application can be reset while Appium session is kept alive. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scroll | start_locator,end_locator |
Scrolls from one element to another Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scroll Down | locator |
Scrolls down to element |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scroll Up | locator |
Scrolls up to element |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Set Appium Timeout | seconds |
Sets the timeout in seconds used by various keywords. There are several Wait ... keywords that take timeout as an argument. All of these timeout arguments are optional. The timeout used by all of them can be set globally using this keyword. The previous timeout value is returned by this keyword and can be used to set the old value back later. The default timeout is 5 seconds, but it can be altered in importing. Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Set Network Connection Status | connectionStatus |
Sets the network connection Status. Android only. Possible values:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Shake |
Shake the device |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Start Activity | appPackage,appActivity, **opts |
Opens an arbitrary activity during a test. If the activity belongs to another application, that application is started and the activity is opened. Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Swipe | start_x, start_y,offset_x, offset_y,duration=1000 |
Swipe from one point to another point, for an optional duration. Args:
Usage:
NOTE: Android 'Swipe' is not working properly, use |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Swipe By Percent | start_x, start_y,end_x, end_y,duration=1000 |
Swipe from one percent of the screen to another percent, for an optional duration. Normal swipe fails to scale for different screen resolutions, this can be avoided using percent. Args:
Usage:
NOTE: This also considers swipe acts different between iOS and Android. New in AppiumLibrary 1.4.5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch Application | index_or_alias |
Switches the active application by index or alias. index_or_alias is either application index (an integer) or alias (a string). Index is got as the return value of Open Application. This keyword returns the index of the previous active application, which can be used to switch back to that application later. Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch To Context | context_name |
Switch to a new context |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tap | locator,x_offset=None,y_offset=None,count=1 |
Tap element identified by Args:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Text Should Be Visible | text,exact_match=False,loglevel=INFO |
Verifies that element identified with text is visible. New in AppiumLibrary 1.4.5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Activity | activity, timeout,interval=1 |
Wait for an activity: block until target activity presents or time out. Android only.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Until Element Is Visible | locator,timeout=None,error=None |
Waits until element specified with locator is visible. Fails if timeout expires before the element is visible. See introduction for more information about timeout and its default value. error can be used to override the default error message. See also Wait Until Page Contains, Wait Until Page Contains Element, Wait For Condition and BuiltIn keyword Wait Until Keyword Succeeds. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Until Page Contains | text,timeout=None,error=None |
Waits until text appears on current page. Fails if timeout expires before the text appears. See introduction for more information about timeout and its default value. error can be used to override the default error message. See also Wait Until Page Does Not Contain, Wait Until Page Contains Element, Wait Until Page Does Not Contain Element and BuiltIn keyword Wait Until Keyword Succeeds. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Until Page Contains Element | locator,timeout=None,error=None |
Waits until element specified with locator appears on current page. Fails if timeout expires before the element appears. See introduction for more information about timeout and its default value. error can be used to override the default error message. See also Wait Until Page Contains, Wait Until Page Does Not Contain Wait Until Page Does Not Contain Element and BuiltIn keyword Wait Until Keyword Succeeds. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Until Page Does Not Contain | text,timeout=None,error=None |
Waits until text disappears from current page. Fails if timeout expires before the text disappears. See introduction for more information about timeout and its default value. error can be used to override the default error message. See also Wait Until Page Contains, Wait Until Page Contains Element, Wait Until Page Does Not Contain Element and BuiltIn keyword Wait Until Keyword Succeeds. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Until Page Does Not Contain Element | locator,timeout=None,error=None |
Waits until element specified with locator disappears from current page. Fails if timeout expires before the element disappears. See introduction for more information about timeout and its default value. error can be used to override the default error message. See also Wait Until Page Contains, Wait Until Page Does Not Contain, Wait Until Page Contains Element and BuiltIn keyword Wait Until Keyword Succeeds. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Xpath Should Match X Times | xpath, count,error=None,loglevel=INFO |
Verifies that the page contains the given number of elements located by the given One should not use the xpath= prefix for 'xpath'. XPath is assumed.
See Log Source for explanation about New in AppiumLibrary 1.4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Zoom | locator,percent=200%,steps=1 |
Zooms in on an element a certain amount. |