欢迎使用Poco (ポコ) UI自动化框架¶
A cross-engine UI automation framework. Unity3D
/cocos2dx-*
/Android native APP
/iOS native APP
/(Other engines SDK)/…
快速预览¶
安装Poco和PocoSDK¶
在电脑上安装poco,并把poco-sdk集成到游戏里
直接pip安装即可
pip install pocoui
把sdk集成到游戏里请参考 Integration Guide 。 网易自研引擎 无需嵌入sdk,请在hunter上直接配置,见 Integration Guide for NetEase
如何使用¶
示例¶
下面Unity3D的例子展示了最简单的用法,更多的例子请移步 More examples. 网易自研引擎项目请参考 网易游戏项目测试脚本标准模板 来开始建立回归测试工程。
首先请把usb线连上Android手机并打开 adb调试模式 。

# coding=utf-8
import time
from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()
poco('btn_start').click()
time.sleep(1.5)
shell = poco('shell').focus('center')
for star in poco('star'):
star.drag_to(shell)
time.sleep(1)
assert poco('scoreVal').get_text() == "100", "score correct."
poco('btn_back', type='Button').click()
编写脚本专用工具(Tools)¶
获取界面中的UI元素和开始编写脚本,请使用我们专门为您打造的 AirtestIDE 或轻量级的检视器 PocoHierarchyViewer 。 网易自研引擎 请直接使用 Hunter内嵌inspector .

Use poco on platforms/engines¶
This section guide you how to start to use poco to write your test cases on different platforms/engines.
入门教学用例(Tutorials and examples)¶
This section will let your know all basic features of poco.
API reference¶
如何用脚本抓取界面所有元素¶
Poco为不同的引擎定义了标准的界面层次结构(hierarchy)格式,在任何游戏上使用dump方法都可以获得相同的结构。示例代码和层次结构格式如下。
import json
from poco.drivers.unity3d import UnityPoco as Poco
poco = Poco()
ui = poco.agent.hierarchy.dump()
print(json.dumps(ui, indent=4))
下面就是层次结构(hierarchy)的数据表示,用 dict
存储并都是可json序列化的。
...
{
"name": "OctopusArea",
"payload": {
"name": "OctopusArea",
"type": "GameObject",
"visible": true,
"clickable": true,
"zOrders": {
"global": 0,
"local": -10
},
"scale": [
1,
1
],
"anchorPoint": [
0.5,
0.5
],
"pos": [
0.130729169,
0.44907406
],
"size": [
0.0859375,
0.125
]
}
"children": [
{...},
...
],
}
...