# 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](http://pywinauto.readthedocs.io/en/latest/index.html) to simulate the interface operation. ![Windows Schematic diagram](4_get_started_with_Windows_test/1_windows_framework.png) ## 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-](4_get_started_with_Windows_test/2_default_embed.gif) 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-](4_get_started_with_Windows_test/3_backup_embed.gif) ### **3、Desktop mode:** If you want to test the entire desktop, AirtestIDE also provides a shortcut to the desktop mode. ![airtestide-desktop-demo](4_get_started_with_Windows_test/4_desktop_mode.gif) ## 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-](4_get_started_with_Windows_test/5_gen_script.gif) **Operational notes:** - Please try to use "poco auto recording" as little as possible![poco auto recording](https://user-images.githubusercontent.com/8188879/42209576-96a33f3c-7ee1-11e8-95b2-2b47e7c90924.png) 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](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html), if there are special input requirements such as key combinations. ### 2、Run the script and view the report ![4-run script](4_get_started_with_Windows_test/6_run_script.gif) ![5-View report](4_get_started_with_Windows_test/7_view_report.gif) 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**