Skip to content

一、Generate Report in AirtestIDE

1.Click on the 'view report' button in IDE

After clicking "Run Script" in the IDE, regardless of whether there are any errors, we can directly click the "View Report" button on the top menu bar. The shortcut key is Ctrl+L. This helps us quickly generate an HTML format report and open it with the default browser.



2.Command line for generating reports in IDE.

When clicking the 'View Report' button in the IDE, the log viewer window will display a command line that generates the report.

Generating HTML log:

D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\AirtestIDE reporter D:\test\song.air --log_root D:/test/test01\0d86098ed0cd4a54c8c611578a3d71b7 --outfile D:\test\test01\0d86098ed0cd4a54c8c611578a3d71b7\log.html --static_root D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\airtest\report --lang zh --plugin

This command means:

  • D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\AirtestIDE reporter D:\test\song.air: generating a running report for the song.air script.

  • --log_root D:/test/test01\0d86098ed0cd4a54c8c611578a3d71b7: According to the log content under the path

  • D:/test/test01\0d86098ed0cd4a54c8c611578a3d71b7. --outfile D:\test\test01\0d86098ed0cd4a54c8c611578a3d71b7\log.html: Export the HTML report to this path at D:\test\test01\0d86098ed0cd4a54c8c611578a3d71b7\log.html.

  • --static_root D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\airtest\report: Specifies the use of static resources from the path D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\airtest\report.

  • --lang zh: Specify the language of the report as Chinese.

  • --plugin Using the report plugin of airtest-selenium and poco.

After generating the report, we can right-click on the script name and select "Open Report File Directory" to help us quickly enter the folder where the HTML report is located.



3.The difference between generating .air and .py script reports.

Regarding the .airand .py scripts, there are some slight differences in the process of generating reports when running in AirtestIDE and clicking on "View Report". Let's take a closer look below.

1)Test report for .air script

For .air scripts that are run in an IDE, the IDE will help us save the log content of the script running in the default log save path. After running the .air script, when we click "View Report", the IDE will find the log content of the script running in this default log save path, and then generate the airtest report directly based on it, without any additional manual processing required.

2)Test report for the .py script

But when running the .py script in an IDE, it's different. First of all, we need to understand that the basis for generating the report is the log content saved during script execution. This means that when running the .py script, we must save the log content, otherwise, the subsequent airtest report generated will have no log content, resulting in an empty report.

So remember to check the "generate log" option, when creating a new .py script.


This is how we ensure that the initialization statement inside the newly built .py script does not have logdir set to None:


Select the 'generate log' option. In the initialization statement, logdir will be set to True. We can also set other log saving paths and pass them to logdir, for example:


Please remember the log path of their .py script. When clicking on 'View Report', we need to manually select the log saving path.


4.Export report with one click in IDE.

The report generated by clicking the "View Report" button can only be viewed locally. We cannot simply package the generated report folder and share it with others for viewing, because the HTML report generated by clicking "View Report" contains absolute paths for images and other static resources. When viewing such reports outside of the local environment, the images and some static resources may not be displayed correctly.

1)Export test report with one click in the IDE

But we can export the report and convert the image and static resource paths in the report to relative paths, so that we can deploy the report on a server or send it to other colleagues for normal viewing. After clicking the "Export Report" button, we need to select the folder to export to. Once selected, it will help us export a report containing all resource files. This folder not only contains an HTML report, but also log files, static resource files, scripts, and screenshots of the scripts. We can directly zip the entire folder and send it to other colleagues for viewing. Also, we can open the HTML report and check the resource paths inside. We can see that they are already relative paths.

2)The command line for exporting a report.

After clicking "Export Report", the command line for exporting the report will be displayed in the log viewing window: Generating HTML log:

D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\AirtestIDE reporter D:\test\song.air --log_root D:/test/test01\0d86098ed0cd4a54c8c611578a3d71b7 --outfile D:\export\report\song.log\log.html --static_root D:\demo\AirtestIDE-win-1.2.12\AirtestIDE\airtest\report --lang zh --plugin --export D:/export/report

Unlike the command line for clicking to view the report, here is an additional parameter "--export":

  • --export D:/export/report means to export our test report to the directory path D:/export/report.

5.Common Issues When Generating Reports.

1)Report generation failed

After clicking 'View Report' in the IDE, a prompt window appears: Failed to generate HTML report!


You can copy the command line that generates the report to the terminal for execution, check the more detailed error message if the report generation fails, and then modify it based on the error message.


2)Prompt: There is no log.txt file.

  • If after clicking the 'View Report' button, a pop-up message appears:


Please check the following aspects: - Is the current script saving log content? If not, please set it to save log content. In the command line for generating reports, check if there is a log.txt file under the path pointed by --log_root. If the file does not exist, please check if it has been saved to another path. - Did you accidentally delete the log file for the script?

3)Missing image files while viewing the report.

If we find that the report displays as follows when viewing it, that is, the report format and some image resources are missing:


We can check the following aspects:

  • If you use Chrome browser to open the report (other browsers may not be as compatible with the Airtest report).
  • If you have shared the report that has not been exported with others, please export the report before sharing it with other friends.
  • You can right-click on the blank space in the report and select "inspect" to check whether the path of missing static or image resources is correct.

4)Notification says that the generated report is a blank report.

If the generated report is a blank report: We can check the following aspects:


  • Is the log.txt file for this script empty? If so, you need to run it again to generate log content before generating the report.

  • Did you use a script to generate a report at the beginning of the script? If so, please execute the specific steps first, and then execute the script that generates the report at the end.