appium属性获取
获取属性 get_attribute
- 官方文档 http://appium.io/docs/en/commands/element/attributes/attribute/
- 写法:element.get_attribute(“content-desc”)
断言
hamcrest框架介绍
- hamcrest是一个为了测试为目的,能组合成灵活表达式的匹配器类库。用于编写断言的框架,使用这个框架编写断言,提高可读性及开发测试的效率
- hamcrest提供了大量被称为“匹配器”的方法。每个匹配器都设计用于执行特定的比较操作
- hamcrest的可扩展性强,让你能够创建自定义的匹配器
- 支持多种语言
- 文档:http://github.com/hamcrest/PyHamcrest
安装
- pip3 install pyhamcrest -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
例子
from hamcrest import *
class TestHamrest:
def test_hamrest_1(self):
assert_that(10, equal_to(10), '这是一个提示')
print('test_hamrest_1')
def test_hamrest_2(self):
assert_that(12, close_to(10, 2))
print('test_hamrest_2')
def test_hamrest_3(self):
assert_that('hello world', contains_string('hello'))
print('test_hamrest_3')
def test_hamrest_4(self):
assert_that(9, equal_to(10), '这是一个提示')
assert_that(9, close_to(10.0, 2.0))
print('test_hamrest_4')