Performing automation testing with Poco

Poco is a cross-engine UI automation framework providing engine independent powerful APIs that retrieve the UI element hierarchy in app’s runtime. Poco supports mainstream game engines such as Unity3D, Cocos2dx and native Android apps.

Learn more from project homepage or Fork Poco on GitHub,

Poco integration with AirtestIDE

While you write the Poco script, IDE provides 3 modes to assist you to obtain the UI element information in a real-time. Poco supports 4 types of engines:

  1. Unity
  2. Cocos-js,
  3. Netease SDK
  4. Android

In order to use Unity, Cocos-js or Netease, the Poco-sdk must be embedded with the testing mobile app. More details about Poco-sdk can be found in Poco-SDK implementation guide.

Poco assistant window is placed on the top left side of AirtestIDE GUI layout by default (as shown on screenshot below).

../_images/poco_intro.png

To change the engine type, use the drop-down menu and perform following steps:

  1. switch to Stop selection
  2. change to desired engine type
../_images/1-poco_switch_app.gif

UI Freeze and Inspector modes

Poco framework provides two modes how to interact with UI elements - UI freeze mode and UI inspector mode.

UI Freeze Mode

The UI freeze mode allows to freeze the device screen in current state and stops refreshing the UI-hierarchy.

How to enter:
Click Pause button in Poco assistant window, or click on any item in the data branch.
../_images/poco_pause_button.png
How to interact:
Device screen freezes in current state and the UI hierarchy stops refreshing at the same time. You can obtain the details about the outlined UI-widget by moving mouse inside the device screen area. You can also inspect the details about the UI-widget in log window by clicking on the object of interest of the UI-widget.
How to exit:
To exit the UI freeze mode, right click on the device screen

Following demonstrates the usage if the UI freeze mode:

../_images/2-poco_freeze.gif

UI Inspector Mode

Inspector mode allows to manipulate with the device, inspect the UI-widgets and logs while UI-hierarchy keeps refreshing.

How to enter:
Click Inspector button.
../_images/poco_inspector_button.png
How to interact:
UI-hierarchy keeps refreshing while you operate on the device screen. You can obtain the details about the outlined UI-widget by moving mouse inside the device screen. You can also inspect the details about the UI-widget in log window by clicking on the object of interst of the UI-widget.
How to exit:
To exit the UI inspector mode, right click on the device screen.

Following demonstrates the usage of the inspector mode.

../_images/3-poco_inspector.gif

Recording Poco script in AirtestIDE

Poco framework provides Python APIs, so we can create automation script in straightforward way. Poco scripts can be recorded either manually step by step, or automatically by capturing all click events on the device screen.

To start record the script manually, click the Pause button to enter the UI freeze mode and move the mouse to the device screen, the selection box appears and you can obtrain the UI tree structure by clicking on selected element. To automatically insert the node code to the the script section, double-click on object of interest.

Following demonstrates how to record Poco script manually:

../_images/4-poco_manual_record.gif

Sometimes, recording the script manually is not very effective, therefore the AirtestIDE provides also automatic script recording. To start record the script automatically, perform following steps:

How to enter:
To enter the auto recording mode, click Auto Recording button.
../_images/poco_auto_recording1.png
How to interact:
UI-hierarchy keeps refreshing while you are operating on the device screen. You can obtain the details about the outlined UI-widget by moving mouse within the device screen. The code will be automatically generated in the script area during the operation.
How to exit:
You can quit the Auto Recording mode with right click on the device screen.

Following demonstrates how to record Poco script automatically.

../_images/5-poco_auto_record.gif

Poco assistant for Windows app

Poco has been implemented to work with some apps in Windows OS (such as with Unity game window). We could use AirtestIDE to view and select UI nodes from these apps. To use this feature, you need to first input the position and size of the app window in AirtestIDE.

The steps to be able to use Poco from AirtestIDE are: Go to Options-Settings-Poco, select Windows Content Area Rect . Select the area of the window and double-click to confirm (right click/press ESC to cancel). This is shown in the image below:

../_images/windows_poco_render_rect.gif

Notes about interaction with Poco

  1. When switching the engine type, a pop-up window appears and it prompts you whether to insert the poco initialization code. Click yes to confirm.
  2. After the UI-hierarchy is shown in the tree structure, you can easily search the hierarchy by hiding/showing the search box by pressing Ctrl+F key combination.