zoukankan      html  css  js  c++  java
  • appium常用关键字

    AppiumLibrary关键字记录

    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.

    将当前页面的截图存入日志。参数“文件名”指定截图的文件名。如果没有给出文件名` `,截图保存到文件` appium-screenshot-<counter>.png。截图将存放在robot日志文件的 PNG目录下。如果填写的文件名不是绝对路径格式,也被认为是同一个目录下的“文件名”。

     

    Clear Text

    实参:[ locator ]

    Clears the text field identified by `locator`.

    See `introduction` for details about locating elements.

    清除由“定位器”标识的文本字段。

    见介绍有关元素定位的细节。

     

     

    Click A Point

    Arguments:[ x=0 | y=0 ]

    Click on a point

     

     

     

    Click Button

    Arguments:[ index_or_name ]

    Click button

     

     

    Click Element

    Arguments:[ locator ]

    Click element identified by `locator`.

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

    点击“定位器”确定的元素。

    元素的主要是 `index`和名称属性。见介绍有关定位元素的细节。

     

     

     

    Close All Applications

    Arguments:[ ]

    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

    Arguments:[ ]

    Closes the current application. 关闭当前应用程序。

     

     

     

    Element Attribute Should Match 元素属性匹配

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

    验证元素的属性是否符合预期标准。

    元素是由定位器确定的。具体介绍见有关定位元素的细节。如果有多个元素匹配,则选择第一个元素。

    attr_name:是所选元素属性的名称。

    match_pattern :用于匹配,如果match_pattern是:

    boolean or 'True'/'true'/'False'/'false'字符串,然后布尔匹配应用任何用于匹配的字符串

     

    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

     

    AppiumLibrary关键字记录

    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.

    将当前页面的截图存入日志。参数“文件名”指定截图的文件名。如果没有给出文件名` `,截图保存到文件` appium-screenshot-<counter>.png。截图将存放在robot日志文件的 PNG目录下。如果填写的文件名不是绝对路径格式,也被认为是同一个目录下的“文件名”。

     

    Clear Text

    实参:[ locator ]

    Clears the text field identified by `locator`.

    See `introduction` for details about locating elements.

    清除由“定位器”标识的文本字段。

    见介绍有关元素定位的细节。

     

     

    Click A Point

    Arguments:[ x=0 | y=0 ]

    Click on a point

     

     

     

    Click Button

    Arguments:[ index_or_name ]

    Click button

     

     

    Click Element

    Arguments:[ locator ]

    Click element identified by `locator`.

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

    点击“定位器”确定的元素。

    元素的主要是 `index`和名称属性。见介绍有关定位元素的细节。

     

     

     

    Close All Applications

    Arguments:[ ]

    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

    Arguments:[ ]

    Closes the current application. 关闭当前应用程序。

     

     

     

    Element Attribute Should Match 元素属性匹配

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

    验证元素的属性是否符合预期标准。

    元素是由定位器确定的。具体介绍见有关定位元素的细节。如果有多个元素匹配,则选择第一个元素。

    attr_name:是所选元素属性的名称。

    match_pattern :用于匹配,如果match_pattern是:

    boolean or 'True'/'true'/'False'/'false'字符串,然后布尔匹配应用任何用于匹配的字符串

     

    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

    Arguments:[ locator | expected ]

     

     

     

     

    Element Should Be Disabled

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

    Arguments:[ 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 Value Should Be

    Arguments:[ locator | expected ]

     

     

     

    Get Appium Timeout

    Arguments:[ ]

    Gets the timeout in seconds that is used by various keywords.

    See `Set Appium Timeout` for an explanation.

     

     

     

    Get Contexts

    Arguments:

    [ ]

    Get available contexts.

    获得现有的环境。

    [u'NATIVE_APP'] 为 原生app

    u'WEBVIEW' 为 内嵌web页

     

     

    Get Current Context

    Arguments:[ ]

    Get current context.

    得到当前语境

     

     

     

     

    Get Element Attribute

    Arguments:

    [ locator | attribute ]

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

    使用给定元素的属性的属性获取:名称、值,…

    Examples:

    Get Element Attribute locator name

    Get Element Attribute locator value

     

     

     

     

    Get Element Location

    Arguments:[ locator ]

    Get element location

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

    任意元素的主要属性是 `id` and `name`。见介绍有关定位元素的细节。

     

     

    Get Element Size

    Arguments:[ locator ]

    Get element size

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

     

     

     

    Get Elements

    Arguments:[ locator | first_element_only=False | fail_on_error=True ]

    Return elements that match the search criteria

    The element is identified by locator. See `introduction` for details about locating elements.

    If the first_element is set to 'True' then only the first matching element is returned.

    If the fail_on_error is set to 'True' this keyword fails if the search return nothing.

    Returns a list of WebElement Objects.

     

     

     

    Get Network Connection Status

    Arguments:[ ]

    Returns an integer bitmask specifying the network connection type.

    Android only.

    See `set network connection status` for more details.

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

     

     

    Get Source

    Arguments:[ ]

    Returns the entire source of the current page.

    返回当前页面的全部来源。

     

     

    Go Back

    Arguments:

    [ ]

    Goes one step backward in the browser history.

    在浏览器历史上一步后退。相当于在当前状态后退一步,在当前页有键盘输入时,后退可以将键盘隐藏掉;

     

     

     

     

    Go To Url

    Arguments:

    [ url ]

    Opens URL in default web browser.

    给打开的浏览器录入给定URL,并打开页面

    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

    Arguments:

    [ 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

    Arguments:[ 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` 的区别在于,这个关键字不登录给定密码;???

     

    Input Text

    Arguments:

    [ locator | text ]

    Types the given `text` into text field identified by `locator`.

    将给定的文本值输入到定位器定位的文本框中;

     

     

     

    Input Value

    Arguments:

    [ 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

    将给定的文本值输入到定位器定位的文本框中;用于IOS

     

     

     

    Landscape

    Arguments:[ ]

    Set the device orientation to LANDSCAPE

     

     

    Lock

    Arguments:[ ]

    Lock the device

     

     

     

    Log Source

    Arguments:

    [ 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

    Arguments:

    [ locator ]

    Long press the element

    长按定位的元素对象

     

     

     

    Long Press Keycode

    Arguments:[ keycode | metastate=None ]

    Sends a long press of keycode to the device.

    Android only.

    See `press keycode` for more details.

     

     

     

    Open Application

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

    打开已安装的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

    将给定的app包上传到手机端,安装并启动app

     

     

     

     

     

     

     

    Page Should Contain Element

    Arguments:

    [ 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. Givin

    验证当前页面包含“定位器”定位到的元素。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

    Page Should Contain Text

    Arguments:

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

    验证当前页面包含“定位器”定位到的text。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

     

     

    Page Should Not Contain Element

    Arguments:

    [ 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. Givin

    验证当前页面不包含“定位器”定位到的元素。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

     

     

     

    Page Should Not Contain Text

    Arguments:

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

    验证当前页面不包含“定位器”定位到的Text

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

     

     

    Pinch

    Arguments:[ locator | percent=200% | steps=1 ]

    Pinch in on an element a certain amount.

    ??不好理解

     

     

    Portrait

    Arguments:[ ]

    Set the device orientation to PORTRAIT

    设置设备朝向肖像??

     

     

     

    Press Keycode

    Arguments:

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

    发送一个按键码的装置。安卓可用。

    找到可用的按键的meta states :http://developer.android.com/reference/android/view/keyevent.html

    元状态描述按下状态如Shift键Ctrl和Alt键的改性剂。的元状态是一个整数,其中每个位设置为1个代表一个按元键。

     

    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   

    拉出文件

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

    Arguments:[ 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)

     

     

    Register Keyword To Run On Failure

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

    Arguments:

    [ application_id ]

    Removes the application that is identified with an application id

    Example: Remove Application com.netease.qa.orangedemo

     

    移除Application

     

     

    Reset Application

    Arguments:[ ]

    Reset application

    应用重置:相当于卸载重装应用

     

     

    Scroll

    Arguments:[ 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.

    Scrolls从一个start_locator元素到另一个end_locator元素,通过“id”和“名字”属性定位的任意元素。

     

     

    Scroll To

    Arguments:[ locator ]

    Scrolls to element

    Scrolls从一个元素到另一个通过“id”和“名字”属性定位的任意元素。

     

    Set Appium Timeout

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

    Arguments:

    [ connectionStatus ]

    Sets the network connection Status.

    Android only.

     

     

     

    Shake

    实参:[ ]

    Shake the device

    摇动装置

     

     

     

    Swipe

    Arguments:[ start_x | start_y | end_x | end_y | duration=1000 ]

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

    在一个定义的时间段,从一个点滑动到另一个点。

     

     

     

    Switch Application

    Arguments:[ 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.

    打开多个app,然后根据定义的app变量切换各app,两个session 需要开启两个端口4755、4723

    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

    Arguments:[ context_name ]

    Switch to a new context

    切换到一个新的Context

    变更appweb视图Context

    WEBVIEW

     

     

    Tap

    Arguments:[ locator ]

    Tap on element

    轻点击元素

     

     

    Wait Until Page Contains

    Arguments:[ 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`.

    等待在当前页面上包含 text内容,在设置的timeout时间内未找到,会结束用例,并在log日志中,打印error定义的信息;

     

     

    Wait Until Page Contains Element

    Arguments:

    [ 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`.

    等待在当前页面上包含`locator`指定的元素,在设置的timeout时间内未找到,会结束用例,并在log日志中,打印error定义的信息;

    又见`等到网页包含`, `等到网页不包含` `等到网页不包含元素`和内置关键词`等到关键词成功`。

     

     

     

     

    Wait Until Page Does Not Contain

    Arguments:[ 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`.

    等待页面中不包含test,如果超时(timeout)仍然存在,则打印error信息;

     

     

     

    Wait Until Page Does Not Contain Element

    Arguments:

    [ 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`.

     

    等待页面中不包含 locator定位的元素存在,如果超时(timeout)仍然存在,则打印error信息;

     

     

    Zoom

    Arguments:

    [ locator | percent=200% | steps=1 ]

    Zooms in on an element a certain amount.

    在元素位置 缩小放大一定的数量。

     

    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

    Arguments:[ locator | expected ]

     

     

    Element Should Be Disabled

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

    Arguments:[ 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 Value Should Be

    Arguments:[ locator | expected ]

     

     

     

    Get Appium Timeout

    Arguments:[ ]

    Gets the timeout in seconds that is used by various keywords.

    See `Set Appium Timeout` for an explanation.

     

     

     

    Get Contexts

    Arguments:

    [ ]

    Get available contexts.

    获得现有的环境。

    [u'NATIVE_APP'] 为 原生app

    u'WEBVIEW' 为 内嵌web页

     

     

    Get Current Context

    Arguments:[ ]

    Get current context.

    得到当前语境

     

     

     

     

    Get Element Attribute

    Arguments:

    [ locator | attribute ]

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

    使用给定元素的属性的属性获取:名称、值,…

    Examples:

    Get Element Attribute locator name

    Get Element Attribute locator value

     

     

    Get Element Location

    Arguments:[ locator ]

    Get element location

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

    任意元素的主要属性是 `id` and `name`。见介绍有关定位元素的细节。

     

     

    Get Element Size

    Arguments:[ locator ]

    Get element size

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

     

     

    Get Elements

    Arguments:[ locator | first_element_only=False | fail_on_error=True ]

    Return elements that match the search criteria

    The element is identified by locator. See `introduction` for details about locating elements.

    If the first_element is set to 'True' then only the first matching element is returned.

    If the fail_on_error is set to 'True' this keyword fails if the search return nothing.

    Returns a list of WebElement Objects.

     

     

    Get Network Connection Status

    Arguments:[ ]

    Returns an integer bitmask specifying the network connection type.

    Android only.

    See `set network connection status` for more details.

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

     

     

    Get Source

    Arguments:[ ]

    Returns the entire source of the current page.

    返回当前页面的全部来源。

     

     

    Go Back

    Arguments:

    [ ]

    Goes one step backward in the browser history.

    在浏览器历史上一步后退。相当于在当前状态后退一步,在当前页有键盘输入时,后退可以将键盘隐藏掉;

     

     

     

    Go To Url

    Arguments:

    [ url ]

    Opens URL in default web browser.

    给打开的浏览器录入给定URL,并打开页面

    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

    Arguments:

    [ 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

    Arguments:[ 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` 的区别在于,这个关键字不登录给定密码;???

     

    Input Text

    Arguments:

    [ locator | text ]

    Types the given `text` into text field identified by `locator`.

    将给定的文本值输入到定位器定位的文本框中;

     

     

     

    Input Value

    Arguments:

    [ 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

    将给定的文本值输入到定位器定位的文本框中;用于IOS

     

     

     

    Landscape

    Arguments:[ ]

    Set the device orientation to LANDSCAPE

     

     

    Lock

    Arguments:[ ]

    Lock the device

     

     

     

    Log Source

    Arguments:

    [ 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

    Arguments:

    [ locator ]

    Long press the element

    长按定位的元素对象

     

     

     

    Long Press Keycode

    Arguments:[ keycode | metastate=None ]

    Sends a long press of keycode to the device.

    Android only.

    See `press keycode` for more details.

     

     

     

    Open Application

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

    打开已安装的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

    将给定的app包上传到手机端,安装并启动app

     

     

     

    Page Should Contain Element

    Arguments:

    [ 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. Givin

    验证当前页面包含“定位器”定位到的元素。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

    Page Should Contain Text

    Arguments:

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

    验证当前页面包含“定位器”定位到的text。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

    Page Should Not Contain Element

    Arguments:

    [ 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. Givin

    验证当前页面不包含“定位器”定位到的元素。

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

    Page Should Not Contain Text

    Arguments:

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

    验证当前页面不包含“定位器”定位到的Text

    如果这个关键字失败,它会自动使用指定的日志级别将日志输出到log页面 ,指定loglevel参数可选

     

     

     

    Pinch

    Arguments:[ locator | percent=200% | steps=1 ]

    Pinch in on an element a certain amount.

    ??不好理解

     

     

    Portrait

    Arguments:[ ]

    Set the device orientation to PORTRAIT

    设置设备朝向肖像??

     

     

     

    Press Keycode

    Arguments:

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

    发送一个按键码的装置。安卓可用。

    找到可用的按键的meta states :http://developer.android.com/reference/android/view/keyevent.html

    元状态描述按下状态如Shift键Ctrl和Alt键的改性剂。的元状态是一个整数,其中每个位设置为1个代表一个按元键。

     

    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   

    拉出文件

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

    Arguments:[ 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)

     

     

    Register Keyword To Run On Failure

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

    Arguments:

    [ application_id ]

    Removes the application that is identified with an application id

    Example: Remove Application com.netease.qa.orangedemo

     

    移除Application

     

     

    Reset Application

    Arguments:[ ]

    Reset application

    应用重置:相当于卸载重装应用

     

     

    Scroll

    Arguments:[ 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.

    Scrolls从一个start_locator元素到另一个end_locator元素,通过“id”和“名字”属性定位的任意元素。

     

     

    Scroll To

    Arguments:[ locator ]

    Scrolls to element

    Scrolls从一个元素到另一个通过“id”和“名字”属性定位的任意元素。

     

    Set Appium Timeout

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

    Arguments:

    [ connectionStatus ]

    Sets the network connection Status.

    Android only.

     

     

    Shake

    实参:[ ]

    Shake the device

    摇动装置

     

    Swipe

    Arguments:[ start_x | start_y | end_x | end_y | duration=1000 ]

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

    在一个定义的时间段,从一个点滑动到另一个点。

     

     

    Switch Application

    Arguments:[ 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.

    打开多个app,然后根据定义的app变量切换各app,两个session 需要开启两个端口4755、4723

    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

    Arguments:[ context_name ]

    Switch to a new context

    切换到一个新的Context

    变更appweb视图Context

    WEBVIEW

     

     

    Tap

    Arguments:[ locator ]

    Tap on element

    轻点击元素

     

     

    Wait Until Page Contains

    Arguments:[ 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`.

    等待在当前页面上包含 text内容,在设置的timeout时间内未找到,会结束用例,并在log日志中,打印error定义的信息;

     

     

     

    Wait Until Page Contains Element

    Arguments:

    [ 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`.

    等待在当前页面上包含`locator`指定的元素,在设置的timeout时间内未找到,会结束用例,并在log日志中,打印error定义的信息;

    又见`等到网页包含`, `等到网页不包含` `等到网页不包含元素`和内置关键词`等到关键词成功`。

     

     

    Wait Until Page Does Not Contain

    Arguments:[ 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`.

    等待页面中不包含test,如果超时(timeout)仍然存在,则打印error信息;

     

     

    Wait Until Page Does Not Contain Element

    Arguments:

    [ 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`.

     

    等待页面中不包含 locator定位的元素存在,如果超时(timeout)仍然存在,则打印error信息;

     

     

    Zoom

    Arguments:

    [ locator | percent=200% | steps=1 ]

    Zooms in on an element a certain amount.

    在元素位置 缩小放大一定的数量。

  • 相关阅读:
    redis命令
    eclipse error pages 打红X的解决方法
    探究adroid活动
    Javascript基本算法演练 Seek and Destroy
    c语言结构体排序示例
    android studio 环境配置
    git学习
    栈用于2进制转换10进制
    html和js
    js
  • 原文地址:https://www.cnblogs.com/yuchne/p/12920367.html
Copyright © 2011-2022 走看看