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.

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.

Using locators

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

Click Element    id=my_element

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

For example:

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

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

StrategyExampleDescriptionNote
identifierClick Element | identifier=my_elementMatches by @id attribute 
idClick Element | id=my_elementMatches by @resource-id attribute 
accessibility_idClick Element | accessibility_id=button3Accessibility options utilize. 
xpathClick Element | xpath=//UIATableView/UIATableCell/UIAButtonMatches with arbitrary XPath 
classClick Element | class=UIAPickerWheelMatches by class 
androidClick Element | android=UiSelector().description('Apps')Matches by Android UI Automator 
iosClick Element | ios=.buttons().withName('Apps')Matches by iOS UI Automation 
cssClick Element | css=.green_buttonMatches by css in webview 
nameClick Element | name=my_elementMatches by @name attributeOnly valid for Selendroid

Using webelements

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

For example:

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

Importing

ArgumentsDocumentation
timeout=5, run_on_failure=Capture Page Screenshot

AppiumLibrary can be imported with optional arguments.

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

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

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

Examples:

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

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

KeywordArgumentsDocumentation
Background Appseconds=5

Puts the application in the background on the device for a certain duration.

Capture Page Screenshotfilename=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 Textlocator

Clears the text field identified by locator.

See introduction for details about locating elements.

Click A Pointx=0, y=0,duration=100

Click on a point

Click Buttonindex_or_name

Click button

Click Elementlocator

Click element identified by locator.

Key attributes for arbitrary elements are index and name. See introduction for details about locating elements.

Click Element At Coordinatescoordinate_X,coordinate_Y

click element at a certain coordinate

Click Texttext,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 Matchlocator, 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 Matchxpath = //*[contains(@text,'foo')]text*foobar 
Element Attribute Should Matchxpath = //*[contains(@text,'foo')]textf.*arregexp = True
Element Attribute Should Matchxpath = //*[contains(@text,'foo')]enabledTrue 
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 Matchxpath = //*[contains(@text,'example text')]nametxt_field_name
Element Name Should Bexpath = //*[contains(@text,'example text')]txt_field_name 
Element Name Should Belocator, expected 
Element Should Be Disabledlocator,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 Enabledlocator,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 Visiblelocator,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 Textlocator, 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 Textlocator, 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 Belocator, 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 Belocator, 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 Capabilitycapability_name

Return the desired capability value by desired capability name

Get Contexts 

Get available contexts.

Get Current Context 

Get current context.

Get Element Attributelocator, attribute

Get element attribute using given attribute: name, value,...

Examples:

Get Element Attributelocatorname
Get Element Attributelocatorvalue
Get Element Locationlocator

Get element location

Key attributes for arbitrary elements are id and name. See introduction for details about locating elements.

Get Element Sizelocator

Get element size

Key attributes for arbitrary elements are id and name. See introduction for details about locating elements.

Get Matching Xpath Countxpath

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 Countxpath=//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 Textlocator

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 Webelementlocator

Returns the first WebElement object matching locator.

Example:

${element}Get Webelementid=my_element
Click Element${element} 

New in AppiumLibrary 1.4.

Get Webelementslocator

Returns list of WebElement objects matching locator.

Example:

@{elements}Get Webelementsid=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 Urlurl

Opens URL in default web browser.

Example:

Open Applicationhttp://localhost:4755/wd/hubplatformName=iOSplatformVersion=7.0deviceName='iPhone Simulator'browserName=Safari
Go To URLhttp://m.webapp.com    
Hide Keyboardkey_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 Passwordlocator, 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 Textlocator, text

Types the given text into text field identified by locator.

See introduction for details about locating elements.

Input Valuelocator, 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 Appapp_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 Applicationhttp://localhost:4723/wd/hubplatformName=AndroiddeviceName=192.168.56.101:5555app=${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

Lockseconds=5

Lock the device for a certain period of time. iOS only.

Log Sourceloglevel=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 Presslocator

Long press the element

Long Press Keycodekeycode,metastate=None

Sends a long press of keycode to the device.

Android only.

See press keycode for more details.

Open Applicationremote_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

OptionMan.Description
remote_urlYesAppium server url
aliasnoalias

Examples:

Open Applicationhttp://localhost:4723/wd/hubalias=Myapp1platformName=iOSplatformVersion=7.0deviceName='iPhone Simulator'app=your.app 
Open Applicationhttp://localhost:4723/wd/hubplatformName=AndroidplatformVersion=4.2.2deviceName=192.168.56.101:5555app=${CURDIR}/demoapp/OrangeDemoApp.apkappPackage=com.netease.qa.orangedemoappActivity=MainActivity
Page Should Contain Elementlocator,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 Texttext,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 Elementlocator,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 Texttext,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.

Pinchlocator,percent=200%,steps=1

Pinch in on an element a certain amount.

Portrait 

Set the device orientation to PORTRAIT

Press Keycodekeycode,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 Filepath,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 Folderpath,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 Filepath, 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 Failurekeyword

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 FailureLog Source# Run Log Source on failure. 
${previous kw}=Register Keyword To Run On FailureNothing# 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 Applicationapplication_id

Removes the application that is identified with an application id

Example:

Remove Applicationcom.netease.qa.orangedemo
Reset Application 

Reset application. Open Application can be reset while Appium session is kept alive.

Scrollstart_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 Downlocator

Scrolls down to element

Scroll Uplocator

Scrolls up to element

Set Appium Timeoutseconds

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 Timeout15 seconds
Open page that loads slowly  
Set Appium Timeout${orig timeout} 
Set Network Connection StatusconnectionStatus

Sets the network connection Status.

Android only.

Possible values:

ValueAliasDataWifiAirplane Mode
0(None)000
1(Airplane Mode)001
2(Wifi only)010
4(Data only)100
6(All network on)110
Shake 

Shake the device

Start ActivityappPackage,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)?
Swipestart_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:

Swipe50010010001000

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

Swipe By Percentstart_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 Percent90501050# Swipes screen from right to left.

NOTE: This also considers swipe acts different between iOS and Android.

New in AppiumLibrary 1.4.5

Switch Applicationindex_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 Applicationhttp://localhost:4723/wd/hubalias=MyApp1platformName=iOSplatformVersion=7.0deviceName='iPhone Simulator'app=your.app
${appium2}=Open Applicationhttp://localhost:4755/wd/hubalias=MyApp2platformName=iOSplatformVersion=7.0deviceName='iPhone Simulator'app=your.app
Click ElementsendHello# Executed on appium running at localhost:4755     
Switch Application${appium1}# Switch using index     
Click ElementackHello# Executed on appium running at localhost:4723     
Switch ApplicationMyApp2# Switch using alias     
Page Should Contain TextackHello Received# Executed on appium running at localhost:4755     
Switch To Contextcontext_name

Switch to a new context

Taplocator,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 Visibletext,exact_match=False,loglevel=INFO

Verifies that element identified with text is visible.

New in AppiumLibrary 1.4.5

Wait Activityactivity, 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 Visiblelocator,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 Containstext,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 Elementlocator,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 Containtext,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 Elementlocator,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 Timesxpath, 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 Timesxpath=//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.

Zoomlocator,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值将完全禁用此功能。有关此功能的更多信息,请参阅注册关键字以运行失败关键字。

例子:

图书馆AppiumLibrary10#将默认超时设置为10秒 
图书馆AppiumLibrary超时= 10run_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 Pointx = 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

例:

$ {}元素得到WebelementID = my_element
单击元素$ {}元素 

AppiumLibrary 1.4中的新功能。

获得Webelements定位器

返回匹配的WebElement对象列表locator

例:

@ {元素}获得WebelementsID = 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.0deviceName ='iPhone模拟器'browserName = Safari浏览器
转到URLhttp://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_urlAppium服务器网址
别号没有别号

例子:

开放申请HTTP://本地主机:4723 / WD /集线器别名= Myapp1platformName = iOS的platformVersion = 7.0deviceName ='iPhone模拟器'应用程式= your.app 
开放申请HTTP://本地主机:4723 / WD /集线器platformName = Android的platformVersion = 4.2.2DEVICENAME = 192.168.56.101:5555应用= $ {} CURDIR /demoapp/OrangeDemoApp.apkappPackage = com.netease.qa.orangedemoappActivity = 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(没有)000
1(飞行模式)001
2(仅限Wifi)010
4(仅限数据)100
6(所有网络上)110
 

摇晃设备

开始活动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坐标距离
  • 持续时间 - (可选)刷卡的时间,以毫秒为单位。

用法:

刷卡50010010001000

注意: 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百分比距离
  • 持续时间 - (可选)刷卡的时间,以毫秒为单位。

用法:

按百分比滑动90501050#从右到左滑动屏幕。

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

AppiumLibrary 1.4.5中的新功能

切换应用index_or_alias

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

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

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

例:

$ {} appium1 =开放申请HTTP://本地主机:4723 / WD /集线器别名= MyApp1platformName = iOS的platformVersion = 7.0deviceName ='iPhone模拟器'应用程式= your.app
$ {} appium2 =开放申请HTTP://本地主机:4755 / WD /集线器别名= MyApp2platformName = iOS的platformVersion = 7.0deviceName ='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 生成。

 

                                    </div>
                                        </div>

转载于:https://my.oschina.net/u/3447023/blog/1927857

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值