1. *** Settings ***
  2. Library AppiumLibrary
  3. Library AutoItLibrary
  4. Library os
  5.  
  6. *** Keywords ***
  7. xpath应该匹配次数
  8. [Arguments] ${xpath} ${count}
  9. Xpath Should Match X Times ${xpath} ${count}
  10.  
  11. 上传文件
  12. [Arguments] ${path} ${data} ${encode}=base64
  13. Push File ${path} ${data} ${encode}
  14.  
  15. 元素不应该包含文本
  16. [Arguments] ${locator} ${expected} ${msg}=
  17. Element Should not Contain Text ${locator} ${expected} ${msg}
  18.  
  19. 元素值应该是
  20. [Arguments] ${locator} ${expected}
  21. Element Value Should Be ${locator} ${expected}
  22.  
  23. 元素名应该是
  24. [Arguments] ${path} ${name}
  25. Element Name Should Be ${path} ${name}
  26.  
  27. 元素属性应该匹配
  28. [Arguments] ${locator} ${attr_name} ${match_pattern} ${regx}=False
  29. Element Attribute Should Match ${locator} ${attr_name} ${match_pattern} ${regx}
  30.  
  31. 元素应该包含文本
  32. [Arguments] ${locator} ${expected} ${msg}=None
  33. Element Should Contain Text ${locator} ${expected} ${msg}
  34.  
  35. 元素应该失效
  36. [Arguments] ${locator} ${level}=INFO
  37. Element should be disabled ${locator} ${level}
  38.  
  39. 元素应该有效
  40. [Arguments] ${locator} ${level}=INFO
  41. Element should be enabled ${locator} ${level}
  42.  
  43. 元素文本应该是
  44. [Arguments] ${locator} ${expected} ${msg}=None
  45. Element Text Should Be ${locator} ${expected} ${msg}
  46.  
  47. 关闭当前应用
  48. Close Application
  49.  
  50. 关闭所有应用
  51. Close All Applications
  52.  
  53. 切换应用
  54. [Arguments] ${index_or_alias}
  55. Switch Application ${index_or_alias}
  56.  
  57. 切换页面内容
  58. [Arguments] ${webview}
  59. Switch To Context ${webview}
  60.  
  61. 卸载应用
  62. [Arguments] ${application_id}
  63. Remove Application ${application_id}
  64.  
  65. 后台运行
  66. [Arguments] ${sec}
  67. Background App ${sec}
  68.  
  69. 向上滚动
  70. [Arguments] ${locator}
  71. Scroll Up ${locator}
  72.  
  73. 向下滚动
  74. [Arguments] ${locator}
  75. Scroll Down ${locator}
  76.  
  77. 失败后运行关键字
  78. [Arguments] ${keyword}
  79. [Documentation] Example: # Disables run-on-failure functionality and stores the previous kw name in a variable. # Restore to the previous keyword.
  80. ...
  81. ... Register Keyword To Run On Failure \ \ \ Log Source
  82. ... \ \ \ \ \ \ \ # Run `Log Source` on failure.
  83. ...
  84. ... ${previous kw}=
  85. ... Register Keyword To Run On Failure \ \ Nothing
  86. ...
  87. ...
  88. ... Register Keyword To Run On Failure \ \ \ \ ${previous kw} \ \ \ \
  89. Register Keyword To Run On Failure ${keyword}
  90.  
  91. 打印资源
  92. [Arguments] ${level}
  93. Log Source ${level}
  94.  
  95. 打开URL
  96. [Arguments] ${url}
  97. [Documentation] Example:
  98. ...
  99. ... 打开应用
  100. ... http://localhost:4755/wd/hub \ platformName=iOS \ platformVersion=7.0
  101. ... deviceName='iPhone Simulator'
  102. ... browserName=Safari
  103. ...
  104. ... 打开URL \ http://m.webapp.com
  105. Go To URL ${url}
  106.  
  107. 打开应用
  108. [Arguments] ${url} ${platformName} ${version} ${deviceName} ${app}
  109. [Documentation] 打开应用 ${url} ${platformName} ${version} \ \ ${devicename} ${app} @{args}
  110. ...
  111. ... 例如:
  112. ...
  113. ... 打开应用 http://localhost:4723/wd/hub Android 5.1.1 5e25d20d ${CURDIR}${/}app${/}fft.apk
  114. ...
  115. ... ${url} 是用于访问应用的地址,一般是固定的。 url 端口可以根据具体地址修改。
  116. ... ${version} \ 是安卓的版本
  117. ... ${devicename} 是手机的UDID, 可以打开cmd 然后用 adb devices -l \ 看到设备列表。
  118. ... UDID 是看到的第一列的内容,真机是一串字符串,模拟器是 \ ip:port \ 的形式
  119. ... ${app} apk 存放的路径 ${CURDIR} 系统变量,取得当前脚本路径。 ${/} 系统变量 '/'
  120. open application ${url} platformName=${platformName} platformVersion=${version} deviceName=${deviceName} app=${app}
  121.  
  122. 按关键字
  123. [Arguments] ${keycode} ${metastate}=None
  124. Press Keycode ${keycode} ${metastate}
  125.  
  126. 摇动手机
  127. Shake
  128.  
  129. 放大元素
  130. [Arguments] ${locator} ${percent}=200% ${step}=1
  131. Zoom ${locator} ${percent} ${step}
  132.  
  133. 敲击元素
  134. [Arguments] ${locator}
  135. Tap ${locator}
  136.  
  137. 横屏
  138. [Documentation] 手机设置横屏
  139. LANDSCAPE
  140.  
  141. 清除文本
  142. [Arguments] ${locator}
  143. Clear Text ${locator}
  144.  
  145. 滑动
  146. [Arguments] ${start_x} ${start_y} ${end_x} ${end_y}
  147. swipe ${start_x} ${start_y} ${end_x} ${end_y}
  148.  
  149. 滚动
  150. [Arguments] ${start_locator} ${end_locator}
  151. [Documentation] 从一个元素滚动到另一个元素
  152. Scroll ${start_locator} ${end_locator}
  153.  
  154. 点击元素
  155. [Arguments] ${locator}
  156. Click Element ${locator}
  157.  
  158. 点击元素坐标
  159. [Arguments] ${coordinate_x} ${coordinate_y}
  160. Click Element At Coordinates ${coordinate_x} ${coordinate_y}
  161.  
  162. 点击固定点
  163. [Arguments] ${x} ${y} @{args}
  164. Click A Point ${x} ${y} @{args}
  165.  
  166. 点击按钮
  167. [Arguments] ${index_or_name}
  168. Click Button ${index_or_name}
  169.  
  170. 点击文本
  171. [Arguments] ${text} ${exact_match}=false
  172. [Documentation] 点击匹配到文本的元素:
  173. ...
  174. ... 点击文本 "text"
  175. ... 点击文本 "text" True
  176. ...
  177. ... 默认模糊匹配所有元素,可以设置成精确匹配。
  178. ... 如果可以匹配到两个或两个以上的元素,那么需要用 click Element 元素,去处理。
  179. Click Text ${text} ${exact_match}
  180.  
  181. 睡眠
  182. [Arguments] ${sec}
  183. sleep ${sec}
  184.  
  185. 竖屏
  186. PORTRAIT
  187.  
  188. 等待页面元素出现
  189. [Arguments] ${locator} ${timeout}=100 ${err}=None
  190. Wait Until Page Contains Element ${locator} ${timeout} ${err}
  191.  
  192. 等待元素出现文本
  193. [Arguments] ${text} ${timeout}=10 ${err}=None
  194. Wait Until Page Contains ${text} ${timeout} ${err}
  195.  
  196. 等待页面不包含元素
  197. [Arguments] ${locator} ${timeout}=10 ${err}=None
  198. Wait Until Page Does Not Contain Element ${locator} ${timeout} ${err}
  199.  
  200. 等待页面不包含文本
  201. [Arguments] ${text} ${timeout}=10 ${err}=None
  202. Wait Until Page Does Not Contain ${text} ${timeout} ${err}
  203.  
  204. 缩小元素
  205. [Arguments] ${locator} ${percent}=200% ${step}=1
  206. Pinch ${locator} ${percent} ${step}
  207.  
  208. 获取Appium超时时间
  209. ${timeout} Get Appium Timeout
  210. [Return] ${timeout}
  211.  
  212. 获取Web元素
  213. [Arguments] ${locator}
  214. [Documentation] 获取匹配的定位器的第一个元素:
  215. ...
  216. ... ${element} 获取Web元素 id=name
  217. ... 点击元素 ${element}
  218. ${element} Get Webelement ${locator}
  219. [Return] ${element}
  220.  
  221. 获取元素坐标
  222. [Arguments] ${locator}
  223. ${location} Get Element Location ${locator}
  224. [Return] ${location}
  225.  
  226. 获取元素尺寸
  227. [Arguments] ${locator}
  228. ${size} Get Element Size ${locator}
  229. [Return] ${size}
  230.  
  231. 获取元素属性
  232. [Arguments] ${locator} ${name_or_value}
  233. [Documentation] 获取元素属性:(name 或者 value)
  234. ... ${val} \ 获取元素属性 ${locator} ${name_or_value}
  235. ...
  236. ... 例如:
  237. ... ${val} 获取元素属性 id=xxxx name
  238. ... ${val} 获取元素属性 id=xxxx value
  239. ${val} Get Element Attribute ${locator} ${name_or_value}
  240. [Return] ${val}
  241.  
  242. 获取匹配xpath数
  243. [Arguments] ${xpath}
  244. [Documentation] 例如:
  245. ...
  246. ... ${count} \ \ \ 获取匹配xpath数 \ \ //android.view.View[@text='Test']
  247. ${count} Get Matching Xpath Count ${xpath}
  248. [Return] ${count}
  249.  
  250. 获取可见文本
  251. ${contents} Get Contexts
  252. [Return] ${contents}
  253.  
  254. 获取当前文本
  255. ${context} Get Current Context
  256. [Return] ${context}
  257.  
  258. 获取所有web元素
  259. [Arguments] ${locator}
  260. [Documentation] @{element} 获取所有web元素 id=my_element
  261. ... 点击元素 @{element}[2]
  262. @{element} Get Webelements ${locator}
  263. [Return] @{element}
  264.  
  265. 获取文件
  266. [Arguments] ${file_path} ${decode}=False
  267. pull file ${file_path} ${decode}
  268.  
  269. 获取文件夹
  270. [Arguments] ${folder_path} ${decode}=False
  271. Pull Folder ${folder_path} ${decode}
  272.  
  273. 获取文本
  274. [Arguments] ${locator}
  275. [Documentation] 获取符合元素的文本:
  276. ... ${text} \ 获取文本 \ //*[contains(@text,'foo')]
  277. ${text} Get Text ${locator}
  278. [Return] ${text}
  279.  
  280. 获取网络连接情况
  281. ${stat} Get Network Connection Status
  282. [Return] ${stat}
  283.  
  284. 获取资源
  285. ${source} Get Source
  286. [Return] ${source}
  287.  
  288. 设置Appium超时
  289. [Arguments] ${sec}
  290. Set Appium Timeout ${sec}
  291.  
  292. 设置网络连接状态
  293. [Arguments] ${sec}
  294. Set Network Connection Status ${sec}
  295.  
  296. 输入值
  297. [Arguments] ${locator} ${val}
  298. Input Value ${locator} ${val}
  299.  
  300. 输入密码
  301. [Arguments] ${path} ${passwd}
  302. Input Password ${path} ${passwd}
  303.  
  304. 输入文本
  305. [Arguments] ${path} ${text}
  306. Input Text ${path} ${text}
  307.  
  308. 返回
  309. [Documentation] 浏览器返回上一个的页面
  310. Go Back
  311.  
  312. 重置应用
  313. Reset Application
  314.  
  315. 锁屏
  316. [Arguments] ${sec}
  317. [Documentation] 这个方法只使用于IOS
  318. Lock ${sec}
  319.  
  320. 长按元素
  321. [Arguments] ${locator}
  322. Long Press ${locator}
  323.  
  324. 长按关键字
  325. [Arguments] ${keycode} ${metastate}=None
  326. [Documentation] keycode 可以在这个网址里面找到:
  327. ... http://developer.android.com/reference/android/view/KeyEvent.html.
  328. ...
  329. ... Args:
  330. ... \ \ \ \ - keycode - the keycode to be sent to the device
  331. ... \ \ - metastate - meta information about the keycode being sent
  332. Long Press Keycode ${keycode} ${metastate}
  333.  
  334. 隐藏键盘
  335. Hide Keyboard
  336.  
  337. 页面不应该包含元素
  338. [Arguments] ${locator} ${lvl}=INFO
  339. Page Should Not Contain Element ${locator} ${lvl}
  340.  
  341. 页面不应该包含文本
  342. [Arguments] ${locator} ${lvl}=INFO
  343. Page Should Not Contain Text ${locator} ${lvl}
  344.  
  345. 页面应该包含元素
  346. [Arguments] ${locator} ${lvl}=INFO
  347. Page Should Contain Element ${locator} ${lvl}
  348.  
  349. 页面应该包含文本
  350. [Arguments] ${locator} ${lvl}=INFO
  351. Page Should Contain Text ${locator} ${lvl}
  352.  
  353. 页面截图
  354. [Arguments] ${filename}=
  355. Capture Page Screenshot ${filename}

AppiumLibrary用户关键字的更多相关文章

  1. RobotFramework AppiumLibrary 用户关键字

    RobotFramework AppiumLibrary 用户关键字 最近在用robotframework搞安卓app 的自动化,其中用到了 AppiumLlibrary 的关键字,我都映射成了用户关 ...

  2. Robot Framework--06 用户关键字User Keyword

    转自:http://blog.csdn.net/tulituqi/article/details/7906130 在我们做自动化案例的时候,用的最多的主要是用户关键字.说到关键字,大体上可以分为测试库 ...

  3. Robot Framework学习笔记(九)------创建资源和用户关键字

    一.测试套件下创建用户关键字 1.创建关键字测试套件右击->点击new user keyword,然后输入name,点击OK保存. 2.在用户关键字的edit点击settings,然后输入Arg ...

  4. Robot framework(RF) 用户关键字

    3.6  用户关键字 在Robot Framework 中关键字的创建分两种:系统关键字和用户关键字. 系统关键字是需要通过脚本开发相应的类和方法,从而实现某一逻辑功能. 用户关键字是根据业务的需求利 ...

  5. Robot Framework(用户关键字)

    在 Robot Framework 中关键字的创建分两种:系统关键字和用户关键字.系统关键字需要通过脚本开发相应的类和方法,这个我们将在后面的章节介绍.用户关键字的创建就要简单得多,它主要利用现有的系 ...

  6. Robot Framework(七)创建用户关键字

    2.6创建用户关键字 关键字表用于通过将现有关键字组合在一起来创建新的更高级别关键字.这些关键字称为用户关键字,以区别于 测试库中实现的最低级库关键字.创建用户关键字的语法与创建测试用例的语法非常接近 ...

  7. robotframework之用户关键字的用法

    robotframework是一个关键字驱动框架,核心在于关键字的应用 目录 1.如何创建用户关键字 2.调用用户关键字 3.用户关键字的使用场景 1.如何创建关键字 第一种:直接在项目上右键,添加用 ...

  8. Robot Framework(11)- 用户关键字的详解

    如果你还想从头学起Robot Framework,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1770899.html 什么是用户关键字 ...

  9. robot 如何定义用户关键字、变量

    1.用户关键字,使用robot语法定义的关键字 2.系统关键字  自带的 3.资源文件,自己定义的关键字 4.变量 自己定义的关键字,需单独建一个资源文件 自己写的关键字,需写在***Keywords ...

随机推荐

  1. 认识Linux文件系统的架构

    本文主要研究一下storm的OpaquePartitionedTridentSpoutExecutor TridentTopology.newStream storm-core-1.2.2-sourc ...

  2. K/3Cloud 分页报表示例参考

    分页报表首先需要实现的方法就是GetList,这个方法用来获得分页的条件. 其他的就和其他报表类似了. using System; using System.Collections.Generic; ...

  3. Euclidean Nim(bzoj 4147)

    Description Euclid和Pythagoras在玩取石子游戏,一开始有n颗石子. Euclid为先手,他们按如下规则轮流操作: ·若为Euclid操作,如果n<p,则他只能新放入p颗 ...

  4. 【Educational Codeforces Round 48】

    A:https://www.cnblogs.com/myx12345/p/9843001.html B:https://www.cnblogs.com/myx12345/p/9843021.html ...

  5. linux上配置spark集群

    环境: linux spark1.6.0 hadoop2.2.0 一.安装scala(每台机器)   1.下载scala-2.11.0.tgz   放在目录: /opt下,tar -zxvf scal ...

  6. linux service命令解析(重要)

    我们平时都会用service xxx start来启动某个进程,那么它背后究竟执行了什么? 其实service的绝对路径为/sbin/service ,打开这个文件cat /sbin/service, ...

  7. windows 下安装Apache httpd 只需三步

    1.下载 Apache 官网地址:http://httpd.apache.org/docs/current/platform/windows.html#down 找到这个, 看到这几个选项: Apac ...

  8. POJ 2391 多源多汇拆点最大流 +flody+二分答案

    题意:在一图中,每个点有俩个属性:现在牛的数量和雨棚大小(下雨时能容纳牛的数量),每个点之间有距离, 给出牛(速度一样)在顶点之间移动所需时间,问最少时间内所有牛都能避雨. 模型分析:多源点去多汇点( ...

  9. React学习及实例开发(三)——用react-router跳转页面

    本文基于React v16.4.1 初学react,有理解不对的地方,欢迎批评指正^_^ 一.定义路由 1.安装react-router npm install react-router@ --sav ...

  10. P1003 铺地毯(noip 2011)

    洛谷——P1003 铺地毯 题目描述 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯.一共有 n 张地毯,编号从 1 到n .现在将这些地毯 ...