LLM-based natural language driven GUI test rehearsal and test script generation method

By using a natural language-driven approach based on LLM, GUI test pre-play and test script generation were achieved, solving the problems of low efficiency and cross-framework adaptation in traditional GUI testing, and improving the efficiency and accuracy of test automation.

CN120973696BActive Publication Date: 2026-03-27HANGZHOU INTERNATIONAL INNOVATION INSTITUTE OF BEIHANG UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Traditional GUI testing relies on manually writing test cases and automated scripts, which is inefficient, costly, and difficult to handle dynamic interface changes and cross-framework adaptation, lacking human-machine collaboration efficiency.

Method used

It adopts an LLM-based natural language-driven approach, generating test operation descriptions through interaction between the planning agent and testers. Combining the operation agent and the code generation agent, it realizes test pre-play and script generation. It adopts a dual-modal understanding of interface elements using text and vision, supports multi-framework adaptation, and ensures code quality through the MCP tool.

Benefits of technology

It lowers the technical barrier, enabling testers without a programming background to participate in automated design, reduces script maintenance costs, improves the adaptability of test operations and the reusability of test scripts, and ensures the accuracy and efficiency of the test process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973696B_ABST
    Figure CN120973696B_ABST
Patent Text Reader

Abstract

The application relates to the field of software engineering and discloses a natural language driven GUI test rehearsal and test script generation method based on an LLM, which comprises the following steps: S1: test operation design: a test personnel and a planning agent realize human-machine cyclic interaction, and convert a high-level test case described in natural language into a low-level and standardized test operation description; wherein the planning agent adopts a hybrid architecture based on retrieval enhancement generation, the test personnel reviews, adjusts and feeds back the test operation description, and the feedback information is stored in a context memory module of the planning agent as prior knowledge; S2: test automation rehearsal: an operation agent takes the test operation description generated in S1 as input. Through human-machine cyclic interaction between the planning agent and the test personnel, automatic conversion of a natural language test case into a standardized test operation is realized, so that a test personnel without a programming background can also participate in automatic test design.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software engineering, in particular to a natural language driven GUI test rehearsal and test script generation method based on LLM. BACKGROUND

[0002] With the continuous improvement of the complexity of software systems, as a key link to ensure software quality, GUI testing is facing the challenges of low efficiency and high cost. Traditional GUI testing mainly relies on manual writing of test cases and automation scripts, and the following technical pain points exist:

[0003] Conversion barrier from natural language to test script: Test personnel usually describe test requirements using natural language, but converting high-level natural language cases into machine executable test scripts requires professional programming knowledge, resulting in a collaboration gap between the test team and the development team.

[0004] Interface understanding and operation adaptation problem: GUI interface elements change frequently, and traditional automation tools rely on fixed element positioning methods, making it difficult to cope with interface reconstruction, cross-browser compatibility and other scenarios, resulting in a sharp increase in test script maintenance costs.

[0005] Test framework dependency and version adaptation problem: Different test frameworks (such as Selenium, Cypress, Playwright) have large differences in syntax specifications and APIs, making it difficult to reuse test scripts across frameworks, and framework version iterations often cause historical scripts to fail.

[0006] Low efficiency of human-machine collaboration: Existing automation testing tools lack effective human-machine interaction mechanisms, and test personnel cannot intuitively intervene in the test process, making it difficult to quickly correct deviations between test case design and actual execution. SUMMARY

[0007] To overcome the shortcomings of the prior art, the present application provides a natural language driven GUI test rehearsal and test script generation method based on LLM, which solves the problem of "traditional GUI testing mainly relies on manual writing of test cases and automation scripts, low efficiency and high cost".

[0008] To achieve the above purpose, the present application is implemented by the following technical scheme: a natural language driven GUI test rehearsal and test script generation method based on LLM, comprising the following steps:

[0009] S1: Test operation design: Test personnel and planning agent interact through human-computer cycle to convert high-level test cases described in natural language into low-level, standardized test operation descriptions; wherein the planning agent adopts a hybrid architecture based on retrieval enhancement generation, and the test personnel reviews, adjusts and feeds back the test operation descriptions, and the feedback information is stored in the context memory module of the planning agent as prior knowledge;

[0010] S2: Test automation rehearsal: The operation agent takes the test operation descriptions generated in S1 as input, performs test rehearsal on the system under test and generates test operation primitives; the operation agent uses text and visual dual modalities to understand interface elements, extracts HTML element visibility, operability, element size, spatial position and element type attributes at the text level, and uses set-of-mark technology to mark interface elements that are interactive and visible at the visual level, and realizes semantic alignment of text and visual features through unified element numbering; the operation agent adopts a strict operation type limitation mechanism, only supports click, drag, page jump, key, selection and input operations, and adopts a single-step execution strategy, re-evaluates the interface state of the system under test after each operation execution to deal with dynamic changes, and only generates test operation primitives in triple structure after successful operation execution;

[0011] S3: Test script generation: The code generation agent takes the test operation primitives generated in S2 and the test script requirements specified by the test personnel as input to generate executable test scripts; the code generation agent adopts a three-stage generation strategy, the first stage parses the test framework version, programming language, execution mode and other requirements specified by the test personnel, the second stage calls the fetch MCP service to obtain the official documents and API references of the specified test framework version through the model context protocol client, and the third stage accurately converts the triple structure of the test operation primitives into code statements supported by the target test framework; At the same time, the code generation agent ensures code quality from static analysis and dynamic execution analysis levels through a quality control mechanism based on deterministic agents, and automatically corrects potential problems.

[0012] Preferably, the test operation description in S1 is a low-level standardized natural language description of a single atomic operation in the test step, which explicitly includes action type, target component semantics, necessary parameters and description information.

[0013] Preferably, in S2, the operation agent and the system under test adopt a sequential interaction control mode, and the interaction process is: the operation agent first perceives the state of the system under test, which includes page URL, page title, page semantic information, then integrates the system state and test operation description to make operation decision and execute operation, and the system under test updates the state after operation execution, completing one interaction.

[0014] Preferably, the test operation primitives in S2 are machine executable metadata corresponding to the test operation descriptions, and the test operation primitives can adapt to different browser automation frameworks.

[0015] Preferably, the test script requirements specified by the tester in S3 include unit test framework selection, web automation framework selection and programming language selection, and the test script generated by the code generation agent contains test environment setup, test step implementation and resource cleanup code.

[0016] Preferably, in the semantic analysis process of the test case by the planning agent in S1, the business rules and constraints implied in the test steps can be understood in combination with the retrieved domain knowledge of the system under test.

[0017] Preferably, in S2, the operation agent simplifies the complex interface structure into a list of meaningful elements when processing.

[0018] Preferably, in S3, the code generation agent obtains the official documents and API references of the specified test framework version through the MCP tool, which serves as the knowledge base for code generation, ensuring that the generated test code meets the syntax specifications and best practices of the specific framework version, and the selection and version control of the framework are completely specified by the tester.

[0019] Preferably, the human-machine cycle interaction process in S1 supports the tester to adjust and optimize the test operation description sequence generated by the planning agent according to actual needs, or provide more detailed instructions and prompt information to the planning agent.

[0020] Preferably, the method is applied to the design, execution and test script generation of the automation test process of a Web system.

[0021] The present application provides a natural language driven GUI test rehearsal and test script generation method based on LLM. It has the following advantages:

[0022] 1. The present application realizes the automatic conversion of natural language test cases to standardized test operations through the human-machine cycle interaction between the planning agent and the tester, enabling non-programming background testers to participate in automation test design, significantly reducing the technical threshold.

[0023] 2. The present application adopts a text and visual dual-mode interface understanding mechanism, and realizes cross-modal semantic alignment by combining a unified element number, solving the limitations of traditional tools relying on single element positioning, making the test operation adaptable to interface dynamic changes and reducing script maintenance costs.

[0024] 3. This invention achieves the adaptation and conversion of the same test logic to different web automation frameworks (Selenium, Cypress, Playwright, etc.) by designing the intermediate layer of test operation primitives and leveraging the framework documentation retrieval capabilities of the MCP tool, thereby improving the reusability of test assets.

[0025] 4. This invention enables testers to intuitively intervene in each stage of the testing process through a visual review interface and an interactive correction mechanism, and to promptly correct decision-making biases of the agent, thus ensuring testing accuracy while maintaining automation efficiency. Attached Figure Description

[0026] Figure 1 This is the overall flowchart of the present invention.

[0027] Figure 2 This is a flowchart illustrating the collaboration between test personnel and the multi-agent system in this invention.

[0028] Figure 3 Flowchart of the test operation design for this invention

[0029] Figure 4 This is a flowchart of the automated test pre-test process for the present invention.

[0030] Figure 5 This is a flowchart illustrating the test script generation process for this invention.

[0031] Figure 6 This is a schematic diagram illustrating an example of generating a test script for the login function of a system according to the present invention. Detailed Implementation

[0032] The technical solutions in 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.

[0033] To facilitate the subsequent description of the specific content of this invention, the relevant technical terms used in the invention are explained below.

[0034] 1. Graphical User Interface (GUI) Testing: A testing method to verify whether the functionality, appearance, and interaction of a software interface meet requirements. It checks the correctness, layout rationality, response speed, and compatibility of interface elements by simulating user operations.

[0035] 2. Test script: A set of automated instructions or code used to simulate user interaction with the system under test. It is executed by automated tools to automatically check whether the functions, layout and response meet expectations.

[0036] 3. Large Language Models (LLMs): Deep learning models trained on vast amounts of data, excelling at understanding and generating natural language, widely used in tasks such as question answering, translation, and content creation.

[0037] 4. LLM Agent: An AI system with autonomous decision-making capabilities, combining LLMs with planning, memory, and tool invocation functions to perform complex tasks.

[0038] 5. Multi-Agent System: A distributed system composed of multiple autonomous agents that interact and collaborate to complete complex tasks.

[0039] 6. Human-in-the-loop (HITL): A workflow that combines human intelligence with automated systems (such as AI or multi-agent systems) through real-time supervision, intervention, or collaboration to optimize decision-making and improve system reliability and adaptability.

[0040] 7. Test Case: A validation scheme designed for specific functions or scenarios in software testing, explicitly describing preconditions, test steps, input data, and expected results to determine whether the system behaves as expected.

[0041] 8. Test Step: A specific sequence of operations performed in software testing to verify the expected behavior of the tested function, typically including input, operation, and expected result descriptions.

[0042] 9. Test Operation Description: A low-level, standardized natural language description of individual atomic operations in test steps, explicitly including action type, target component semantics, necessary parameters, and explanations.

[0043] Test Operation Primitives: Machine-executable metadata corresponding to test operation descriptions, including target component positioning information, operation type enumeration values, and optional parameter values.

[0044] The overall flow of the method is divided into three stages, as shown in Figure 1: In the test operation design stage, test cases are input, and test operation descriptions are output through human-in-the-loop (HITL) interaction. In the automated test rehearsal stage, the test operation descriptions from the previous stage are input, and operation primitives are output by testing the system with operation agents. In the test script generation stage, the operation primitives from the previous stage are input, and actual executable test scripts are output by code generation agents.

[0045] The specific collaboration details are shown in FIG. 2. The tester interacts with multiple agents to ultimately achieve the generation of the test script: interacts with the human-in-the-loop (HITL), cooperates to complete the design and confirmation of the test operation description, the pre-exploration of the web automation test, the output of the test operation primitives, and the generation of the test script.

[0046] Step 1, test operation design

[0047] In web GUI automation testing, testers usually need to write high-level test case descriptions to describe the user tasks or business goals that the tester needs to test for the system under test (see Table 1 for a system login function test case). However, in the face of abstract and general test case descriptions, large language models often cannot accurately understand, and hallucination problems often lead to low accuracy in test instruction implementation and conversion. In order to improve the accuracy of large language models in implementing instructions and improve the efficiency of automated execution, this method needs to convert high-level test case steps into low-level test operation descriptions for web pages. Testers interact with planning agents through human-in-the-loop (HITL) to gradually disassemble, correct, and generate test operation descriptions for test case steps described in natural language.

[0048] Table 1: A system login function test case example

[0049]

[0050] The specific process is shown in FIG. 3: taking the tester, planning agent, and operation agent as the main body, mainly including modeling the domain knowledge of the system under test, understanding the semantics of the test case, and interactive design of the test operation description.

[0051] In the modeling of the domain knowledge of the system under test, the planning agent takes the system manual, interface specification, and historical test data as input, uses a hybrid architecture based on retrieval-augmented generation (RAG), and stores and retrieves document information of the system under test through a vector database. After these documents are processed through semantic vectorization, the business concepts and operation methods in the system under test are understood, providing necessary domain knowledge support for understanding the system under test and providing a basis for accurate conversion of test cases to test operation descriptions. It can support the agent to perform efficient similarity retrieval.

[0052] In understanding the semantics of test cases, the planning agent first performs semantic analysis on the input test case, identifying key business concepts, operation objects, operation steps, and corresponding expected results. Through the enhanced retrieval generation method, the planning agent can understand the business rules and constraints implied in the test steps by combining the domain knowledge of the system under test. This deep understanding enables the agent to accurately grasp the test intent and lay the foundation for subsequent operation description generation.

[0053] In interactive test operation description design, to ensure the accuracy of the generated results, a human-computer cycle interactive confirmation mechanism is introduced. The agent, based on the semantic understanding of the system under test and the test case, decomposes and plans the test steps, generates a standardized sequence of test operation instructions, each instruction including precise positioning description of interface elements and corresponding operation parameters, and considers factors such as interface structure characteristics, operation sequence dependency relationships, and possible conditional branches. The agent combines semantic understanding and knowledge retrieval mechanism for operation description generation, and displays the action type and target element corresponding to each test operation through a visual interface for review and confirmation by the tester. The tester can adjust and optimize the operation description sequence according to actual needs, or provide more detailed instructions and prompt information to the agent to enhance the planning accuracy. The adjustment information and feedback results in the above interaction process will be written into the agent's context memory module as prior knowledge to support continuous planning and interactive confirmation in subsequent test steps. Through the above progressive quality optimization mechanism, accurate conversion of high-level test cases to low-level, executable test operation descriptions can be achieved, and the intelligent level and practical performance of test operation generation can be significantly improved.

[0054] Taking Table 1 as an example, after test operation design, the planning agent will generate a test operation description sequence as shown in Table 2, including steps such as accessing the system under test, inputting username and password, and clicking the login button. This conversion not only preserves the test intent, but also provides sufficient execution details, providing reliable input for subsequent automated test rehearsal.

[0055] Table 2 Example of test operation description sequence for login function of a certain system

[0056]

[0057] Step 2, test automation rehearsal

[0058] After the initial test operation description design, the generated test operation description can be used for the test flow requirements of subsequent iterations of the system under test, taking the test operation description as input information, the operation agent performs the pre-exploration of the system under test, and generates the test operation primitive sequence corresponding to the current round after each round of operation success. Therefore, it ensures the accurate execution and effective verification of each test step.

[0059] The specific process is shown in FIG. 4: the operation agent and the system under test adopt a sequential interaction control mode, the operation agent first perceives the state of the system under test (including page URL, page title, page semantic information), and integrates the system state with the test operation description, then makes operation decision and performs operation, and the system under test updates the state after execution, completing one interaction.

[0060] In the perception of the system under test and the understanding of the semantic of the page element, the operation agent adopts a text and visual dual-modal method to understand the interface element. At the text level, the present application extracts multi-dimensional features of HTML elements, including visibility, operability, element size, spatial position and element type, etc. At the visual level, the present application uses set-of-mark technology to mark the interface elements that can be interacted and visible, and realizes the semantic alignment of text features and visual features through unified element numbering. This dual-modal interface understanding method has the following advantages: first, by extracting the multi-dimensional features of HTML elements, the operable elements can be accurately identified and located; second, the visual marking technology can capture the visual features and spatial relationships of the elements; finally, the semantic alignment of text and visual features ensures the accuracy of operation decision. For complex interface structure, the present application simplifies the page into a list of meaningful elements, reducing the processing difficulty.

[0061] In decision making and operation execution, the operation agent adopts a strict operation type limiting mechanism to ensure the rationality of the generated operation decision. The basic operation types supported by the present application include click, dragdrop, goto, keypress, select and type, and the parameters thereof are abstracted. Through function calling and structured output, the present application ensures that only predefined operation types can be generated, improving the reliability of operation execution. In order to cope with the dynamic changes of the interface, the present application adopts a single-step execution strategy. The operation agent re-evaluates the interface state after each operation execution, and makes a decision for the next operation. This strategy ensures that the system under test can respond to the dynamic changes of the interface in time, improving the accuracy of test pre-exploration.

[0062] In operation primitive generation, the application first defines an operation primitive as a standardized description of successful operation execution, using a triple (locator, parameter, operation name) structure. The corresponding operation primitive is only generated after the operation is successfully executed by the system under test, ensuring the validity of the primitive. By abstracting the operation, the generated test operation primitive can be adapted to different browser automation frameworks, improving the portability of the test script. As shown in Table 3, each operation primitive contains complete execution information, providing reliable input for subsequent test script generation.

[0063] Table 3: Example of test operation primitive for a system login function

[0064]

[0065]

[0066] Step 3: Test script generation

[0067] After generating the operation primitive, the generated operation primitive can be converted for use in various browser automation frameworks (such as Selenium, Playwright, etc.). The test operation primitive is used as input information, and the code generation agent generates test scripts suitable for different test environments based on the specific requirements of the test script (such as unit test framework, web automation framework, programming language, etc.). Finally, the GUI test rehearsal and test script generation for natural language test cases are realized. Through strict code generation strategies and quality control mechanisms, the generated test scripts meet the requirements of specific test frameworks and maintain high code quality.

[0068] The specific process is shown in Figure 5: After accepting the operation primitive and user requirement input, the code generation agent selectively calls the MCP to obtain the relevant dependency documentation manual for the user's specific requirements for the test script. The code generation agent uses a three-stage generation strategy to ensure the accuracy and standardization of the test script. The first stage is requirement analysis, and the agent strictly follows the requirements specified by the test personnel, including version selection of the test framework, programming language preference, synchronous or asynchronous execution mode, and other technical specifications. The second stage is document retrieval, and the application obtains the official documentation and API reference for the specified test framework version through the MCP tool, providing accurate technical guidance for code generation. The third stage is code conversion, which accurately converts the triple (locator, parameter, operation name) in the test operation primitive into code statements supported by the target test framework.

[0069] This phased generation strategy has the following advantages: first, by strictly following user requirements, it ensures that the generated code meets project specifications; second, by document retrieval enhancement, it ensures that the code meets the syntax requirements of a specific framework version; and finally, by precise triple conversion, it ensures accurate implementation of test operations.

[0070] The code generation agent supports code generation for mainstream automated testing frameworks through a document retrieval mechanism. The invention achieves this by interfacing with the Model Context Protocol (MCP) client, using the fetch MCP service call to extract web content, and obtaining the corresponding version of the testing framework documents. These documents serve as the knowledge base for code generation, ensuring that the generated code meets the syntax specifications and best practices of the specific framework version. The choice and version control of the framework are entirely specified by the tester, and the agent strictly generates the corresponding test code based on the specified version of the framework document.

[0071] To ensure the quality of the generated code, the invention implements a quality control mechanism based on deterministic agents. This mechanism includes two levels: static analysis and dynamic execution analysis. At the static analysis level, the system systematically checks the code for syntax correctness, naming conventions, code structure, etc. At the dynamic execution analysis level, the invention can execute the test script with the authorization of the tester to verify its runtime behavior. When potential problems are found, the agent will attempt to automatically correct them. For problems that cannot be automatically corrected, the invention will request assistance from the tester.

[0072] It is particularly important to note that the test script generation of the invention only focuses on the implementation of test steps and does not involve the generation of test assertions. This design choice allows the invention to focus on improving the accuracy of operation sequence implementation, while leaving the verification logic of test results to the tester to define according to specific business requirements.

[0073] As shown in Figure 6, the generated test script contains complete test environment setup, test step implementation, and resource cleanup code. The script structure is clear, with complete comments, making it easy for testers to understand and maintain. In this way, the invention can convert test operation primitives into high-quality automated test scripts, providing a reliable code base for test execution. The generated syntax meets the requirements and is a runnable test script.

[0074] The invention adopts a multi-agent system architecture based on large language models, which decomposes complex GUI testing automation tasks into three core stages: test operation interaction design, automated test rehearsal, and test script generation. Each stage is handled by a dedicated agent, effectively reducing the complexity of the task through clear responsibility division and collaboration mechanisms. In particular, the invention has significant advantages in the following areas:

[0075] 1. By planning the RAG architecture of the agent, the deep semantic understanding of the test case is realized, and the accurate grasp of the test intention is ensured;

[0076] 2. With the help of the dual-modal understanding ability of the operation agent, the accuracy and robustness of the interface operation are improved;

[0077] 3. The three-stage generation strategy of the code generation agent is used to ensure the quality and framework adaptability of the test script.

[0078] The application improves the stability of the test script through the innovative interface element processing method:

[0079] 1. The interface understanding method of text and visual dual modal is adopted, and the semantic labeling and alignment of interface elements are realized through the set-of-mark technology;

[0080] 2. The multi-dimensional feature extraction of HTML elements is realized, including the comprehensive analysis of visibility, operability, element size, spatial position and other attributes;

[0081] 3. Through strict operation type limitation and single-step execution strategy, the problem of dynamic change of the interface is effectively solved;

[0082] This method based on semantic understanding has stronger adaptability than the traditional positioning method based on coordinates or XPath, and can maintain the effectiveness of the test script when the interface changes.

[0083] The application realizes significant optimization in resource utilization efficiency:

[0084] 1. Direct communication between agents is realized through function call mode, avoiding the complex communication protocol overhead;

[0085] 2. The deterministic agent design is adopted, and the code quality is ensured through static analysis and dynamic execution analysis, reducing the need for manual intervention;

[0086] 3. The test script generation is limited to the operation step implementation level, avoiding the complexity of test assertion generation;

[0087] In addition, the multi-agent cooperation mechanism of the application also has the following advantages:

[0088] 1. Through the explicit error handling mechanism, the controllability and reliability of the test process are realized;

[0089] 2. The quality control mechanism based on human-computer cycle ensures the accuracy and practicality of the generated results;

[0090] 3. Support for different test framework adaptation improves the universality and scalability of the system;

[0091] Through the comprehensive effect of the above technical effects, the GUI test automation efficiency and reliability are significantly improved, and an innovative solution is provided for test engineering practice.

[0092] Although the embodiments of the present application 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 thereto without departing from the principles and spirit of the present application, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for LLM-based natural language driven GUI test rehearsal and test script generation, characterized in that, Comprise the following steps: S1: test operation design: test personnel and planning agent through man-machine cycle interaction, convert high-level test case described in natural language into low-level, standardized test operation description; wherein, the planning agent adopts a hybrid architecture based on retrieval enhancement generation, the test personnel reviews, adjusts and feeds back the test operation description, and the feedback information is stored in the context memory module of the planning agent as prior knowledge; S2: test automation rehearsal: the operation agent takes the test operation description generated in S1 as input, performs test rehearsal on the system under test and generates test operation primitives; the operation agent understands interface elements in text and visual dual modalities, extracts HTML element visibility, operability, element size, spatial position and element type attributes at the text level, uses set-of-mark technology to mark interface elements that are interactive and visible at the visual level, and realizes semantic alignment of text and visual features through unified element numbering; the operation agent adopts a strict operation type limiting mechanism, only supports click, drag, page jump, key, selection and input type operations, and adopts a single-step execution strategy, re-evaluates the interface state of the system under test after each operation execution to respond to dynamic changes, and only generates test operation primitives in triple structure after successful operation execution; In the S2, the operation agent and the system under test adopt a sequential interaction control mode, and the interaction process is: the operation agent first perceives the state of the system under test, the state of the system under test includes page URL, page title, page semantic information, then integrates the system state with the test operation description to make operation decision and execute operation, the system under test updates the state after operation execution, and completes one interaction; S3: test script generation: the code generation agent takes the test operation primitives generated in S2 and the test script requirements specified by the test personnel as input, and generates executable test scripts; the code generation agent adopts a three-stage generation strategy, the first stage parses the test framework version, programming language and execution mode requirements specified by the test personnel, the second stage calls the fetch MCP service to obtain the official documents and API references of the specified test framework version through the model context protocol client, and the third stage accurately converts the triple structure of the test operation primitives into code statements supported by the target test framework; at the same time, the code generation agent ensures code quality from static analysis and dynamic execution analysis levels through the quality control mechanism based on deterministic agent, and automatically corrects potential problems; In the S3, the code generation agent obtains the official documents and API references of the specified test framework version through the MCP tool, which serves as the knowledge base for code generation, ensuring that the generated test code meets the syntax specifications and best practices of the specific framework version, and the selection and version control of the framework are completely specified by the test personnel.

2. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, The test operation description in S1 is a low-level standardized natural language description of a single atomic operation in the test step, which explicitly includes action type, target component semantics, necessary parameters and description information.

3. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, The test operation primitive in S2 is machine executable metadata corresponding to the test operation description, and the test operation primitive can adapt to different browser automation frameworks.

4. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, The test script requirements specified by the tester in S3 include unit test framework selection, web automation framework selection, and programming language selection, and the test script generated by the code generation agent includes test environment setting, test step implementation, and resource cleanup code.

5. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, In the semantic analysis process of the test case by the planning agent in S1, the business rules and constraints implied in the test steps can be understood in combination with the retrieved domain knowledge of the system under test.

6. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, In S2, the operation agent simplifies the complex interface structure into a list of meaningful elements when processing.

7. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, In the human-machine cycle interaction process in S1, the tester can adjust and optimize the test operation description sequence generated by the planning agent according to actual needs, or provide more detailed instructions and prompt information to the planning agent.

8. The LLM based natural language driven GUI test rehearsal and test script generation method of claim 1, wherein, The method is applied to the automatic test flow design, test execution, and test script generation of web systems.