zoukankan      html  css  js  c++  java
  • AppiumLibrary

    Strategy Example Description
    identifier Click Element|identifier=my_element Matches by @id or @name attribute
    id Click Element|id=my_element Matches by @id attribute
    name Click Element|name=my_element Matches by @name attribute
    xpath Click Element|xpath=//UIATableView/UIATableCell/UIAButton Matches with arbitrary XPath
    class Click Element|class=UIAPickerWheel Matches by class
    accessibility_id Click Element|accessibility_id=t Accessibility options utilize.
    android Click Element|android=new 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

    Keywords

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

    filenameargument specifies the name of the file to write the screenshot into. If nofilenameis given, the screenshot is saved into fileappium-screenshot-<counter>.pngunder the directory where the Robot Framework log file is written into. Thefilenameis also considered relative to the same directory, if it is not given in absolute format.

    csscan 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 bylocator.

    Seeintroductionfor details about locating elements.

    Click Button index_or_name

    Click button

    Click Element locator

    Click element identified bylocator.

    Key attributes for arbitrary elements areindexandname. Seeintroductionfor details about locating elements.

    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 byOpen Applicationare reset and start from1.

    Close Application  

    Closes the current application.

    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 areidandname. Seeintroductionfor details about locating elements.

    Element Should Be Enabled locator,loglevel=INFO

    Verifies that element identified with locator is enabled.

    Key attributes for arbitrary elements areidandname. Seeintroductionfor details about locating elements.

    Get Contexts  

    Get available contexts.

    Get Current Context  

    Get current context.

    Get Network Connection Status  

    Returns an integer bitmask specifying the network connection type. Android only. Seeset network connection statusfor more details.

    Get Source  

    Returns the entire source of the current page.

    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  

    Hides the software keyboard on the device, using the specified key to press. If no key name is given, the keyboard is closed by moving focus from the text field. iOS only.

    Input Password locator,text

    Types the given password into text field identified bylocator.

    Difference between this keyword andInput Textis that this keyword does not log the given password. Seeintroductionfor details about locating elements.

    Input Text locator,text

    Types the giventextinto text field identified bylocator.

    Seeintroductionfor details about locating elements.

    Input Value locator,text

    Sets the given value into text field identified bylocator. This is an IOS only keyword, input value makes use of set_value

    Seeintroductionfor details about locating elements.

    Lock  

    Lock the device

    Log Source loglevel=INFO

    Logs and returns the entire html source of the current page or frame.

    Theloglevelargument defines the used log level. Valid log levels areWARN,INFO(default),DEBUG,TRACEandNONE(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. Seepress keycodefor 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 checkhttp://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 containslocatorelement.

    If this keyword fails, it automatically logs the page source using the log level specified with the optionalloglevelargument. Givin

    Page Should Contain Text text,loglevel=INFO

    Verifies that current page containstext.

    If this keyword fails, it automatically logs the page source using the log level specified with the optionalloglevelargument. GivingNONEas level disables logging.

    Page Should Not Contain Element locator,loglevel=INFO

    Verifies that current page not containslocatorelement.

    If this keyword fails, it automatically logs the page source using the log level specified with the optionalloglevelargument. Givin

    Page Should Not Contain Text text,loglevel=INFO

    Verifies that current page not containstext.

    If this keyword fails, it automatically logs the page source using the log level specified with the optionalloglevelargument. GivingNONEas level disables logging.

    Pinch locator,percent=200%,steps=1

    Pinch in on an element a certain amount.

    Press Keycode keycode,metastate=None

    Sends a press of keycode to the device. Android only. Possible keycodes & meta states can be found inhttp://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

    :Args:

    • keycode - the keycode to be sent to the device
    • metastate - status of the meta keys
    Pull File path,decode=False

    Retrieves the file atpathand return it's content. Android only.

    :Args:

    • 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 atpath. Returns the folder's contents zipped. Android only.

    :Args:

    • 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 aspath. Android only.

    :Args:

    • 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)
    Register Keyword To Run On Failure keyword

    Sets the keyword to execute when a AppiumLibrary keyword fails.

    keyword_nameis 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 inimporting, and the keyword that is used by default isCapture 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 # RunLog Sourceon 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

    Scroll start_locator,end_locator

    Scrolls from one element to another Key attributes for arbitrary elements areidandname. Seeintroductionfor details about locating elements.

    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

    Swipe start_x,start_y,end_x,end_y,duration=1000

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

    Switch Application index_or_alias

    Switches the active application by index or alias.

    index_or_aliasis either application index (an integer) or alias (a string). Index is got as the return value ofOpen 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

    Tap on element

    Wait Until Page Contains text,timeout=None,error=None

    Waits untiltextappears on current page.

    Fails iftimeoutexpires before the text appears. Seeintroductionfor more information abouttimeoutand its default value.

    errorcan be used to override the default error message.

    See alsoWait Until Page Does Not Contain,Wait Until Page Contains Element,Wait Until Page Does Not Contain Elementand BuiltIn keywordWait Until Keyword Succeeds.

    Wait Until Page Contains Element locator,timeout=None,error=None

    Waits until element specified withlocatorappears on current page.

    Fails iftimeoutexpires before the element appears. Seeintroductionfor more information abouttimeoutand its default value.

    errorcan be used to override the default error message.

    See alsoWait Until Page Contains,Wait Until Page Does Not ContainWait Until Page Does Not Contain Elementand BuiltIn keywordWait Until Keyword Succeeds.

    Wait Until Page Does Not Contain text,timeout=None,error=None

    Waits untiltextdisappears from current page.

    Fails iftimeoutexpires before thetextdisappears. Seeintroductionfor more information abouttimeoutand its default value.

    errorcan be used to override the default error message.

    See alsoWait Until Page Contains,Wait Until Page Contains Element,Wait Until Page Does Not Contain Elementand BuiltIn keywordWait Until Keyword Succeeds.

    Wait Until Page Does Not Contain Element locator,timeout=None,error=None

    Waits until element specified withlocatordisappears from current page.

    Fails iftimeoutexpires before the element disappears. Seeintroductionfor more information abouttimeoutand its default value.

    errorcan be used to override the default error message.

    See alsoWait Until Page Contains,Wait Until Page Does Not Contain,Wait Until Page Contains Elementand BuiltIn keywordWait Until Keyword Succeeds.

    Zoom locator,percent=200%,steps=1

    Zooms in on an element a certain amount.

  • 相关阅读:
    网站建设怎样添加设为首页和加入收藏代码
    在WEB项目中调用QQ通讯组件打开QQ聊天界面
    网页引用Font Awesome图标
    jQuery鼠标划入划出
    django框架
    python连接数据库:
    数据库:
    TCP:
    数据库:
    Excel在任务栏中只显示一个窗口的解决办法
  • 原文地址:https://www.cnblogs.com/chenjingyi/p/5881583.html
Copyright © 2011-2022 走看看