首页 > 其他 > 详细

使用poco方法的断言知识

时间:2020-01-17 17:47:14      阅读:691      评论:0      收藏:0      [点我收藏+]

Airtest的断言语句

1、验证UI界面

assert_exists  和  assert_not_exists  两个接口来断言一张图片存在或不存在于当前画面中。

此方法使用简单,不赘述。

2、验证数值

assert_equal  和  assert_not_equal  来断言传入的两个值相等或者不相等。

操作:

# assert_equal("实际值", "预测值", "请填写测试点.")

# 获取控件的“text”属性值
value = poco("com.miui.calculator:id/btn_8_s").attr("text")
assert_equal(value, "8", "按钮值为8")

 

断言相关的知识——处理断言失败

不论是airtest提供的断言接口,还是Airtest-selenium提供的断言接口,如果断言失败,都会引发AssertionError,从而导致脚本执行终止;如果不想脚本因为一个断言失败就终止,可以将断言用try语句包起来:

value = poco("com.miui.calculator:id/btn_8_s").attr("text")

try:
    assert_equal(value, "8", "按钮值为8")
except AssertionError:
    print("按钮值断言失败")

  

转载:https://mp.weixin.qq.com/s/DEe-Emyi0hN0JZA83i1Wmg

 

 

 

 

使用poco方法的断言知识

原文:https://www.cnblogs.com/CincentHuang/p/12206623.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!