AI-assisted generation of test cases for the same type of front-end automation

By building a standardized file directory in front-end automated testing and using an AI interface to generate test cases, the problems of long time consumption and high maintenance costs in existing technologies are solved, achieving efficient and standardized test case generation and improving the quality and stability of automated testing.

CN122432033APending Publication Date: 2026-07-21CHANGZHOU MICROINTELLIGENCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHANGZHOU MICROINTELLIGENCE CO LTD
Filing Date
2026-04-10
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In existing technologies, the writing and management of front-end automated test cases suffer from problems such as long processing time, inconsistent formats, frequent path errors, and high maintenance costs. Furthermore, AI-driven generation tools have failed to achieve automatic file pairing and parsing and structured generation.

Method used

By establishing a standardized file directory, using an AI interface to automatically generate test cases, and combining automatic file pairing and parsing, the consistency between .py test scripts and .yaml configuration files is ensured, and test cases that meet the specifications are generated through preset rules and multi-dimensional verification.

Benefits of technology

It significantly improves generation efficiency, reduces manual writing time, standardizes script and configuration file formats, lowers maintenance costs, and ensures that generated test cases conform to specifications, are compatible with various AI models, and improves test quality and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122432033A_ABST
    Figure CN122432033A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of automation testing, and discloses an AI-assisted method for generating same-type front-end automation test cases, and the specific steps are as follows: step one: a standardized file directory is built, so that the.py test script and the dependent.yaml configuration file meet the pairing conditions of same file name and consistent relative position, and the.py file starts with "test_"; the public configuration file and the AI parameter file are configured in the.yaml file directory. The method automatically generates same-type test cases through an AI interface, automatically pairs and analyzes the files, and improves the generation efficiency by more than 70%, greatly reducing the manual writing time; at the same time, the script and the configuration file format specification are unified, the configuration parameter hard coding is avoided, and the maintenance and expansion cost is reduced; the generated file is stored in the original directory in a non-overlapping manner, without the need for additional path adjustment, simplifying file management; relying on clear AI input rules and multi-dimensional verification, it is ensured that the generated test cases match the target requirements and can be directly executed by the pytest framework.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of automated testing technology, specifically an AI-assisted method for generating automated test cases for the same type of front-end. Background Technology

[0002] In front-end automated testing, test case writing and management are core components. Currently, testers typically need to manually write .py test scripts compatible with the pytest framework, along with corresponding .yaml configuration files. However, this manual approach has several drawbacks: First, manually writing test cases is time-consuming, especially when there are many similar test scenarios, resulting in a large amount of repetitive work. Second, different testers write scripts with inconsistent formats, and configuration parameters are often hard-coded into the scripts, increasing the difficulty of script maintenance. Third, the pairing of test cases and configuration files relies on manual management, which can easily lead to path errors or confused correspondences. Fourth, the script execution logic lacks a unified standard, resulting in high costs for subsequent modifications and extensions.

[0003] Currently, although some tools attempt to simplify the test case generation process, most fail to achieve the integration of automatic file pairing and parsing, AI-driven structured generation, and non-overlay storage. Testers still need to invest a lot of time in format adjustment and file management, which is difficult to meet the needs of efficient and standardized testing. Therefore, improvements are needed. Summary of the Invention

[0004] The purpose of this invention is to provide an AI-assisted method for generating automated test cases for the same type of front-end, so as to solve the problems mentioned in the background art.

[0005] To achieve the above objectives, this invention provides the following technical solution: an AI-assisted method for generating automated front-end test cases of the same type, the specific steps of which are as follows: Step 1: Set up a standardized file directory to ensure that the .py test scripts and their dependent .yaml configuration files are matched in terms of filename and relative position, and that the .py files begin with "test_"; configure the common configuration file and AI parameter file in the .yaml file directory, where the AI ​​parameter file includes the API Key and API endpoint information; Step 2: Parse the target file, read the content of the target .py test script and the corresponding .yaml configuration file through a preset function to form the basic data for AI input; Step 3: Configure AI interface call parameters, extract configuration information from the AI ​​parameter file, and call the AI ​​interface of DeepSeek or ChatGPT; combine AI input content according to preset rules. The input content includes .py script content, .yaml configuration content, explanation of the functions of both, requirements for the correspondence between use cases and configuration, and generation format specifications. Step 4: Process the AI's returned results. Extract the .py code content and .yaml configuration content from the markdown blocks using a parsing function, and store them as corresponding variables. Step 5: Generate and store the target files. Convert the extracted content into .py and .yaml files with the "_generated" suffix, and store them in the same directory as the original files, ensuring that the newly generated files do not overwrite the original files. Step Six: Perform file verification to check the storage path, naming rules, correspondence between test cases and configurations, and the matching degree between test case types and targets of the new files. If the verification passes, the generation process is completed; if it fails, corrections are made.

[0006] Preferably, the standardized file directory in step one includes a root directory called test_project, and subordinate directories config, testcase, and utils. The config directory stores .yaml configuration files, common configuration files, and AI parameter files, and the testcase directory stores .py test scripts.

[0007] Preferably, the input to the preset function in step two is the relative path of the target .py test script, and the output is the relative path of the corresponding .yaml configuration file.

[0008] Preferably, the preset rules for AI input in step three include: specifying that the generated test cases must be consistent with the target .py script format, and outputting only one block of .py code content and one block of .yaml configuration content.

[0009] Preferably, the parsing function in step four extracts the target content by recognizing the separator of triple backticks, and distinguishes between .py code and .yaml configuration according to the content format.

[0010] Preferably, the verification in step six also includes verifying that each newly added test case in the generated .py file has a matching configuration entry in the corresponding .yaml file.

[0011] Preferably, when the verification in step six fails, a targeted manual correction method is used. If it is a format problem, the file format is manually adjusted; if it is a content problem, the file content is manually modified. After the correction is completed, the verification is re-executed.

[0012] Preferably, the format specifications of the .py test script in step one include: using the @pytest.mark.parametrize decorator to parameterize the reading of the .yaml configuration, including common operation steps and step-by-step page operations, and each operation is accompanied by detailed comments; the page operations include XPath or Element ID reading, clicking, input, drop-down selection, content reading, disabling status detection, file upload, and waiting operations.

[0013] Preferably, the format specification of the .yaml configuration file in step one includes: the first-level key is consistent with the test case name in the .py script, the second-level key is the operation set, the third-level key is the single-step operation target set, and the fourth-level key contains XPath and description fields, which correspond to the operation target element and operation description, respectively.

[0014] The beneficial effects of this invention are as follows: This method automatically generates similar test cases through an AI interface, coupled with automatic file matching and parsing, improving generation efficiency by over 70% and significantly reducing manual writing time. It also standardizes script and configuration file formats, avoiding hard-coding of configuration parameters and reducing maintenance and expansion costs. Generated files are stored in the original directory without overwriting, eliminating the need for path adjustments and simplifying file management. Relying on clear AI input rules and multi-dimensional validation, it ensures that generated test cases match target requirements and can be directly executed by the pytest framework, comprehensively improving generation quality and usability. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the overall process of the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] like Figure 1 As shown in the figure, this embodiment of the invention provides an AI-assisted method for generating similar front-end automated test cases. The specific steps are as follows: Step 1: Set up a standardized file directory to ensure that the .py test scripts and their dependent .yaml configuration files are matched in terms of filename and relative position, and that the .py files begin with "test_"; configure the common configuration file and AI parameter file in the .yaml file directory. The AI ​​parameter file includes the API Key and API endpoint information. Step 2: Parse the target file, read the content of the target .py test script and the corresponding .yaml configuration file through a preset function to form the basic data for AI input; Step 3: Configure AI interface call parameters, extract configuration information from the AI ​​parameter file, and call the AI ​​interface of DeepSeek or ChatGPT; combine AI input content according to preset rules. The input content includes .py script content, .yaml configuration content, explanation of the function of both, the correspondence between test cases and configuration, and the generation format specification. Step 4: Process the AI's returned results. Extract the .py code content and .yaml configuration content from the markdown blocks using a parsing function, and store them as corresponding variables. Step 5: Generate and store the target files. Convert the extracted content into .py and .yaml files with the "_generated" suffix, and store them in the same directory as the original files, ensuring that the newly generated files do not overwrite the original files. Step Six: Perform file verification to check the storage path, naming rules, correspondence between test cases and configurations, and the matching degree between test case types and targets of the new files. If the verification passes, the generation process is completed; if it fails, corrections are made.

[0018] Standardized directory and file pairing rules lay the foundation for process standardization, ensuring clear file associations and reducing team collaboration and maintenance costs. Structured extraction and rule-based combination of AI input data enable AI to accurately understand generation requirements, ensuring consistency between output content and target test cases. The parsing and storage mechanism accurately extracts effective information while avoiding overwriting original files through the "_generated" suffix, balancing security and traceability. Full-process verification controls multiple dimensions such as path, naming, and relationships, ultimately outputting compliant and usable test cases, reducing manual intervention costs. It also adapts to multiple models such as DeepSeek and ChatGPT, enhancing the method's versatility and scalability, and significantly improving the efficiency and quality of front-end automated testing.

[0019] In step one, the standardized file directory includes the test_project root directory, as well as the config, testcase, and utils directories. The config directory contains .yaml configuration files, common configuration files, and AI parameter files, while the testcase directory contains .py test scripts.

[0020] The config directory centrally manages configuration files, the testcase directory is dedicated to storing test scripts, and the utils directory contains utility resources. The clear division of responsibilities among the directories avoids cluttered files and significantly improves search and maintenance efficiency. At the same time, the unified directory structure conforms to the general specifications of front-end automated testing projects, lowers the threshold for team collaboration, and provides clear file path guidance for AI-assisted script generation, facilitating rapid integration and implementation.

[0021] In step two, the input to the preset function is the relative path of the target .py test script, and the output is the relative path of the corresponding .yaml configuration file.

[0022] Simply enter the path to the .py script to automatically generate the corresponding .yaml path, avoiding the tedious operation of manually searching and entering configuration paths, effectively reducing human error and significantly improving association efficiency.

[0023] The preset rules for AI input in step three include: the generated test cases must be consistent with the target .py script format, and only one .py code block and one .yaml configuration block will be output.

[0024] The test cases must be in the same format as the target .py script to directly match the project's existing specifications, reducing format adjustment costs and ensuring that the generated content can be quickly integrated into the existing testing framework, thus reducing the workload of manual correction. At the same time, limiting the output to only one .py code and one .yaml configuration file avoids redundant information generated by AI, making the output more focused on core requirements. This facilitates direct parsing and storage in subsequent automated processes, reduces the time spent on manually selecting effective content, and improves the accuracy and efficiency of AI-assisted generation.

[0025] In step four, the parsing function extracts the target content by recognizing the separator of triple backticks and distinguishes between .py code and .yaml configuration based on the content format.

[0026] Triple backticks are a common delimiter for code blocks. AI often uses them to wrap code when generating content, using them as a basis for identification to accurately locate target content, effectively eliminate redundant information such as explanatory text, and avoid parsing errors. At the same time, it automatically distinguishes between .py code and .yaml configuration based on content format, eliminating the need for manual classification, reducing operational errors, and ensuring that the two types of content can be accurately mapped to the testcase and config directories. This lays the foundation for subsequent automatic storage and integration into test projects. This approach adapts to common AI output formats, enhances the versatility of parsing functions, and improves the coherence and efficiency of the automation process.

[0027] The verification in step six also includes verifying that each newly added test case in the generated .py file has a matching configuration entry in the corresponding .yaml file.

[0028] By verifying the matching between newly added .py test cases and corresponding .yaml configuration entries, the problem of "test cases are defined but configurations are not synchronized" can be discovered in advance before testing, reducing the cost of troubleshooting errors in the subsequent execution phase, making up for possible oversights of AI, ensuring that the generated test cases can run normally based on the complete configuration, and improving the stability and reliability of automated testing.

[0029] In step six, if the verification fails, a targeted manual correction method is used. If it is a format problem, the file format is manually adjusted; if it is a content problem, the file content is manually modified. After the correction is completed, the verification is re-executed.

[0030] The advantage of this design is that it can accurately and efficiently solve verification problems, ensure the quality of test files, eliminate problems such as non-standard formats and mismatched content, and ensure that the final file not only conforms to the project format standards, but also achieves a strict correspondence between test cases and configurations. This approach flexibly makes up for the omissions in AI generation and parsing, improves the accuracy and stability of subsequent automated test execution, and at the same time keeps the correction process simple and controllable.

[0031] The format specifications for the .py test script in step one include: using the @pytest.mark.parametrize decorator to parameterize the .yaml configuration, including common operation steps and step-by-step page operations, with detailed comments for each step; page operations include reading XPath or Element ID, clicking, inputting, selecting from dropdown lists, reading content, disabling status detection, uploading files, and waiting operations.

[0032] Parameterized decorators are used to associate .yaml configurations, separating test data from scripts. This facilitates flexible expansion of test scenarios and reduces data maintenance costs. Common operations are separated from step-by-step page operations, reducing duplicate code and improving script reusability. Detailed comments enhance script readability, facilitating team collaboration and subsequent iterations. Covering various page operations such as XPath reading and clicks ensures that the scripts can handle common front-end interaction scenarios, improving the comprehensiveness of testing.

[0033] In step one, the format specifications of the .yaml configuration file include: the first-level key is consistent with the test case name in the .py script, the second-level key is the operation set, the third-level key is the single-step operation target set, and the fourth-level key contains the XPath and description fields, which correspond to the operation target element and operation description, respectively.

[0034] The first-level key matches the name of the .py test case, directly establishing a precise mapping between the script and the configuration, avoiding confusion in association; the hierarchical division from the second to the fourth level breaks down the operation into "set - single-step target - specific field", making the configuration logic clear, facilitating quick location of the XPath and description of the single-step operation, improving readability and maintenance efficiency, and helping AI understand.

[0035] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0036] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for AI-assisted generation of similar front-end automated test cases, characterized in that: The specific steps are as follows: Step 1: Set up a standardized file directory to ensure that the .py test scripts and their dependent .yaml configuration files are matched in terms of filename and relative position, and that the .py files begin with "test_"; configure the common configuration file and AI parameter file in the .yaml file directory, where the AI ​​parameter file includes the API Key and API endpoint information; Step 2: Parse the target file, read the content of the target .py test script and the corresponding .yaml configuration file through a preset function to form the basic data for AI input; Step 3: Configure AI interface call parameters, extract configuration information from the AI ​​parameter file, and call the AI ​​interface of DeepSeek or ChatGPT; combine AI input content according to preset rules. The input content includes .py script content, .yaml configuration content, explanation of the functions of both, requirements for the correspondence between use cases and configuration, and generation format specifications. Step 4: Process the AI's returned results. Extract the .py code content and .yaml configuration content from the markdown blocks using a parsing function, and store them as corresponding variables. Step 5: Generate and store the target files. Convert the extracted content into .py and .yaml files with the "_generated" suffix, store them in the same directory as the original files, and ensure that the newly generated files do not overwrite the original files. Step Six: Perform file verification to check the storage path, naming rules, correspondence between test cases and configurations, and the matching degree between test case types and targets of the new files. If the verification passes, the generation process is completed; if it fails, corrections are made.

2. The AI-assisted method for generating similar front-end automated test cases according to claim 1, characterized in that: The standardized file directory mentioned in step one includes the test_project root directory, and its subordinate config, testcase, and utils directories. The config directory stores .yaml configuration files, common configuration files, and AI parameter files, and the testcase directory stores .py test scripts.

3. The method for generating similar front-end automated test cases with AI assistance according to claim 1, characterized in that: The input to the preset function in step two is the relative path of the target .py test script, and the output is the relative path of the corresponding .yaml configuration file.

4. The method for generating similar front-end automated test cases with AI assistance according to claim 1, characterized in that: The preset rules for AI input in step three include: the generated test cases must be consistent with the target .py script format, and only one block of .py code content and one block of .yaml configuration content will be output.

5. The method for AI-assisted generation of similar front-end automated test cases according to claim 1, characterized in that: The parsing function described in step four extracts the target content by recognizing the separator of triple backticks, and distinguishes between .py code and .yaml configuration based on the content format.

6. The AI-assisted method for generating similar front-end automated test cases according to claim 1, characterized in that: The verification described in step six also includes verifying that each newly added test case in the generated .py file has a matching configuration entry in the corresponding .yaml file.

7. The method for AI-assisted generation of similar front-end automated test cases according to claim 1, characterized in that: If the verification in step six fails, a targeted manual correction method is used. If it is a format problem, the file format is manually adjusted; if it is a content problem, the file content is manually modified. After the correction is completed, the verification is re-executed.

8. The method for AI-assisted generation of similar front-end automated test cases according to claim 1, characterized in that: The format specifications of the .py test script mentioned in Step 1 include: using the @pytest.mark.parametrize decorator to parameterize the reading of the .yaml configuration, including common operation steps and step-by-step page operations, with detailed comments for each step; the page operations include reading XPath or Element ID, clicking, inputting, selecting from dropdown lists, reading content, disabling status detection, uploading files, and waiting operations.

9. The AI-assisted method for generating similar front-end automated test cases according to claim 1, characterized in that: The format specifications of the .yaml configuration file mentioned in step one include: the first-level key is consistent with the test case name in the .py script, the second-level key is the operation set, the third-level key is the single-step operation target set, and the fourth-level key contains the XPath and description fields, which correspond to the operation target element and operation description, respectively.