您的位置:首页 > 移动开发

RobotFrameWork+APPIUM实现对安卓APK的自动化测试----第五篇【AppiumLibrary校验函数介绍】

2016-02-01 15:55 453 查看
以上连作者先跪一下方便面,在上一篇中,作者遗漏了两个常用的函数:

1.长按

Long PresslocatorLong press the element

这个函数的作用为:长按一个控件

2.缩小(翻译为 “捏”)

Pinchlocator, percent=200%, steps=1Pinch in on an element a certain amount.

这个函数作者老实坦白,没有试验过,个人赶脚和ZOOM是一样的(放大),缩小功能

好啦接下来开始我们的第五篇啦,校验函数的介绍。

校验主要是用来判断界面操作是否成功,主要方法有:判断URL是否正确、需要的元素是否出现、需要元素属性是否正确、等等

1.元素校验

Element Name Should Belocator, expected
Element Should Be Disabledlocator, loglevel=INFOVerifies 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=INFOVerifies 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 Belocator, expected
这一组为元素级别的校验,是较为细致的校验,

第一个是检查元素的NAME属性,

第二个为检查元素是否为不可用/见,

第三个为检查元素是否可用/见,

第四个为检查元素value属性;

这一组作者自己用的较少,个人认为现在做APP自动化测试,界面内容本来就不多,无需这么精细。

备注:locator为元素定位,loglevel为日志等级,expected为希望值,同学们照着填就可以了。

2.界面校验

Page Should Contain Elementlocator, loglevel=INFOVerifies 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

Page Should Contain Texttext, loglevel=INFOVerifies 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=INFOVerifies 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

Page Should Not Contain Texttext, loglevel=INFOVerifies 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.

这一组为界面级别的校验,是一个较为常用的校验,
第一个为界面必须包含什么元素,

第二个为界面必须包含什么文字信息,(最为常用)

第三个为界面必须不包含什么元素,

第四个为界面必须不包含什么文字信息,(第二个最为常用)

作者写断言的时候,大部分都用的是第二个和第四个,当然这个是作者自己的偏好,同学们还是应该更为宽广的应用函数。

第五篇的内容就这些了,希望对童鞋们的APPIUM自动化测试指路能有所帮助。如果有什么遗漏的或者说的不对的也请同学们指正
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: