UI自动化之Poco常用断言方式

实际上用到的几种写断言的方式:

1.验证UI界面(断言图片是否存在,UI页面不稳定情况下,图片识别效率不高)
assert_exists
assert_not_exists
2.验证数值(断言传入的两个值(数字或者string)是否相等)
assert_equal:

assert_equal(poco("button").get_text(), "0", "按钮的值与预期一致")

assert_not_equal

 name1=self.poco(text='名称').parent().parent().child()[11].child()[0].child()[0]
self.poco(text='涨幅').click()
time.sleep(3)
# 获取排序后的第一个基金的name值
name2=self.poco(text='名称').parent().parent().child()[11].child()[0].child()[0]
assert_not_equal(name1.get_text(),name2.get_text(),"排序后,非同一支基金")

3.断言文字是否存在

assert_true(self.poco(text='涨幅榜').exists())

你可能感兴趣的:(Appium移动端测试,ui,自动化,前端)