【移动自动化】【六】断言

断言

  1. 通过find_element 找到元素,判断是否存在
  2. 获取通过get_attribute获取对象,判断是否存在
  3. 通常使用 assert,可以查看pytest中断言用法 常用的有in , >=, !=
  4. 可以参考ch2/test_asset.pu

PyHamcrest

  1. 用法更丰富
  2. pip install PyHamcrest
  3. https://github.com/hamcrest/PyHamcrest
  4. demo-> ch2/test_hamcrest.py
task = self.driver.find_element_by_xpath('//*[contains(@resource-id, "tvName") and contains(@text, "任务中心")]')
assert_that(task.text, equal_to('任务中心'))
  1. 官网有很有用法,可以直接参考,这边不一一列举了

github

https://github.com/wangxiao9/appium_demo.git

posted @ 2020-08-07 16:09  WANG-X  阅读(154)  评论(0编辑  收藏  举报