Skip to content

How to test games based on the Unity3D engine

Because the game interface is rendered by the game engine, the game interface does not have system-native control information. So for games, we need to access poco-sdk to get the control information in the game interface.The following uses the mobile game developed by Unity as an example to introduce how to connect on Android and iOS platforms.

Android platform

  1. Clone the Unity3D folder from poco sdk repo.


  1. Place the cloned Unity3D folder in the Assets/Scripts folder of your Unity project.


  1. Delete unused folders named UI system in the Assets/Scripts/Unity3D directory. Example: If the UI system used in your project is ugui, please delete the two foldersfairygui and ngui ,then keep theugui folder.


  1. Open your project in Unity3D and add Unity3D/PocoManager.cs as a script component to your GameObject.It is required to be mounted under an object that will never be destroyed, such as the main camera under normal circumstances.

For example:
Click on the Main Camera in thedemo scene, and the inspector interface will appear on the right. Then click on Add Component in the inspector interface.



Enter poco in the pop-up dialog box and select the Poco Manager option that appears.


After completing the above operations, the component will appear in the inspector interface as shown in the figure.


  1. Click File-> Build Settings in the upper left corner of the interface to generate a suitable Android package and install it on your phone.

  2. Start Airtest IDE, link your phone to Airtest IDE as described above, and start the corresponding game.

  3. Select the Unity mode in the Poco auxiliary window in the lower left corner, and you can see the UI tree structure of the current interface:


  1. After selecting the Unity mode, Airtest IDE will automatically insert poco's initialization code:


When writing the script, we can use the API provided by Poco to operate the elements on the game interface.

Here is a simple test case. You can download this simple Unity3D game from here. After the installation is complete, open the game, click Start button, then clickdrag drop, and the following interface will appear.


For each star you drag to the shell in the center of the screen, you will get 20 points; if you drag 5 stars to the shell in turn, you will get 100 points. The following script is testing whether dragging 5 stars one by one will get 100 points.

from airtest.core.api import *


from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()



shell = poco('shell').focus('center')
for star in poco('plays').offspring('star'):

assert poco('scoreVal').get_text() == "100", "score correct."
poco('btn_back', type='Button').click()

Click the Run Script button and you will get the result shown below.


iOS platform

  1. Similarly, you need to complete the engine SDK access first, and then connect the iOS phone through the Airtest IDE
  2. Different from Android, the connection of iOS Unity Poco requires starting two proxy. 8100 port is used to connect iOS mobile phone, 5001 port is used to connect to rpc port of poco-sdk
iproxy 8100 8100
iproxy 5001 5001

Here iproxy is equivalent to forward in adb

  1. After connecting the iOS phone, you select the Unity mode in the Poco auxiliary window, and then you will see the UI tree structure of the current interface:


  1. Then you can write automated test scripts for games on iOS through the API provided by Poco.