1.4 Test Windows app

This tutorial focuses on how to use AirtestIDE for automated testing of Windows OS applications. It uses Netease Cloud Music for Windows as the example application (app).

This article is about 550 words, it may take 2 minutes to read the full text

Basic information

AirtestIDE supports testing of common Windows OS applications, mainly relying on its image recognition framework (Airtest). For location positioning, use pywinauto to simulate the interface operation.

Windows Schematic diagram

Windows App connection

To test a Windows OS app, AirtestIDE first needs to select the window of such app.

After the window of the app to test is selected, AirtestIDE will actively place the connected window at the top of the stacking sequence (Z-order) when executing the tests, and then perform the corresponding test operation. It is worth mentioning that we are selecting the window of the app through window handles; After the window of the app is selected, the script will also give it a specific window handle when running. It is important not to close the selected window to avoid errors not finding such handle.

1、Conventional connection method:

AirtestIDE provides a one-click app embedding connection, as shown in the image:

1-

To improve of script writing efficiency, AirtestIDE will embed the app window into its “devices” window by default. (You can disconnect anytime through the shortcut entry on the top right of the “devices” window)

**2、Alternate connection method: **

For some special apps, there may be exceptions when you embed AirtestIDE (such as embedding failure, app being embedded but clicks not responding, etc.) In these cases, check “Settings” - “Device” - “Windows Embed Backup Method”. AirtestIDE will use the alternate method for connection (also called windows standby connection mode).

2-

3、Desktop mode:

If you want to test the entire desktop, AirtestIDE also provides a shortcut to the desktop mode.

airtestide-desktop-demo

Writing Airtest scripts

After completing the Windows app embedding process, you can start to write the test scripts on that app, by using the help panel of the left on the conected window.

1. Generate Test Scripts

3-

Operational notes:

  • Please try to use “poco auto recording” as little as possiblepoco auto recording It will adapt the app content to the size of the recording operation, which may result in rework of the script needed.
  • When performing the operation on the active screen such as touch / ʻ`` / assers_exists / assert_not_exists, after the screen area is selected:
    • Double click to complete the operation;
    • Right click to restart the screen area selection;
    • The Esc button exits this operation.
  • When performing a manual swipe operation, after completing the area selection, click the slide end to complete the statement recording.
  • When using text(), the underlying call is pywinauto.keyboard.SendKeys. Please see this document, if there are special input requirements such as key combinations.

2、Run the script and view the report

4-run script

5-View report

After the test script finishes running, the execution steps can be viewed on a report generated by a one-click report generation. If there is a script running error, the report also shows the possible cause of the error.

Other Features

  • Embedded POCO-SDK Game window Test (document on its way)
  • If a connected window is closed, you may consider testing app positioning (document on its way) using the window name