Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
305 lines (226 sloc) 13.3 KB

Welcome to Poco (ポコ) documentation!

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

.github-corner:hover .octo-arm { animation:octocat-wave 560ms ease-in-out } @keyframes octocat-wave { 0%,100% { transform:rotate(0) } 20%,60% { transform:rotate(-25deg) } 40%,80% { transform:rotate(10deg) } } @media (max-width:500px) { .github-corner:hover .octo-arm { animation:none } .github-corner .octo-arm { animation:octocat-wave 560ms ease-in-out } }
.github-btn{height:20px;overflow:hidden}.gh-btn,.gh-count,.gh-ico{float:left}.gh-btn,.gh-count{padding:2px 5px 2px 4px;color:#333;text-decoration:none;text-shadow:0 1px 0 #fff;white-space:nowrap;cursor:pointer;border-radius:3px}.gh-btn{background-color:#eee;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fcfcfc),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#fcfcfc 0,#eee 100%);background-image:-moz-linear-gradient(top,#fcfcfc 0,#eee 100%);background-image:-ms-linear-gradient(top,#fcfcfc 0,#eee 100%);background-image:-o-linear-gradient(top,#fcfcfc 0,#eee 100%);background-image:linear-gradient(to bottom,#fcfcfc 0,#eee 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#eeeeee', GradientType=0);background-repeat:no-repeat;border:1px solid #d5d5d5}.gh-btn:focus,.gh-btn:hover{text-decoration:none;background-color:#ddd;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#eee),color-stop(100%,#ddd));background-image:-webkit-linear-gradient(top,#eee 0,#ddd 100%);background-image:-moz-linear-gradient(top,#eee 0,#ddd 100%);background-image:-ms-linear-gradient(top,#eee 0,#ddd 100%);background-image:-o-linear-gradient(top,#eee 0,#ddd 100%);background-image:linear-gradient(to bottom,#eee 0,#ddd 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#dddddd', GradientType=0);border-color:#ccc}.gh-btn:active{background-image:none;background-color:#dcdcdc;border-color:#b5b5b5;box-shadow:inset 0 2px 4px rgba(0,0,0,.15)}.gh-ico{width:14px;height:14px;margin-right:4px;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjQwcHgiIGhlaWdodD0iNDBweCIgdmlld0JveD0iMTIgMTIgNDAgNDAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMTIgMTIgNDAgNDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiMzMzMzMzMiIGQ9Ik0zMiAxMy40Yy0xMC41IDAtMTkgOC41LTE5IDE5YzAgOC40IDUuNSAxNS41IDEzIDE4YzEgMC4yIDEuMy0wLjQgMS4zLTAuOWMwLTAuNSAwLTEuNyAwLTMuMiBjLTUuMyAxLjEtNi40LTIuNi02LjQtMi42QzIwIDQxLjYgMTguOCA0MSAxOC44IDQxYy0xLjctMS4yIDAuMS0xLjEgMC4xLTEuMWMxLjkgMC4xIDIuOSAyIDIuOSAyYzEuNyAyLjkgNC41IDIuMSA1LjUgMS42IGMwLjItMS4yIDAuNy0yLjEgMS4yLTIuNmMtNC4yLTAuNS04LjctMi4xLTguNy05LjRjMC0yLjEgMC43LTMuNyAyLTUuMWMtMC4yLTAuNS0wLjgtMi40IDAuMi01YzAgMCAxLjYtMC41IDUuMiAyIGMxLjUtMC40IDMuMS0wLjcgNC44LTAuN2MxLjYgMCAzLjMgMC4yIDQuNyAwLjdjMy42LTIuNCA1LjItMiA1LjItMmMxIDIuNiAwLjQgNC42IDAuMiA1YzEuMiAxLjMgMiAzIDIgNS4xYzAgNy4zLTQuNSA4LjktOC43IDkuNCBjMC43IDAuNiAxLjMgMS43IDEuMyAzLjVjMCAyLjYgMCA0LjYgMCA1LjJjMCAwLjUgMC40IDEuMSAxLjMgMC45YzcuNS0yLjYgMTMtOS43IDEzLTE4LjFDNTEgMjEuOSA0Mi41IDEzLjQgMzIgMTMuNHoiLz48L3N2Zz4=);background-size:100% 100%;background-repeat:no-repeat}.gh-count{position:relative;display:none;margin-left:4px;background-color:#fafafa;border:1px solid #d4d4d4}.gh-count:focus,.gh-count:hover{color:#4183C4}.gh-count:after,.gh-count:before{content:'';position:absolute;display:inline-block;width:0;height:0;border-color:transparent;border-style:solid}.gh-count:before{top:50%;left:-3px;margin-top:-4px;border-width:4px 4px 4px 0;border-right-color:#fafafa}.gh-count:after{top:50%;left:-4px;z-index:-1;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#d4d4d4}.github-btn-large{height:30px}.github-btn-large .gh-btn,.github-btn-large .gh-count{padding:3px 10px 3px 8px;font-size:16px;line-height:22px;border-radius:4px}.github-btn-large .gh-ico{width:20px;height:20px}.github-btn-large .gh-count{margin-left:6px}.github-btn-large .gh-count:before{left:-5px;margin-top:-6px;border-width:6px 6px 6px 0}.github-btn-large .gh-count:after{left:-6px;margin-top:-7px;border-width:7px 7px 7px 0} Fork Star 99+

Getting Started

.. toctree::
   :maxdepth: 2

   source/README

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.

../doc/img/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) !

source/doc/img/hunter-inspector.png

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 API

You can find all functions/methods for writing test scripts under the following links.

.. toctree::
    :maxdepth: 2

    Poco instance API <source/poco.pocofw>
    UI proxy object API <source/poco.proxy>
    Exceptions <source/poco.exceptions>

Engine specific API

.. toctree::
    :hidden:

    Poco drivers (engine specific poco implementation) <source/doc/poco_drivers>

Poco SDK API

.. toctree::
    :maxdepth: 3

    Poco SDK API <source/poco.sdk>


.. toctree::
    :hidden:

    Examples and Tutorial <source/doc/poco-example/index>

.. toctree::
    :hidden:

    Project integration <source/doc/integration>


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