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
| Keyword | Arguments | Documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Background App | seconds=5 |
Puts the application in the background on the device for a certain duration. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Capture Page Screenshot | filename=None |
Takes a screenshot of the current page and embeds it into the log. 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:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Examples:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pull File | path,decode=False |
Retrieves the file atpathand return it's content. Android only. :Args:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pull Folder | path,decode=False |
Retrieves a folder atpath. Returns the folder's contents zipped. Android only. :Args:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Push File | path,data,encode=False |
Puts the data in the file specified aspath. Android only. :Args:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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:
This run-on-failure functionality only works when running tests on Python/Jython 2.4 or newer and it does not work on IronPython at all. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove Application | application_id |
Removes the application that is identified with an application id Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reset Application |
Reset application |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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. |
Altogether 49 keywords.
AppiumLibrary的更多相关文章
- (转)AppiumLibrary基本操作
*** Settings *** Library AppiumLibrary Library Collections Library String Library Dialogs *** Test C ...
- Appium+Robotframework实现Android应用的自动化测试-4:AppiumLibrary介绍和安装
Appium是个好东东,Android,iOS都支持,并且居然RobotFramework也支持Appium了,这就是本文要介绍的AppiumLibrary. 通过前面的文章大家知道可以使用多种语言来 ...
- Appium+Robotframework实现Android应用的自动化测试-5:RIDE中AppiumLibrary的配置
可能很多朋友已经迫不及待的想要用RobotFramework+AppiumLibrary来写Android App的测试脚本了,那我们也废话少说,直接开始. 首先打开RIDE,这是编写RobotFra ...
- RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary介绍
在使用AppiumLibrary库时,需要预先安装好Appium自动化工具,Appium官网地址为:http://appium.io/ Appium的GitHub地址为:https://github. ...
- AppiumLibrary常用关键字
通过上一章节,open application关键字的使用,相信大家对手机自动化充满了兴趣,那么今天这一章节,主要介绍AppiumLibrary中常用关键字的使用. 一.实用函数 关键字 含义 实例 ...
- RobotFramework - AppiumLibrary 之元素定位
一.介绍 AppiumLibrary 是 Robot Framework 的App测试库. 它使用Appium 与Android 和 iOS应用程序进行通信,类似于Selenium WebDriver ...
- 导入appiumlibrary显红
1.点击ride中的Tools的View RIDE Log 2.打开日志报如下错误,提示没有six这个模块,可能是最新包的要对python版本兼容 3.所以使用pip install six安装包后 ...
- RobotFramework AppiumLibrary 用户关键字
RobotFramework AppiumLibrary 用户关键字 最近在用robotframework搞安卓app 的自动化,其中用到了 AppiumLlibrary 的关键字,我都映射成了用户关 ...
- 导入AppiumLibrary报错: ImportError: cannot import name 'InvalidArgumentException
导入AppiumLibrary报错: ImportError: cannot import name 'InvalidArgumentException报错原因 selenium.common.exc ...
随机推荐
- php提取背景图片
preg_match_all('/background\s*-\s*+image\s*:\s*url\s*\("*([^"]*)"*\)/i', $content,$ma ...
- 股票API
实时股票数据接口大全 股票数据的获取目前有如下两种方法可以获取:1. http/javascript接口取数据2. web-service接口 1.http/javascript接口取数据 1.1Si ...
- C语言头文件书写
说一下C语言的存储类说明符: 1.Auto 只在块内变量声明中被允许,表示变量具有本地生存期. 2.Extern 出现在顶层或块的外部变量函数与变量声明中,表示声明的对象具有静态生存 ...
- Entity Framework Code First 数据迁移
需要在[工具 --> NuGet 程序包管理器 --> 程序包管理器控制台]中输入三个命令: Enable-Migrations (初次迁移时使用) Add-Migration [为本次迁 ...
- C#中通过调用Dll函数时,执行一段时间后,就会报内存可能被破坏的错的解决办法
遇到同样的问题,已经解决的:http://blog.csdn.net/youxiazzz12/article/details/24313347
- Android学习之Image操作及时间日期选择器
一.基础学习 1.ImageView是图片容器,就相当于RadioGroup是RadioButton的容器一样,是View的直接子类. 1: <ImageView 2: android:id=& ...
- poj 1284 Primitive Roots
从来没有接触过完全剩余系,不会证明,知道看了别人的题解才知道要用欧拉函数: 下面是证明过程: p是奇素数,如果{xi%p | 1 <= i <= p - 1} = {1,2,...,p-1 ...
- csu 10月 月赛 H 题 A Very Hard Problem
Description CX老湿经常被人黑,被黑得多了,自己也就麻木了.于是经常听到有人黑他,他都会深情地说一句:禽兽啊! 一天CX老湿突发奇想,给大家出了一个难题,并且声称谁能够准确地回答出问题才能 ...
- Android 获取系统短信内容
//这里通过内容提供者获取系统短信内容 Uri uri = Uri.parse("content://sms/"); String[] projection = {"_i ...
- ANDROID_MARS学习笔记_S04_006_用获取access_token,access_token_secrect
一.代码流程 1.MainActivity会开启PrepareRequestTokenActivity 2.PrepareRequestTokenActivity会根据配置文件的CONSUMER_KE ...