robotframework-appiumlibrary 用法

AppiumLibrary

Library version: 1.4.6
Library scope: global
Named arguments: supported

Introduction

AppiumLibrary is a Mobile App testing library for Robot Framework.css

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 webelementlocator 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

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: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

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.git

For example:github

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

Importing

Arguments Documentation
timeout=5, run_on_failure=Capture Page Screenshot

AppiumLibrary can be imported with optional arguments.web

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:

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

Shortcuts

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次 · 缩放

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 text.

By default tries to click first text involves given text, if you would like to click exactly matching text, then set exact_match to True.

If there are multiple use of text and you do not want first one, use locator with Get Web Elements instead.

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

  • boolean or 'True'/'true'/'False'/'false' String then a boolean match is applied
  • any other string is cause a string match

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:

Element Attribute Should Match xpath = //*[contains(@text,'foo')] text *foobar  
Element Attribute Should Match xpath = //*[contains(@text,'foo')] text f.*ar regexp = True
Element Attribute Should Match xpath = //*[contains(@text,'foo')] enabled True  
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 Attribute Should Match xpath = //*[contains(@text,'example text')] name txt_field_name
Element Name Should Be xpath = //*[contains(@text,'example text')] txt_field_name  
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 locator contains text expected.

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 id and xpathmessage can be used to override the default error message.

New in AppiumLibrary 1.4.

Element Should Not Contain Text locator, expected,message=

Verifies element identified by locator does not contain text expected.

message can be used to override the default error message. See Element Should Contain Text for more details.

Element Text Should Be locator, expected,message=

Verifies element identified by locator exactly contains text expected.

In contrast to Element Should Contain Text, this keyword does not try a substring match but an exact match on the element identified by locator.

message can be used to override the default error message.

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 Attribute locator name
Get Element Attribute locator value
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 xpath

One should not use the xpath= prefix for 'xpath'. XPath is assumed.

Correct:    
${count} Get Matching Xpath Count //android.view.View[@text='Test']
Incorrect:    
${count} Get Matching Xpath Count xpath=//android.view.View[@text='Test']

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:

${text} Get Text //*[contains(@text,'foo')]

New in AppiumLibrary 1.4.

Get Webelement locator

Returns the first WebElement object matching locator.

Example:

${element} Get Webelement id=my_element
Click Element ${element}  

New in AppiumLibrary 1.4.

Get Webelements locator

Returns list of WebElement objects matching locator.

Example:

@{elements} Get Webelements id=my_element
Click Element @{elements}[2]  

This keyword was changed in AppiumLibrary 1.4 in following ways:

  • Name is changed from Get Elements to current one.
  • Deprecated argument fail_on_error, use Run Keyword and Ignore Error if necessary.

New in AppiumLibrary 1.4.

Get Window Height  

Get current device height.

Example:

${width} Get Window Height  
${height} Get Window Height  
Click A Point ${width ${height}

New in AppiumLibrary 1.4.5

Get Window Width  

Get current device width.

Example:

${width} Get Window Height  
${height} Get Window Height  
Click A Point ${width ${height}

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:

Open Application http://localhost:4755/wd/hub platformName=iOS platformVersion=7.0 deviceName='iPhone Simulator' browserName=Safari
Go To URL http://m.webapp.com        
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.

  • app_path - path to app
  • app_package - package of install app to verify
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):

[Setup Suite]          
  Open Application http://localhost:4723/wd/hub platformName=Android deviceName=192.168.56.101:5555 app=${CURDIR}/demoapp/OrangeDemoApp.apk
[Test Setup]          
  Launch Application        
    <<<test execution>>>      
    <<<test execution>>>      
[Test Teardown]          
  Quit Application        
[Suite Teardown]          
  Close Application        

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

Option Man. Description
remote_url Yes Appium server url
alias no alias

Examples:

Open Application http://localhost:4723/wd/hub alias=Myapp1 platformName=iOS platformVersion=7.0 deviceName='iPhone Simulator' app=your.app  
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=4.2.2 deviceName=192.168.56.101:5555 app=${CURDIR}/demoapp/OrangeDemoApp.apk appPackage=com.netease.qa.orangedemo appActivity=MainActivity
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

  • META_SHIFT_ON = 1
  • META_ALT_ON = 2
metastate=1 --> Shift is pressed
metastate=2 --> Alt is pressed
metastate=3 --> Shift+Alt is pressed
  • _keycode- - the keycode to be sent to the device
  • _metastate- - status of the meta keys
Pull File path,decode=False

Retrieves the file at path and return it's content.

Android only.

  • path - the path to the file on the device
  • decode - True/False decode the data (base64) before returning it (default=False)
Pull Folder path,decode=False

Retrieves a folder at path. Returns the folder's contents zipped.

Android only.

  • path - the path to the folder on the device
  • decode - True/False decode the data (base64) before returning it (default=False)
Push File path, data,encode=False

Puts the data in the file specified as path.

Android only.

  • path - the path on the device
  • data - data to be written to the file
  • encode - True/False encode the data as base64 before writing it to the file (default=False)
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:

Register Keyword To Run On Failure Log Source # Run Log Source on failure.  
${previous kw}= Register Keyword To Run On Failure Nothing # Disables run-on-failure functionality and stores the previous kw name in a variable.
Register Keyword To Run On Failure ${previous kw} # Restore to the previous keyword.  

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:

Remove Application com.netease.qa.orangedemo
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:

${orig timeout} = Set Appium Timeout 15 seconds
Open page that loads slowly    
Set Appium Timeout ${orig timeout}  
Set Network Connection Status connectionStatus

Sets the network connection Status.

Android only.

Possible values:

Value Alias Data Wifi Airplane Mode
0 (None) 0 0 0
1 (Airplane Mode) 0 0 1
2 (Wifi only) 0 1 0
4 (Data only) 1 0 0
6 (All network on) 1 1 0
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.

  • appPackage - The package containing the activity to start.
  • appActivity - The activity to start.
  • appWaitPackage - Begin automation after this package starts (optional).
  • appWaitActivity - Begin automation after this activity starts (optional).
  • intentAction - Intent to start (opt_ional).
  • intentCategory - Intent category to start (optional).
  • intentFlags - Flags to send to the intent (optional).
  • optionalIntentArguments - Optional arguments to the intent (optional).
  • stopAppOnReset - Should the app be stopped on reset (optional)?
Swipe start_x, start_y,offset_x, offset_y,duration=1000

Swipe from one point to another point, for an optional duration.

Args:

  • start_x - x-coordinate at which to start
  • start_y - y-coordinate at which to start
  • offset_x - x-coordinate distance from start_x at which to stop
  • offset_y - y-coordinate distance from start_y at which to stop
  • duration - (optional) time to take the swipe, in ms.

Usage:

Swipe 500 100 100 0 1000

NOTE: Android 'Swipe' is not working properly, use offset_x and offset_y as if these are destination points.

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:

  • start_x - x-percent at which to start
  • start_y - y-percent at which to start
  • end_x - x-percent distance from start_x at which to stop
  • end_y - y-percent distance from start_y at which to stop
  • duration - (optional) time to take the swipe, in ms.

Usage:

Swipe By Percent 90 50 10 50 # Swipes screen from right to left.

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:

${appium1}= Open Application http://localhost:4723/wd/hub alias=MyApp1 platformName=iOS platformVersion=7.0 deviceName='iPhone Simulator' app=your.app
${appium2}= Open Application http://localhost:4755/wd/hub alias=MyApp2 platformName=iOS platformVersion=7.0 deviceName='iPhone Simulator' app=your.app
Click Element sendHello # Executed on appium running at localhost:4755          
Switch Application ${appium1} # Switch using index          
Click Element ackHello # Executed on appium running at localhost:4723          
Switch Application MyApp2 # Switch using alias          
Page Should Contain Text ackHello Received # Executed on appium running at localhost:4755          
Switch To Context context_name

Switch to a new context

Tap locator,x_offset=None,y_offset=None,count=1

Tap element identified by locator.

Args:

  • x_offset - (optional) x coordinate to tap, relative to the top left corner of the element.
  • y_offset - (optional) y coordinate. If y is used, x must also be set, and vice versa
  • count - can be used for multiple times of tap on that element
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.

  • activity - target activity
  • timeout - max wait time, in seconds
  • interval - sleep interval between retries, in seconds
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 ContainsWait 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 ContainWait Until Page Contains ElementWait 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 ContainsWait 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 ContainsWait Until Page Contains ElementWait 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 ContainsWait Until Page Does Not ContainWait 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 xpath.

One should not use the xpath= prefix for 'xpath'. XPath is assumed.

Correct:    
Xpath Should Match X Times //android.view.View[@text='Test'] 1
Incorrect:    
Xpath Should Match X Times xpath=//android.view.View[@text='Test'] 1

error can be used to override the default error message.

See Log Source for explanation about loglevel argument.

New in AppiumLibrary 1.4.

Zoom locator,percent=200%,steps=1

Zooms in on an element a certain amount.

 

AppiumLibrary

图书馆版本: 1.4.6
图书馆范围: 全球
命名参数: 支持的

介绍

AppiumLibrary是Robot Framework的移动应用程序测试库。

找到或指定元素

AppiumLibrary中须要在页面上查找元素的全部关键字都接受一个参数,a locator或a webelementlocator是一个字符串,描述如何使用指定不一样位置策略的语法来定位元素。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

使用webelements

从AppiumLibrary的1.4版开始,能够传递包含WebElement而不是字符串定位符的参数。要获取WebElement,请使用新的Get WebElementsGet WebElement关键字。

例如:

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

输入

参数 文档
timeout = 5, run_on_failure =捕获页面截图

可使用可选参数导入AppiumLibrary。

timeout是用于等待全部等待操做的默认超时。稍后可使用Set Appium Timeout设置它

run_on_failure 指定AppiumLibrary关键字失败时要执行的关键字的名称(来自任何可用的库)。

默认状况下,Capture Page Screenshot将用于截取当前页面的屏幕截图。使用No Operation值将彻底禁用此功能。有关此功能的更多信息,请参阅注册关键字以运行失败关键字。

例子:

图书馆 AppiumLibrary 10 #将默认超时设置为10秒  
图书馆 AppiumLibrary 超时= 10 run_on_failure =无操做 #将默认超时设置为10秒,而且在失败时不执行任何操做

快捷键

背景应用程序 · 捕获页面截图 · 明文 · 单击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

单击标识的文本text

默认状况下,尝试单击第一个文本涉及给定text,若是要单击彻底匹配的文本,则设置exact_matchTrue

若是有屡次使用text而您不想使用第一个,请使用定位器替换Get Web Elements

关闭全部应用程序  

关闭全部打开的应用程序。

此关键字旨在用于测试或套件拆解,以确保在测试执行完成以前关闭全部应用程序。

在此关键字以后,Open Application返回的应用程序索引将重置并从1开始。

关闭申请  

关闭当前应用程序并关闭webdriver会话。

元素属性应该匹配 locator, attr_namematch_pattern, regexp = False

验证元素的属性是否与预期条件匹配。

该元素由定位器标识。有关定位元素的详细信息,请参阅简介。若是多个元素匹配,则选择第一个元素。

attr_name是选定的元素中的属性的名称。

若是match_pattern是匹配,match_pattern用于匹配

  • boolean或'True'/'true'/'False'/'false'字符串而后应用布尔匹配
  • 任何其余字符串都会致使字符串匹配

正则表达式定义字符串是否匹配使用正则表达式完成(即内置的图书馆应该匹配的正则表达式或字符串模式匹配(即内置的图书馆应该匹配

例子:

元素属性应该匹配 xpath = // * [contains(@ text,'foo')] 文本 * foobar的  
元素属性应该匹配 xpath = // * [contains(@ text,'foo')] 文本 regexp =真
元素属性应该匹配 xpath = // * [contains(@ text,'foo')] 启用 真正  
1.是一个字符串模式匹配,即'text'属性应该以字符串'foobar'结尾 2.是一个正则表达式匹配,即正则表达式'f。* ar'应该在'text'属性中 3.是一个boolead匹配即'enabled'属性应为True 

注意:在Android上,支持的属性名称在 AndroidElement类的getBoolAttribute()和getStringAttribute()方法中进行了硬编码。目前支持(appium v​​1.4.11): contentDescription,text,className,resourceId,enabled,checkable,checked,clickable,focusable,focused,longClickable,scrollable,selected,displayed

注意:某些属性能够经过两种不一样的方式进行评估,例如:

元素属性应该匹配 xpath = // * [contains(@ text,'example text')] 名称 txt_field_name
元素名称应该是 xpath = // * [contains(@ text,'example text')] txt_field_name  
元素名称应该是 定位器, 预期  
元素应该被禁用 locator, loglevel = INFO

验证已使用定位器标识的元素已禁用。

任意元素的关键属性是idname。有关定位元素的详细信息,请参阅简介

应该启用元素 locator, loglevel = INFO

验证是否已启用使用定位器标识的元素。

任意元素的关键属性是idname。有关定位元素的详细信息,请参阅简介

元素应该是可见的 locator, loglevel = INFO

验证使用定位器标识的元素是否可见。

任意元素的关键属性是idname。有关定位元素的详细信息,请参阅简介

AppiumLibrary 1.4.5中的新功能

元素应包含文本 locator, expectedmessage =

验证由locator包含文本标识的元素expected

若是您但愿在元素的文本上断言精确(非子串)匹配,请使用元素文本

任意元素的关键属性是idxpathmessage可用于覆盖默认错误消息。

AppiumLibrary 1.4中的新功能。

元素不该包含文本 locator, expectedmessage =

验证标识的元素locator不包含文本expected

message可用于覆盖默认错误消息。有关详细信息,请参阅元素应包含文本

元素文本应该是 locator, expectedmessage =

验证由locator确切包含文本标识的元素expected

Element Should Contain Text相比,此关键字不会尝试子字符串匹配,而是在标识的元素上进行精确匹配locator

message 可用于覆盖默认错误消息。

AppiumLibrary 1.4中的新功能。

要素值应该是 定位器, 预期  
获取活动  

检索设备上的当前活动。

仅适用于Android。

获取Appium SessionId  

返回当前会话ID做为参考

获取Appium超时  

获取各类关键字使用的超时(以秒为单位)。

有关说明,请参阅设置Appium超时

得到能力 capability_name

按所需的功能名称返回所需的功能值

获取上下文  

获取可用的上下文。

获取当前上下文  

获取当前上下文。

获取元素属性 定位器, 属性

使用给定属性获取元素属性:name,value,...

例子:

获取元素属性 定位器 名称
获取元素属性 定位器
获取元素位置 定位器

获取元素位置

任意元素的关键属性是idname。有关定位元素的详细信息,请参阅简介

获取元素大小 定位器

获取元素大小

任意元素的关键属性是idname。有关定位元素的详细信息,请参阅简介

获取匹配的Xpath计数 XPath的

返回匹配的元素数 xpath

不该该为'xpath' 使用xpath =前缀。假设XPath。

正确:    
$ {}计数 获取匹配的Xpath计数 //android.view.View[@text='Test']
不正确:    
$ {}计数 获取匹配的Xpath计数 的xpath = // android.view.View [@文本= '测试']

若是您但愿断言匹配元素的数量,请使用Xpath应匹配X次

AppiumLibrary 1.4中的新功能。

获取网络链接状态  

返回指定网络链接类型的整数位掩码。

仅适用于Android。

有关详细信息,请参阅设置网络链接状态

获取来源  

返回当前页面的整个源。

获取文字 定位器

获取元素文本(对于混合和移动浏览器使用xpath定位器,其余可能会致使问题)

例:

$ {}文 获取文字 // * [含有(@文本, '富')]

AppiumLibrary 1.4中的新功能。

获得Webelement 定位器

返回第一个匹配的WebElement对象locator

例:

$ {}元素 获得Webelement ID = my_element
单击元素 $ {}元素  

AppiumLibrary 1.4中的新功能。

得到Webelements 定位器

返回匹配的WebElement对象列表locator

例:

@ {元素} 得到Webelements ID = my_element
单击元素 @ {元素} [2]  

此关键字在AppiumLibrary 1.4中如下列方式更改:

  • 名称从“ 获取元素”更改成当前元素
  • 不推荐使用的参数fail_on_error,若有必要,请使用“运行关键字”和“忽略错误”

AppiumLibrary 1.4中的新功能。

得到窗口高度  

获取当前设备高度。

例:

$ {}宽 得到窗口高度  
$ {height}的 得到窗口高度  
单击A Point $ {宽度 $ {height}的

AppiumLibrary 1.4.5中的新功能

获取窗口宽度  

获取当前设备宽度。

例:

$ {}宽 得到窗口高度  
$ {height}的 得到窗口高度  
单击A Point $ {宽度 $ {height}的

AppiumLibrary 1.4.5中的新功能

回去  

在浏览器历史记录中向后退一步。

转到网址 网址

在默认Web浏览器中打开URL。

例:

开放申请 HTTP://本地主机:4755 / WD /集线器 platformName = iOS的 platformVersion = 7.0 deviceName ='iPhone模拟器' browserName = Safari浏览器
转到URL http://m.webapp.com        
隐藏键盘 KEY_NAME =无

隐藏设备上的软件键盘。(可选)在iOS中,使用key_name按特定键,例如。完成。在Android中,不使用任何参数。

输入密码 定位器, 文本

将给定密码键入由locator标识的文本字段。

此关键字与输入文本之间的区别在于此关键字不会记录给定的密码。有关定位元素的详细信息,请参阅简介

输入文本 定位器, 文本

将给定文本键入由定位符标识的文本字段。

有关定位元素的详细信息,请参阅简介

输入值 定位器, 文本

将给定值设置为locator标识的文本字段。这是一个仅限IOS的关键字,输入值使用set_value

有关定位元素的详细信息,请参阅简介

安装应用程序 app_path, app_package

经过Appium安装App

仅适用于Android。

  • app_path - 应用程序的路径
  • app_package - 要验证的安装应用程序包
景观  

将设备方向设置为LANDSCAPE

启动程序  

启动程序。应用程序能够在Appium会话运行时启动。此关键字可用于在测试用例期间或测试用例之间启动应用程序。

Open Application运行测试时,此关键字有效。这是在测试用例之间启动应用程序退出应用程序的好习惯。因为Suite Setup是Open Application,所以可使用Test Setup 启动应用程序

示例(语法只是一种表示,请参阅RF指南以了解Setup / Teardown的用法):

[设置套件]          
  开放申请 HTTP://本地主机:4723 / WD /集线器 platformName = Android的 DEVICENAME = 192.168.56.101:5555 应用= $ {} CURDIR /demoapp/OrangeDemoApp.apk
[测试设置]          
  启动程序        
    <<< test execution >>>      
    <<< test execution >>>      
[测试拆解]          
  退出申请        
[套房拆解]          
  关闭申请        

请参阅退出应用程序退出应用程序但保持Appium sesion运行。

AppiumLibrary 1.4.6中的新功能

秒= 5

将设备锁定一段时间。仅适用于iOS。

日志源 记录等级= INFO

记录并返回当前页面或框架的整个html源。

日志级别参数定义所使用的日志级别。有效的日志级别为WARNINFO(默认),DEBUGTRACENONE(无日志记录)。

长按 定位器

长按元素

长按键码 keycode, metastate =无

向设备发送长按键代码。

仅适用于Android。

有关详细信息,请参阅按键代码

开放申请 remote_url, alias = None** kwargs

打开给定Appium服务器的新应用程序。appium服务器,Android和iOS的功能,请查看http://appium.io/slate/en/master/?python#appium-server-capabilities

选项 人。 描述
remote_url Appium服务器网址
别号 没有 别号

例子:

开放申请 HTTP://本地主机:4723 / WD /集线器 别名= Myapp1 platformName = iOS的 platformVersion = 7.0 deviceName ='iPhone模拟器' 应用程式= your.app  
开放申请 HTTP://本地主机:4723 / WD /集线器 platformName = Android的 platformVersion = 4.2.2 DEVICENAME = 192.168.56.101:5555 应用= $ {} CURDIR /demoapp/OrangeDemoApp.apk appPackage = com.netease.qa.orangedemo appActivity = MainActivity
页面应包含元素 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的位表示按下的元键。

例如

  • META_SHIFT_ON = 1
  • META_ALT_ON = 2
metastate = 1 - > Shift被按下 metastate = 2 - > Alt被按下 metastate = 3 - >按下Shift + Alt 
  • _keycode- - 要发送到设备的密钥代码
  • _metastate- - 元键的状态
拉文件 path, decode = False

路径中检索文件并返回其内容。

仅适用于Android。

  • path - 设备上文件的路径
  • decode - 在返回以前对数据(base64)进行True / False解码(默认= False)
拉文件夹 path, decode = False

检索路径中的文件夹。返回压缩文件夹的内容。

仅适用于Android。

  • path - 设备上文件夹的路径
  • decode - 在返回以前对数据(base64)进行True / False解码(默认= False)
推送文件 path, data, encode = False

将数据放在指定为path的文件中。

仅适用于Android。

  • path - 设备上的路径
  • data - 要写入文件的数据
  • encode - True / False在将数据写入文件以前将数据编码为base64(默认值= False)
退出申请  

退出申请。Appium会话保持活动状态时,应用程序能够退出。此关键字可用于在测试用例期间或测试用例之间关闭应用程序。

请参阅启动应用程序以获取解释

AppiumLibrary 1.4.6中的新功能

注册关键字以在失败时运行 关键词

设置关键字在AppiumLibrary关键字失败时执行。

keyword_name是在AppiumLibrary关键字失败时将执行的关键字(来自任何可用库)的名称。没法使用须要参数的关键字。使用值“Nothing”将彻底禁用此功能。

要使用的初始关键字是在导入中设置的,默认状况下使用的关键字是Capture Page Screenshot。在出现故障时拍摄屏幕截图是一个很是有用的功能,但请注意它能够减慢执行速度。

此关键字返回先前注册的失败关键字的名称。它能够用于之后恢复原始值。

例:

注册关键字以在失败时运行 日志源 #失败时运行Log Source  
$ {previous kw} = 注册关键字以在失败时运行 没有 #禁用run-on-failure功能并将之前的kw名称存储在变量中。
注册关键字以在失败时运行 $ {previous kw} #恢复到上一个​​关键字。  

这种运行失败功能仅在Python / Jython 2.4或更高版本上运行测试时才有效,并且根本不适用于IronPython。

删除申请 APPLICATION_ID

删除使用应用程序ID标识的应用程序

例:

删除申请 com.netease.qa.orangedemo
重置申请  

重置申请。Appium会话保持活动状态时,能够重置打开应用程序。

滚动 start_locator, end_locator

从一个元素滚动到另外一个元素任意元素的键属性是idname。有关定位元素的详细信息,请参阅简介

向下滚动 定位器

向下滚动到元素

向上滑动 定位器

向上滚动到元素

设置Appium超时

设置各类关键字使用的超时秒数。

有几个Wait ...关键字以超时做为参数。全部这些超时参数都是可选的。可使用此关键字全局设置全部这些超时使用的超时。

此关键字返回先前的超时值,可用于稍后设置旧值。默认超时为5秒,但能够在导入时更改。

例:

$ {orig timeout} = 设置Appium超时 15秒
打开加载缓慢的页面    
设置Appium超时 $ {orig timeout}  
设置网络链接状态 connectionStatus

设置网络链接状态。

仅适用于Android。

可能的值:

别号 数据 无线上网 飞行模式
0 (没有) 0 0 0
1 (飞行模式) 0 0 1
2 (仅限Wifi) 0 1 0
4 (仅限数据) 1 0 0
6 (全部网络上) 1 1 0
 

摇晃设备

开始活动 appPackage, appActivity**选择

在测试期间打开任意活动。若是活动属于另外一个应用程序,则启动该应用程序并打开活动。

仅适用于Android。

  • appPackage - 包含要启动的活动的包。
  • appActivity - 要开始的活动。
  • appWaitPackage - 此软件包启动后开始自动化(可选)。
  • appWaitActivity - 在此活动开始后开始自动化(可选)。
  • intentAction - 意图启动(opt_ional)。
  • intentCategory - 要启动的Intent类别(可选)。
  • intentFlags - 要发送到intent的标志(可选)。
  • optionalIntentArguments - intent的可选参数(可选)。
  • stopAppOnReset - 应用程序是否应在重置时中止(可选)?
刷卡 start_x, start_y, offset_xoffset_y, duration = 1000

可选持续时间从一个点滑动到另外一个点。

ARGS:

  • start_x - 要开始的x坐标
  • start_y - 要开始的y坐标
  • offset_x - 从start_x中止的x坐标距离
  • offset_y - 从start_y到中止的y坐标距离
  • 持续时间 - (可选)刷卡的时间,以毫秒为单位。

用法:

刷卡 500 100 100 0 1000

注意: Android'Swipe'没法正常工做,请使用offset_xoffset_y就像这些是目标点同样。

按百分比滑动 start_x, start_y, end_xend_y, duration = 1000

可选持续时间从屏幕的百分比滑动到另外一个百分比。普通滑动没法针对不一样的屏幕分辨率进行缩放,这可使用百分比来避免。

ARGS:

  • start_x - 开始时的x%
  • start_y - 开始时的y%
  • end_x - 从start_x到中止的x百分比距离
  • end_y - 从start_y到中止的y百分比距离
  • 持续时间 - (可选)刷卡的时间,以毫秒为单位。

用法:

按百分比滑动 90 50 10 50 #从右到左滑动屏幕。

注意:这也考虑了iOS和Android之间不一样的滑动行为。

AppiumLibrary 1.4.5中的新功能

切换应用 index_or_alias

按索引或别名切换活动应用程序。

index_or_alias是应用程序索引(整数)或别名(字符串)。获取索引做为Open Application的返回值。

此关键字返回上一个活动应用程序的索引,该索引可用于稍后切换回该应用程序。

例:

$ {} appium1 = 开放申请 HTTP://本地主机:4723 / WD /集线器 别名= MyApp1 platformName = iOS的 platformVersion = 7.0 deviceName ='iPhone模拟器' 应用程式= your.app
$ {} appium2 = 开放申请 HTTP://本地主机:4755 / WD /集线器 别名= MyApp2 platformName = iOS的 platformVersion = 7.0 deviceName ='iPhone模拟器' 应用程式= your.app
单击元素 sendHello #在运行localhost:4755的appium上执行          
切换应用 $ {} appium1 #使用索引切换          
单击元素 ackHello #在运行localhost:4723的appium上执行          
切换应用 MyApp2 #使用别名切换          
页面应包含文本 ackHello收到了 #在运行localhost:4755的appium上执行          
切换到上下文 CONTEXT_NAME

切换到新的上下文

龙头 locator, x_offset = Noney_offset = None, count = 1

点击标识的元素locator

ARGS:

  • x_offset - (可选)相对于元素左上角的x坐标。
  • y_offset - (可选)y坐标。若是使用y,则还必须设置x,反之亦然
  • count - 可用于屡次点击该元素
文字应该是可见的 text, exact_match = Falseloglevel = INFO

验证用文本标识的元素是否可见。

AppiumLibrary 1.4.5中的新功能

等待活动 活动, 超时, 间隔= 1

等待活动:阻止直到目标活动出现或超时。

仅适用于Android。

  • 活动 - 目标活动
  • 超时 - 最长等待时间,以秒为单位
  • interval - 重试之间的休眠间隔,以秒为单位
等到元素可见 locator, timeout =无, 错误=无

等待直到使用定位器指定的元素可见。

若是超时在元素可见以前到期,则失败。有关超时及其默认值的更多信息,请参阅简介

错误可用于覆盖默认错误消息。

另请参阅等待直到页面包含等待直到页面包含元素等待条件和BuiltIn关键字等待直到关键字成功

等到页面包含 text, timeout = Noneerror = None

等待文本出如今当前页面上。

若是超时在文本出现以前到期,则会失败。有关超时及其默认值的更多信息,请参阅简介

错误可用于覆盖默认错误消息。

另请参阅等待直到页面不包含等到页面包含元素等到页面不包含元素和BuiltIn关键字等待直到关键字成功

等到页面包含元素 locator, timeout =无, 错误=无

等待直到使用定位器指定的元素出如今当前页面上。

若是超时在元素出现以前到期,则失败。有关超时及其默认值的更多信息,请参阅简介

错误可用于覆盖默认错误消息。

另请参阅等待直到页面包含等到页面不包含 等待直到页面不包含元素和BuiltIn关键字等待直到关键字成功

等到页面不包含 text, timeout = Noneerror = None

等待文本从当前页面消失。

若是超时文本消失以前到期,则失败。有关超时及其默认值的更多信息,请参阅简介

错误可用于覆盖默认错误消息。

另请参阅等待页面包含等到页面包含元素等到页面不包含元素和BuiltIn关键字等待直到关键字成功

等到页面不包含元素 locator, timeout =无, 错误=无

等待直到使用定位器指定的元素从当前页面消失。

若是超时在元素消失以前到期,则失败。有关超时及其默认值的更多信息,请参阅简介

错误可用于覆盖默认错误消息。

另请参阅等待直到页面包含等到页面不包含等到页面包含元素和BuiltIn关键字等待直到关键字成功

Xpath应该匹配X次 xpath, count, error = None, loglevel = INFO

验证页面是否包含给定的给定数量的元素xpath

不该该为'xpath' 使用xpath =前缀。假设XPath。

正确:    
Xpath应该匹配X次 //android.view.View[@text='Test'] 1
不正确:    
Xpath应该匹配X次 的xpath = // android.view.View [@文本= '测试'] 1

error 可用于覆盖默认错误消息。

有关参数的说明,请参见日志源loglevel

AppiumLibrary 1.4中的新功能。

放大 locator, percent = 200%steps = 1

放大必定数量的元素。

共有85个关键字。 
Libdoc于2017-10-30 01:55:33 生成。

相关文章
相关标签/搜索