Library version: | 1.4.6 |
---|---|
Library scope: | global |
Named arguments: | supported |
AppiumLibrary is a Mobile App testing library for Robot Framework.css
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.html
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:java
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.python
For example:android
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:ios
Strategy | Example | Description | Note |
identifier | Click Element | identifier=my_element | Matches by @id attribute | |
id | Click Element | id=my_element | Matches by @resource-id attribute | |
accessibility_id | Click Element | accessibility_id=button3 | Accessibility options utilize. | |
xpath | Click Element | xpath=//UIATableView/UIATableCell/UIAButton | Matches with arbitrary XPath | |
class | Click Element | class=UIAPickerWheel | Matches by class | |
android | Click Element | android=UiSelector().description('Apps') | Matches by Android UI Automator | |
ios | Click Element | ios=.buttons().withName('Apps') | Matches by iOS UI Automation | |
css | Click Element | css=.green_button | Matches by css in webview | |
name | Click Element | name=my_element | Matches by @name attribute | Only valid for Selendroid |
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.git
For example:github
@{elements} Get Webelements class=UIAButton Click Element @{elements}[2]
Arguments | Documentation | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
timeout=5, run_on_failure=Capture Page Screenshot | AppiumLibrary can be imported with optional arguments.web
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:
|
Background App · Capture Page Screenshot · Clear Text · Click A Point · Click Button · Click Element · Click Element At Coordinates · Click Text · Close All Applications · Close Application · Element Attribute Should Match ·Element Name Should Be · Element Should Be Disabled · Element Should Be Enabled · Element Should Be Visible · Element Should Contain Text · Element Should Not Contain Text · Element Text Should Be · Element Value Should Be ·Get Activity · Get Appium SessionId · Get Appium Timeout · Get Capability · Get Contexts · Get Current Context · Get Element Attribute · Get Element Location · Get Element Size · Get Matching Xpath Count ·Get Network Connection Status · Get Source · Get Text · Get Webelement · Get Webelements · Get Window Height · Get Window Width · Go Back · Go To Url · Hide Keyboard · Input Password · Input Text · Input Value · Install App ·Landscape · Launch Application · Lock · Log Source · Long Press · Long Press Keycode · Open Application · Page Should Contain Element · Page Should Contain Text · Page Should Not Contain Element · Page Should Not Contain Text ·Pinch · Portrait · Press Keycode · Pull File · Pull Folder · Push File · Quit Application · Register Keyword To Run On Failure · Remove Application · Reset Application · Scroll · Scroll Down · Scroll Up · Set Appium Timeout ·Set Network Connection Status · Shake · Start Activity · Swipe · Swipe By Percent · Switch Application · Switch To Context · Tap · Text Should Be Visible · Wait Activity · Wait Until Element Is Visible · Wait Until Page Contains ·Wait Until Page Contains Element · Wait Until Page Does Not Contain · Wait Until Page Does Not Contain Element · Xpath Should Match X Times · Zoom
背景應用程序 · 捕獲頁面截圖 · 明文 · 單擊A點 · 單擊按鈕 · 單擊元素 · 單擊座標時的元素 · 單擊文本 · 關閉全部應用程序 · 關閉應用程序 · 元素屬性應匹配 · 元素名稱應爲 · 元素應該被禁用 · 元素應該被啓用 · 元素應該是可見的 · 元素應該包含文本 ·元素不該該包含文本 · 元素文本應該 · 元素值應該 · 獲取活動 · 獲取Appium SessionId · 獲取Appium超時 · 得到能力 · 獲取上下文 · 獲取當前上下文 · 獲取元素屬性 · 獲取元素位置 · 獲取元素大小 · 獲取匹配Xpath計數 · 獲取網絡鏈接狀態 · 獲取源 ·獲取文本 · 獲取Webelement · 獲取Webelements · 獲取窗口高度 · 獲取窗口寬度 · 返回 · 轉到URL · 隱藏鍵盤 · 輸入密碼 · 輸入文本 · 輸入值 · 安裝應用 · 園林 · 啓動應用程序 · 鎖 · 日誌源 · 長按 · 長按鍵碼 · 打開應用 · 頁面應包含元素 · 頁面應包含文本 ·頁面不該包含元素 · 頁面不該包含文本 · 捏 · 肖像 · 按鍵碼 · 拉文件 · 拉文件夾 · 按文件 · 退出應用程序 · 註冊關鍵字上運行故障 · 刪除應用程序 · 復位應用程序 · 滾動 · 向下滾動 · 向上滾動 · 設置Appium超時 · 設置網絡鏈接狀態 · 搖 · 啓動活動 · 滑動 ·按百分比滑動 · 切換應用程序 · 切換到上下文 · 點擊 · 文本應該可見 · 等待活動 · 等到元素可見 · 等到頁面包含 · 等到頁面包含元素 · 等到頁面不包含 · 等待頁面不包含元素 · Xpath應匹配X次 · 縮放
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:
1. is a string pattern match i.e. the 'text' attribute should end with the string 'foobar' 2. is a regular expression match i.e. the regexp 'f.*ar' should be within the 'text' attribute 3. is a boolead match i.e. the 'enabled' attribute should be True 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
metastate=1 --> Shift is pressed metastate=2 --> Alt is pressed metastate=3 --> Shift+Alt is pressed
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. |
圖書館版本: | 1.4.6 |
---|---|
圖書館範圍: | 全球 |
命名參數: | 支持的 |
AppiumLibrary是Robot Framework的移動應用程序測試庫。
AppiumLibrary中須要在頁面上查找元素的全部關鍵字都接受一個參數,a locator
或a webelement
。locator
是一個字符串,描述如何使用指定不一樣位置策略的語法來定位元素。webelement
是一個包含WebElement實例的變量,它是元素的表示形式。
默認狀況下,當提供定位器時,它將與特定元素類型的鍵屬性進行匹配。對於iOS和Android,key屬性適用id
於全部元素,定位元素很容易使用id
。例如:
單擊元素id = my_element
在AppiumLibrary 1.4中新增,id
而且xpath
不須要指定,可是xpath
應該以//
else 開頭,只需使用xpath
定位器,以下所述。
例如:
單擊元素my_element 等待頁面包含元素// * [/ type="android.widget.EditText「]
Appium還支持一些Mobile JSON Wire Protocol定位器策略。也能夠經過指定具備定位符前綴的查找策略來指定AppiumLibrary應該用於查找元素的方法。支持的策略是:
戰略 | 例 | 描述 | 注意 |
識別碼 | 單擊元素| 標識符= my_element | 由@id屬性匹配 | |
ID | 單擊元素| ID = my_element | 匹配@ resource-id屬性 | |
accessibility_id | 單擊元素| accessibility_id = BUTTON3 | 輔助功能選項使用。 | |
XPath的 | 單擊元素| 的xpath = // UIATableView / UIATableCell / UIAButton | 與任意XPath匹配 | |
類 | 單擊元素| 類= UIAPickerWheel | 按類匹配 | |
安卓 | 單擊元素| 機器人= UiSelector()。描述( '應用') | Android UI Automator匹配 | |
IOS | 單擊元素| IOS = .buttons()。withName( '應用') | iOS UI Automation匹配 | |
CSS | 單擊元素| CSS = .green_button | 在webview中經過css匹配 | |
名稱 | 單擊元素| 名稱= my_element | 匹配@name屬性 | 僅適用於Selendroid |
從AppiumLibrary的1.4版開始,能夠傳遞包含WebElement而不是字符串定位符的參數。要獲取WebElement,請使用新的Get WebElements或Get WebElement關鍵字。
例如:
@ {elements} Get Webelements class = UIAButton Click Element @ {elements} [2]
參數 | 文檔 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
timeout = 5, run_on_failure =捕獲頁面截圖 | 可使用可選參數導入AppiumLibrary。
默認狀況下,Capture Page Screenshot將用於截取當前頁面的屏幕截圖。使用No Operation值將徹底禁用此功能。有關此功能的更多信息,請參閱註冊關鍵字以運行失敗關鍵字。 例子:
|
背景應用程序 · 捕獲頁面截圖 · 明文 · 單擊A點 · 單擊按鈕 · 單擊元素 · 單擊座標時的元素 · 單擊文本 · 關閉全部應用程序 · 關閉應用程序 · 元素屬性應匹配 · 元素名稱應爲 · 元素應該被禁用 · 元素應該被啓用 · 元素應該是可見的 · 元素應該包含文本 ·元素不該該包含文本 · 元素文本應該 · 元素值應該 · 獲取活動 · 獲取Appium SessionId · 獲取Appium超時 · 得到能力 · 獲取上下文 · 獲取當前上下文 · 獲取元素屬性 · 獲取元素位置 · 獲取元素大小 · 獲取匹配Xpath計數 · 獲取網絡鏈接狀態 · 獲取源 ·獲取文本 · 獲取Webelement · 獲取Webelements · 獲取窗口高度 · 獲取窗口寬度 · 返回 · 轉到URL · 隱藏鍵盤 · 輸入密碼 · 輸入文本 · 輸入值 · 安裝應用 · 園林 · 啓動應用程序 · 鎖 · 日誌源 · 長按 · 長按鍵碼 · 打開應用 · 頁面應包含元素 · 頁面應包含文本 ·頁面不該包含元素 · 頁面不該包含文本 · 捏 · 肖像 · 按鍵碼 · 拉文件 · 拉文件夾 · 按文件 · 退出應用程序 · 註冊關鍵字上運行故障 · 刪除應用程序 · 復位應用程序 · 滾動 · 向下滾動 · 向上滾動 · 設置Appium超時 · 設置網絡鏈接狀態 · 搖 · 啓動活動 · 滑動 ·按百分比滑動 · 切換應用程序 · 切換到上下文 · 點擊 · 文本應該可見 · 等待活動 · 等到元素可見 · 等到頁面包含 · 等到頁面包含元素 · 等到頁面不包含 · 等待頁面不包含元素 · Xpath應匹配X次 · 縮放
關鍵詞 | 參數 | 文檔 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
背景應用 | 秒= 5 | 將應用程序放在設備的後臺一段時間。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
捕獲頁面截圖 | 文件名=無 | 獲取當前頁面的屏幕截圖並將其嵌入到日誌中。 filename參數指定要將屏幕截圖寫入的文件的名稱。若是沒有給出文件名,屏幕截圖將保存到寫入Robot Framework日誌文件的目錄下的appium-screenshot- <counter> .png文件中。該文件名,若是它不是以絕對格式給出也被認爲是相對於同一目錄。 css可用於修改屏幕截圖的截取方式。默認狀況下,更改bakground顏色以免在頁面佈局以某種方式損壞時可能出現背景泄漏問題。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
明文 | 定位器 | 清除定位器標識的文本字段。 有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
單擊A Point | x = 0, y = 0, 持續時間= 100 | 點擊一個點 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
單擊按鈕 | index_or_name | 點擊按鈕 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
單擊元素 | 定位器 | 單擊定位器標識的元素。 任意元素的關鍵屬性是索引和名稱。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
單擊座標處的元素 | coordinate_X, coordinate_Y | 單擊某個座標處的元素 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
單擊文本 | text, exact_match = False | 單擊標識的文本 默認狀況下,嘗試單擊第一個文本涉及給定 若是有屢次使用 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
關閉全部應用程序 | 關閉全部打開的應用程序。 此關鍵字旨在用於測試或套件拆解,以確保在測試執行完成以前關閉全部應用程序。 在此關鍵字以後,Open Application返回的應用程序索引將重置並從1開始。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
關閉申請 | 關閉當前應用程序並關閉webdriver會話。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素屬性應該匹配 | locator, attr_name,match_pattern, regexp = False | 驗證元素的屬性是否與預期條件匹配。 該元素由定位器標識。有關定位元素的詳細信息,請參閱簡介。若是多個元素匹配,則選擇第一個元素。 該attr_name是選定的元素中的屬性的名稱。 若是match_pattern是匹配,match_pattern用於匹配
在正則表達式定義字符串是否匹配使用正則表達式完成(即內置的圖書館應該匹配的正則表達式或字符串模式匹配(即內置的圖書館應該匹配) 例子:
1.是一個字符串模式匹配,即'text'屬性應該以字符串'foobar'結尾 2.是一個正則表達式匹配,即正則表達式'f。* ar'應該在'text'屬性中 3.是一個boolead匹配即'enabled'屬性應爲True 注意:在Android上,支持的屬性名稱在 AndroidElement類的getBoolAttribute()和getStringAttribute()方法中進行了硬編碼。目前支持(appium v1.4.11): contentDescription,text,className,resourceId,enabled,checkable,checked,clickable,focusable,focused,longClickable,scrollable,selected,displayed 注意:某些屬性能夠經過兩種不一樣的方式進行評估,例如:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素名稱應該是 | 定位器, 預期 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素應該被禁用 | locator, loglevel = INFO | 驗證已使用定位器標識的元素已禁用。 任意元素的關鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
應該啓用元素 | locator, loglevel = INFO | 驗證是否已啓用使用定位器標識的元素。 任意元素的關鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素應該是可見的 | locator, loglevel = INFO | 驗證使用定位器標識的元素是否可見。 任意元素的關鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 AppiumLibrary 1.4.5中的新功能 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素應包含文本 | locator, expected,message = | 驗證由 若是您但願在元素的文本上斷言精確(非子串)匹配,請使用元素文本。 任意元素的關鍵屬性是 AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素不該包含文本 | locator, expected,message = | 驗證標識的元素
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
元素文本應該是 | locator, expected,message = | 驗證由 與Element Should Contain Text相比,此關鍵字不會嘗試子字符串匹配,而是在標識的元素上進行精確匹配
AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
要素值應該是 | 定位器, 預期 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取活動 | 檢索設備上的當前活動。 僅適用於Android。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取Appium SessionId | 返回當前會話ID做爲參考 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取Appium超時 | 獲取各類關鍵字使用的超時(以秒爲單位)。 有關說明,請參閱設置Appium超時。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
得到能力 | capability_name | 按所需的功能名稱返回所需的功能值 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取上下文 | 獲取可用的上下文。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取當前上下文 | 獲取當前上下文。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取元素屬性 | 定位器, 屬性 | 使用給定屬性獲取元素屬性:name,value,... 例子:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取元素位置 | 定位器 | 獲取元素位置 任意元素的關鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取元素大小 | 定位器 | 獲取元素大小 任意元素的關鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取匹配的Xpath計數 | XPath的 | 返回匹配的元素數 不該該爲'xpath' 使用xpath =前綴。假設XPath。
若是您但願斷言匹配元素的數量,請使用Xpath應匹配X次。 AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取網絡鏈接狀態 | 返回指定網絡鏈接類型的整數位掩碼。 僅適用於Android。 有關詳細信息,請參閱設置網絡鏈接狀態 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取來源 | 返回當前頁面的整個源。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取文字 | 定位器 | 獲取元素文本(對於混合和移動瀏覽器使用xpath定位器,其餘可能會致使問題) 例:
AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲得Webelement | 定位器 | 返回第一個匹配的WebElement對象 例:
AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
得到Webelements | 定位器 | 返回匹配的WebElement對象列表 例:
此關鍵字在AppiumLibrary 1.4中如下列方式更改:
AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
得到窗口高度 | 獲取當前設備高度。 例:
AppiumLibrary 1.4.5中的新功能 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
獲取窗口寬度 | 獲取當前設備寬度。 例:
AppiumLibrary 1.4.5中的新功能 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
回去 | 在瀏覽器歷史記錄中向後退一步。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
轉到網址 | 網址 | 在默認Web瀏覽器中打開URL。 例:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
隱藏鍵盤 | KEY_NAME =無 | 隱藏設備上的軟件鍵盤。(可選)在iOS中,使用key_name按特定鍵,例如。完成。在Android中,不使用任何參數。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
輸入密碼 | 定位器, 文本 | 將給定密碼鍵入由locator標識的文本字段。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
輸入文本 | 定位器, 文本 | 將給定文本鍵入由定位符標識的文本字段。 有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
輸入值 | 定位器, 文本 | 將給定值設置爲locator標識的文本字段。這是一個僅限IOS的關鍵字,輸入值使用set_value 有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
安裝應用程序 | app_path, app_package | 經過Appium安裝App 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
景觀 | 將設備方向設置爲LANDSCAPE |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
啓動程序 | 啓動程序。應用程序能夠在Appium會話運行時啓動。此關鍵字可用於在測試用例期間或測試用例之間啓動應用程序。 當Open Application運行測試時,此關鍵字有效。這是在測試用例之間啓動應用程序和退出應用程序的好習慣。因爲Suite Setup是Open Application,所以可使用Test Setup 啓動應用程序 示例(語法只是一種表示,請參閱RF指南以瞭解Setup / Teardown的用法):
請參閱退出應用程序以退出應用程序但保持Appium sesion運行。 AppiumLibrary 1.4.6中的新功能 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
鎖 | 秒= 5 | 將設備鎖定一段時間。僅適用於iOS。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
日誌源 | 記錄等級= INFO | 記錄並返回當前頁面或框架的整個html源。 該日誌級別參數定義所使用的日誌級別。有效的日誌級別爲WARN,INFO(默認),DEBUG,TRACE和NONE(無日誌記錄)。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
長按 | 定位器 | 長按元素 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
長按鍵碼 | keycode, metastate =無 | 向設備發送長按鍵代碼。 僅適用於Android。 有關詳細信息,請參閱按鍵代碼。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
開放申請 | remote_url, alias = None,** kwargs | 打開給定Appium服務器的新應用程序。appium服務器,Android和iOS的功能,請查看http://appium.io/slate/en/master/?python#appium-server-capabilities
例子:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
頁面應包含元素 | locator, loglevel = INFO | 驗證當前頁面是否包含locator元素。 若是此關鍵字失敗,它將使用使用可選loglevel參數指定的日誌級別自動記錄頁面源。將NONE做爲級別禁用日誌記錄。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
頁面應包含文本 | text, loglevel = INFO | 驗證當前頁面是否包含文本。 若是此關鍵字失敗,它將使用使用可選loglevel參數指定的日誌級別自動記錄頁面源。將NONE做爲級別禁用日誌記錄。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
頁面不該包含元素 | locator, loglevel = INFO | 驗證當前頁面不包含locator元素。 若是此關鍵字失敗,它將使用使用可選loglevel參數指定的日誌級別自動記錄頁面源。將NONE做爲級別禁用日誌記錄。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
頁面不該包含文本 | text, loglevel = INFO | 驗證當前頁面不包含文本。 若是此關鍵字失敗,它將使用使用可選loglevel參數指定的日誌級別自動記錄頁面源。將NONE做爲級別禁用日誌記錄。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
捏 | locator, percent = 200%,steps = 1 | 捏必定量的元素。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
肖像 | 將設備方向設置爲PORTRAIT |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
按鍵碼 | keycode, metastate =無 | 向設備發送按鍵代碼。 僅適用於Android。 能夠在http://developer.android.com/reference/android/view/KeyEvent.html中找到可能的密鑰代碼和元狀態。 Meta狀態描述按鍵修改器的按下狀態,例如Shift,Ctrl和Alt鍵。Meta State是一個整數,其中每一個設置爲1的位表示按下的元鍵。 例如
metastate = 1 - > Shift被按下 metastate = 2 - > Alt被按下 metastate = 3 - >按下Shift + Alt
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
拉文件 | path, decode = False | 在路徑中檢索文件並返回其內容。 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
拉文件夾 | path, decode = False | 檢索路徑中的文件夾。返回壓縮文件夾的內容。 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
推送文件 | path, data, encode = False | 將數據放在指定爲path的文件中。 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
退出申請 | 退出申請。Appium會話保持活動狀態時,應用程序能夠退出。此關鍵字可用於在測試用例期間或測試用例之間關閉應用程序。 請參閱啓動應用程序以獲取解釋 AppiumLibrary 1.4.6中的新功能 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
註冊關鍵字以在失敗時運行 | 關鍵詞 | 設置關鍵字在AppiumLibrary關鍵字失敗時執行。 keyword_name是在AppiumLibrary關鍵字失敗時將執行的關鍵字(來自任何可用庫)的名稱。沒法使用須要參數的關鍵字。使用值「Nothing」將徹底禁用此功能。 要使用的初始關鍵字是在導入中設置的,默認狀況下使用的關鍵字是Capture Page Screenshot。在出現故障時拍攝屏幕截圖是一個很是有用的功能,但請注意它能夠減慢執行速度。 此關鍵字返回先前註冊的失敗關鍵字的名稱。它能夠用於之後恢復原始值。 例:
這種運行失敗功能僅在Python / Jython 2.4或更高版本上運行測試時纔有效,並且根本不適用於IronPython。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
刪除申請 | APPLICATION_ID | 刪除使用應用程序ID標識的應用程序 例:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
重置申請 | 重置申請。Appium會話保持活動狀態時,能夠重置打開應用程序。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
滾動 | start_locator, end_locator | 從一個元素滾動到另外一個元素任意元素的鍵屬性是id和name。有關定位元素的詳細信息,請參閱簡介。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
向下滾動 | 定位器 | 向下滾動到元素 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
向上滑動 | 定位器 | 向上滾動到元素 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
設置Appium超時 | 秒 | 設置各類關鍵字使用的超時秒數。 有幾個Wait ...關鍵字以超時做爲參數。全部這些超時參數都是可選的。可使用此關鍵字全局設置全部這些超時使用的超時。 此關鍵字返回先前的超時值,可用於稍後設置舊值。默認超時爲5秒,但能夠在導入時更改。 例:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
設置網絡鏈接狀態 | connectionStatus | 設置網絡鏈接狀態。 僅適用於Android。 可能的值:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
搖 | 搖晃設備 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
開始活動 | appPackage, appActivity,**選擇 | 在測試期間打開任意活動。若是活動屬於另外一個應用程序,則啓動該應用程序並打開活動。 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
刷卡 | start_x, start_y, offset_x,offset_y, duration = 1000 | 可選持續時間從一個點滑動到另外一個點。 ARGS:
用法:
注意: Android'Swipe'沒法正常工做,請使用 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
按百分比滑動 | start_x, start_y, end_x,end_y, duration = 1000 | 可選持續時間從屏幕的百分比滑動到另外一個百分比。普通滑動沒法針對不一樣的屏幕分辨率進行縮放,這可使用百分比來避免。 ARGS:
用法:
注意:這也考慮了iOS和Android之間不一樣的滑動行爲。 AppiumLibrary 1.4.5中的新功能 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
切換應用 | index_or_alias | 按索引或別名切換活動應用程序。 index_or_alias是應用程序索引(整數)或別名(字符串)。獲取索引做爲Open Application的返回值。 此關鍵字返回上一個活動應用程序的索引,該索引可用於稍後切換回該應用程序。 例:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
切換到上下文 | CONTEXT_NAME | 切換到新的上下文 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
龍頭 | locator, x_offset = None,y_offset = None, count = 1 | 點擊標識的元素 ARGS:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
文字應該是可見的 | text, exact_match = False,loglevel = INFO | 驗證用文本標識的元素是否可見。 AppiumLibrary 1.4.5中的新功能 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等待活動 | 活動, 超時, 間隔= 1 | 等待活動:阻止直到目標活動出現或超時。 僅適用於Android。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等到元素可見 | locator, timeout =無, 錯誤=無 | 等待直到使用定位器指定的元素可見。 若是超時在元素可見以前到期,則失敗。有關超時及其默認值的更多信息,請參閱簡介。 錯誤可用於覆蓋默認錯誤消息。 另請參閱等待直到頁面包含,等待直到頁面包含元素,等待條件和BuiltIn關鍵字等待直到關鍵字成功。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等到頁面包含 | text, timeout = None,error = None | 等待文本出如今當前頁面上。 若是超時在文本出現以前到期,則會失敗。有關超時及其默認值的更多信息,請參閱簡介。 錯誤可用於覆蓋默認錯誤消息。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等到頁面包含元素 | locator, timeout =無, 錯誤=無 | 等待直到使用定位器指定的元素出如今當前頁面上。 若是超時在元素出現以前到期,則失敗。有關超時及其默認值的更多信息,請參閱簡介。 錯誤可用於覆蓋默認錯誤消息。 另請參閱等待直到頁面包含,等到頁面不包含 等待直到頁面不包含元素和BuiltIn關鍵字等待直到關鍵字成功。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等到頁面不包含 | text, timeout = None,error = None | 等待文本從當前頁面消失。 若是超時在文本消失以前到期,則失敗。有關超時及其默認值的更多信息,請參閱簡介。 錯誤可用於覆蓋默認錯誤消息。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
等到頁面不包含元素 | locator, timeout =無, 錯誤=無 | 等待直到使用定位器指定的元素從當前頁面消失。 若是超時在元素消失以前到期,則失敗。有關超時及其默認值的更多信息,請參閱簡介。 錯誤可用於覆蓋默認錯誤消息。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Xpath應該匹配X次 | xpath, count, error = None, loglevel = INFO | 驗證頁面是否包含給定的給定數量的元素 不該該爲'xpath' 使用xpath =前綴。假設XPath。
有關參數的說明,請參見日誌源 AppiumLibrary 1.4中的新功能。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
放大 | locator, percent = 200%,steps = 1 | 放大必定數量的元素。 |
共有85個關鍵字。
由Libdoc於2017-10-30 01:55:33 生成。