1. 测试框架中的图片相关处理场景:"多图查找", "局部截图", "局部识图", "两图对比"

from airtest.aircv import *
from airtest.aircv.cal_confidence import *

1.1 多图查找:find_all(params)
                               传参: Template
                               回参:list

1.2 局部截图:aircv.crop_image(screen,(x1,y1,x2,y2))
                              传参:screen= G.DEVICE.snapshot() #获取当前屏幕图像
                                         (x1,y1,x2,y2): 截取区域的左上角,右下角坐标
                              回参:numpy.ndarray, 多维数组

1.3 局部识图:template.match_in(screen)
                              传参:target_img_path # 要查找的目标图片路径
                              screen: # 当前图片
                              回参:坐标 或 None

1.4两图对比: cal_ccoeff_confidence(cv2.imread(img1),cv2.imread(img2))
                              传参:img #图片路径
                              回参:(0,1] 相似度  

        

2. 除IDE高频使用的assert__exsits(图片)断言,根据不同的用例场景与处理,返回值多样,需要应用多种断言语句:

from airtest.core.assertions import *

# 断言表达式为True
assert_true(1==1, msg="assert 1==1")

# 断言表达式为False
assert_false(1==2, msg="assert 1!=2")

# 断言2个对象相同
assert_is(1, 1, msg="assert 1 is 1")

# 断言2个对象不相同
assert_is_not(1, 2, msg="assert 1 is not 2")

# 断言表达式为None
assert_is_none(None, msg="assert None is None")

# 断言表达式不为None
assert_is_not_none(1, msg="assert 1 is not None")

# 断言第一个参数在第二个参数中
assert_in(1, [1, 2], msg="assert 1 in [1, 2]")

# 断言第一个参数不在第二个参数中
assert_not_in(3, [1, 2], msg="assert 3 not in [1, 2]")

# 断言对象是某种类型的实例
assert_is_instance(1, int, msg="assert 1 is int")

# 断言对象不是某种类型的实例
assert_not_is_instance(1, str, msg="assert 1 is not str")

# 断言第一个值大于第二个值
assert_greater(2, 1, msg="assert 2 > 1")

# 断言第一个值大于等于第二个值
assert_greater_equal(1, 1, msg="assert 1 >= 1")

# 断言第一个值小于第二个值
assert_less(1, 2, msg="assert 1 < 2")

# 断言第一个值小于等于第二个值
assert_less_equal(1, 1, msg="assert 1 <= 1")