Airtest简介
Airtest是网易出品的一款基于图像识别和poco控件识别的一款UI自动化测试工具。基于图形化识别的Airtest Project解决方案,十分有效地降低了自动化测试的门槛,真正使自动化测试带来测试效率的提升。Google表示Airtest 是安卓游戏最强大、最全面的自动测试方案之一。
Airtest的使用,官方文档有详细说明,详见:
http://airtest.netease.com/docs/docs_AirtestIDE-zh_CN/index.html
Airtest API文档,如下:
https://airtest.readthedocs.io/en/latest/
以下列出将Airtest API文档翻译了一些常用的操作,希望能帮助到大家:
Poco
Poco是一款基于UI控件搜索的自动化框架,与基于图像识别的Airtest不同的是,Poco可以使用类似 poco(“OK”).click() 的方式来获取并操作节点
Poco的常规使用案例:
poco = Poco() 初始化
点击
poco(‘btn_start’).click()
poco(text=‘basic’).click().click()
poco(‘btn_back’, type=‘Button’).click()
poco(‘star_single’).long_click()
poco(‘star_single’).long_click(duration=5)
对象存在判断
invisible_obj = poco(‘result_panel’, type=‘Layer’)
print(invisible_obj.exists()) # => False. This UI is not visible to user.
拖动和滑动(drag/swipe)
poco(‘star’).drag_to(poco(‘shell’))
poco(‘Scroll View’).swipe([0, -0.1])
poco(‘Scroll View’).swipe(‘up’) # the same as above, also have down/left/right
x, y = poco(‘Scroll View’).get_position()
end = [x, y - 0.1]
dir = [0, -0.1]
poco.swipe([x, y], end) # drag from point A to point B
poco.swipe([x, y], direction=dir) # drag from point A toward given direction and length
等待UI
start_btn = poco(‘start’)
start_btn.click()
start_btn.wa