Welcome to Poco (ポコ) documentation!

A cross-engine UI automation framework. Unity3D/cocos2dx-*/Android native APP/(Other engines SDK)/…

Fork Star 99+

Getting Started

Install Poco and PocoSDK

In order to use Poco, you must install Poco python library on your host and also install the poco-sdk in your game/app.

Poco can be installed straightforward with pip command

pip install pocoui

For poco-sdk integration please refer to Integration Guide

Using Poco as Python package

Simple demo

The following example shows a simple script on demo game using Unity3D. Check More examples section for more detailed info.

First you should connect your Android phone, for example, via usb cable and enable the ADB DEBUG MODE.

_images/overview.gif
# 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 for writing test scripts

To retrieve the UI hierarchy of the game, please use our AirtestIDE (an IDE for writing test scripts) or standalone PocoHierarchyViewer (to viewer the hierarchy and attributes only but lightweight) !

_images/hunter-inspector.png

API reference

Dump UI hierarchy example

Poco defines an uniform format to serialize UI hierarchy for different game engines. This section shows how to dump UI hierarchy.

import json
from poco.drivers.unity3d import UnityPoco as Poco

poco = Poco()
ui = poco.agent.hierarchy.dump()
print(json.dumps(ui, indent=4))

The following is the snippet of UI hierarchy. All UI elements are organized in dict representing the tree structure. More detailed info about properties are described in .dumpHierarchy().

...
{
    "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": [
        {...},
        ...
    ],
}
...

Join to discuss!

join slack