Test script generation method and device, storage medium and program product

Through the AI ​​model-driven two-stage test script generation method, combined with operation documents and user interaction data to build a knowledge base, the problems of low efficiency and poor stability of existing E2E test script generation are solved, and efficient and stable test script generation and maintenance are achieved.

CN120723657AActive Publication Date: 2025-09-30ALIBABA CLOUD COMPUTING CO LTD

Patent Information

Application Number
CN202511212109.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-27
Publication Date
2025-09-30
Estimated Expiration
2045-08-27

AI Technical Summary

Technical Problem

The existing E2E test script generation method is inefficient and unstable, making it difficult to adapt to complex and changing application scenarios. The recording and playback method is affected by changes in page layout. Manual script writing requires a lot of manpower and has high maintenance costs.

Method used

An AI model driven by the first and second agents is used to build an element information knowledge base combined with operation documents and user interaction traffic data to achieve two-stage test script generation. Executable test scripts are generated by mapping interface elements with test cases described in natural language and operation description information.

Benefits of technology

It improves the generation efficiency and stability of test scripts, reduces the difficulty and cost of maintenance, ensures the consistency of test scripts with page content, and adapts to complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723657A_ABST
    Figure CN120723657A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a test script generation method and device, a storage medium and a program product. In the embodiment of the invention, the associated AI model is driven based on the first agent and the second agent, and on the basis of the operation document of the to-be-tested software and the flow data generated by the interaction operation between the user and the to-be-tested software, a two-stage test script generation scheme is realized, and the generation efficiency of the test script is improved. The element information knowledge base is constructed based on the flow data to assist the second agent in retrieval, so that the test steps of the test case generated based on the operation document can be mapped into the operation description information of the interface element, and the interface element is accurately positioned based on the operation description information; the content of the page on the to-be-tested software is kept consistent with the content written in the test script, and the stability of the test script is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a test case generation method, device, storage medium, and program product. Background Art

[0002] With the development of cloud computing technology, more and more cloud products have emerged. To verify the functional integrity and exception handling capabilities of these cloud products, it is necessary to conduct E2E (end-to-end) testing on these cloud products. Currently, E2E testing generates E2E test scripts based on recording and playback, or users manually write E2E test scripts based on testing requirements. Currently, test script generation is inefficient and suffers from poor stability. Summary of the Invention

[0003] Embodiments of the present application provide a test script generation method, device, storage medium, and program product to improve the generation efficiency and stability of test scripts.

[0004] An embodiment of the present application provides a test script generation method, which includes: obtaining an operation document of the software to be tested, the software to be tested includes function points, and the operation document includes functional description information and operation guidance information of the function points; using a first intelligent agent and its associated use case generation model to understand the content of the operation document to obtain key test information, and generating a test case described in natural language based on the key test information; using a second intelligent agent and its associated script generation model, combined with an element information knowledge base, to map the test steps in the test case to operation description information for the target interface elements, and generate an executable test script based on the target interface elements and their corresponding operation description information; the element information knowledge base is constructed based on traffic data generated by the user's interactive operations with the software to be tested, including a mapping relationship between the interface elements involved in the software to be tested and the operation description information.

[0005] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, the memory being used to store a computer program, and the processor being coupled to the memory and being used to execute the computer program to implement the steps in any one of the test script generation methods.

[0006] An embodiment of the present application also provides a computer-readable storage medium storing a computer program / instruction. When the computer program / instruction is executed by a processor, the processor is enabled to implement the steps in any one of the test script generation methods.

[0007] An embodiment of the present application also provides a computer program product, which includes: a computer program / instructions, which, when executed by a processor, enables the processor to implement the steps in any one of the test script generation methods.

[0008] The embodiment of the present application is based on an AI model driven by a first agent and a second agent, and based on the operation documents of the software to be tested and the traffic data generated by the user's interactive operation with the software to be tested, a two-stage test script generation scheme is implemented to improve the efficiency of test script generation. In addition, an element information knowledge base is constructed based on the traffic data to assist the second agent in retrieval, so that the test steps of the test case generated based on the operation document can be mapped to the operation description information of the interface element, thereby accurately locating the interface element based on the operation description information, ensuring that the content of the page on the software to be tested is consistent with the content written in the test script, which is conducive to improving the stability of the test script. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A schematic structural diagram of a first system for implementing a test script generation method provided by an exemplary embodiment of the present application; Figure 2 A flowchart of a test script generation method provided by another exemplary embodiment of the present application; Figure 3 A schematic diagram of the architecture of a first agent provided in another exemplary embodiment of the present application; Figure 4 A schematic diagram of the architecture of a second agent provided in another exemplary embodiment of the present application; Figure 5 A schematic diagram of an architecture for constructing an element information knowledge base provided by another exemplary embodiment of the present application; Figure 6 A schematic structural diagram of a testing device provided as another exemplary embodiment of the present application. DETAILED DESCRIPTION

[0010] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0011] It should be noted that when the embodiments of this application involve user information, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation portals for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) are in compliance with relevant laws and standards.

[0012] In addition, it should be noted that when the embodiments of the present application involve user interaction operations or triggering operations, the user interaction operations or triggering operations involved in the embodiments of the present application include but are not limited to: touch operations, gesture operations, voice operations, head movement operations, eye movement operations and other interactive operations in various ways; among which, touch operations include but are not limited to: click operations, double-click operations, long press operations, sliding operations, pinch operations or mouse hover operations, etc. Sliding operations include but are not limited to: straight sliding, curved sliding, etc.

[0013] This article uses cloud products as an example to illustrate E2E testing, but this is not limited to cloud products. Cloud products primarily refer to various cloud computing-based products offered by cloud vendors, which provide users with computing, storage, network, and other resources. Cloud products are deployed in complex distributed environments and rely on technologies such as networking, virtualization, and multi-tenancy. This architecture makes them susceptible to uncertainties such as network latency and hardware failures. Therefore, E2E testing of cloud products is essential to verify their functional integrity and exception handling capabilities, ensuring they can provide stable and efficient services in real-world environments.

[0014] In E2E testing, a common test script generation method is based on recording and playback. This method typically uses a large visual model to take screenshots of the page, identify the text and coordinates of the interface elements in the image, and then generate an executable test script based on these coordinates. Because this method relies on image parsing and obtains the actual display positions of interface elements on the page, the coordinates of interface elements may be affected by changes in the page layout. For example, when the page is scaled, the resolution is adjusted, or displayed on different devices, the layout may change, rendering the coordinates originally obtained during recording invalid. In other words, a test script generated for one page layout may not accurately locate interface elements when applied to a second page layout. Therefore, page layout changes in this method can lead to inaccurate positioning of interface elements, resulting in low test script stability. Furthermore, screenshot resolution is affected by factors such as the display's DPI (Dots Per Inch), browser zoom ratio, and device pixel ratio. Low-resolution screenshots can lead to inaccurate text recognition and affect the determination of interface element coordinates. Screenshots also have other limitations. For example, they can be incomplete, potentially missing some interface elements. When multiple controls with identical text content exist on a page, it's difficult to distinguish the operating object based solely on the text. For these reasons, test scripts generated using recording and playback methods suffer from poor stability, high maintenance costs, and a low cost-to-performance ratio, making them difficult to adapt to complex and changing application scenarios.

[0015] Another way to generate test scripts is for users to manually write E2E test scripts based on test requirements. In this approach, each test script must be written from scratch, covering every aspect, including page navigation, element positioning, user operations, and assertion logic, requiring a significant investment of human resources. Furthermore, manually writing test scripts has a long development cycle and is difficult to quickly respond to frequently changing application requirements. Once a test script is written, any changes to the page structure and interface elements may render the existing element positioning logic ineffective, leading to test execution failure and poor script stability. When test scripts need to be maintained or modified, manual adjustments are often required, resulting in high maintenance costs and low efficiency. Therefore, manually writing E2E test scripts presents challenges such as low generation efficiency, poor stability, high labor costs, and difficulty in maintenance.

[0016] The following embodiment of the present application provides a test script generation method, in which a two-stage test script generation scheme is implemented based on an AI model driven by a first agent and a second agent, and based on the operation documents of the software to be tested and the traffic data generated by the user's interactive operation with the software to be tested, thereby improving the generation efficiency of the test script. In addition, an element information knowledge base is constructed based on the traffic data to assist the second agent in retrieval, so that the test steps of the test case generated based on the operation document can be mapped to the operation description information of the interface element, thereby accurately locating the interface element based on the operation description information, and ensuring that the content of the page on the software to be tested is consistent with the content written in the test script, which is conducive to improving the stability of the test script. Furthermore, due to the high stability of the test script, the maintenance difficulty and cost can be reduced.

[0017] The following is combined with Figures 1-6 , detailing the technical solutions provided by various embodiments of this application. This solution can be implemented by a first system 10, which can be an artificial intelligence system including a first agent and a second agent, and can also include a knowledge base for implementing enhanced retrieval, namely, an element information knowledge base. For an introduction to the first agent, the second agent, and the element information knowledge base, please refer to the subsequent embodiments.

[0018] Figure 2 A flow chart of a test script generation method provided by an exemplary embodiment of the present application. Figure 2 As shown, the method includes: S1. Obtain the operation document of the software to be tested. The software to be tested includes functional points, and the operation document includes functional description information and operation guidance information of the functional points.

[0019] S2. Utilize the first agent and its associated use case generation model to understand the content of the operation document to obtain key test information, and generate a test case described in natural language based on the key test information.

[0020] S3. Utilize the second intelligent agent and its associated script generation model, combined with the element information knowledge base, to map the test steps in the test case into operation description information for the target interface elements, and generate an executable test script based on the target interface elements and their corresponding operation description information.

[0021] Among them, the element information knowledge base is constructed based on the traffic data generated by the interaction between the user and the software to be tested, including the mapping relationship between the interface elements involved in the software to be tested and the operation description information.

[0022] Software under test refers to the object being tested. It can be software programs for cloud products or services developed based on cloud computing technology, or it can be traditional software programs. For example, software under test can include various database services, application programming interface (API) gateways, load balancing services, World Wide Web (Web) applications, Web services, and other software products provided as services.

[0023] The software to be tested includes one or more function points. Function points refer to the functions that the software to be tested can achieve. Function points can be understood as the expected functions. For example, if the software to be tested is instant messaging software, function points may include chat, file transfer, emoticon packs, etc.; for another example, if the software to be tested is shopping software, function points may include support for favorites, displaying product details pages, payment functions, etc. If the software to be tested is cloud server service software, function points may include creating instances, deleting instances, purchasing instances, selling instances, binding instances, or managing instances.

[0024] The above functional points will be implemented during the operation of the software to be tested. Furthermore, during the operation of the software to be tested, it supports interaction with the user, such as receiving user interactive operations and outputting response results to the user after responding to the interactive operations. Users can interact with the software to be tested through various methods such as keyboard, mouse, touch screen, voice, etc. The interactive behavior can be clicking buttons, text input, sliding the screen, jumping pages, voice control, etc. For example, in the implementation process of displaying the product details page, the software to be tested receives the user's click on the product image or name. Each functional point corresponds to the event processing logic. There may be dependencies between different functional points.

[0025] In order to perform E2E testing on the software under test, in the embodiment of the present application, a test script can be generated for the software under test. In the embodiment of the present application, the test script corresponding to the software under test is generated based on the operation documents of the software under test and the traffic data generated by the user's interaction with the software under test. To this end, the operation documents of the software under test can be obtained.

[0026] The operation document is a file provided to users for them to understand the software to be tested, and records the introduction information, usage methods, etc. of the software to be tested. In an embodiment of the present application, the operation document includes functional description information and operation guide information of the functional points involved in the software to be tested. The functional description information is a summary of "what" the functional point is, including but not limited to the purpose and function of the functional point. Exemplarily, the functional description information corresponding to the creation instance function point can be to create a new instance in the software to be tested. The operation guide information refers to the content of how to use the function point, including but not limited to the prerequisites, operation steps, precautions, expected results, etc. on which the use of the function point depends. Among them, the prerequisites are the conditions that must be met before executing the function point, the operation steps are the steps required to use the function point, precautions refer to the matters that need to be paid attention to when using the function point, and the expected results refer to the status or feedback information that should be presented after executing the function point. Exemplarily, the operation guidance information corresponding to the create instance function point includes: the prerequisite is that the user has logged in to the cloud platform console and has the permission to create resources; the operation steps are to enter the cloud server instance management page; click the create instance button; select the region, availability zone, image, instance specifications, and storage configuration in turn; set up the network and security group; configure the login credentials; confirm the configuration and fee, click buy now and complete the payment; the note is that the region cannot be changed after the instance is created; the expected result is that the instance status is displayed as running, and can be viewed and managed in the instance list.

[0027] This application does not limit the method of obtaining the operating documents of the software to be tested. The operating documents of the software to be tested can be obtained from the official document platform of the software to be tested, or from a document collaboration platform. To implement step S1, an acquisition module 300 can be deployed in the first system.

[0028] After obtaining the operation document of the software to be tested, the first intelligent agent and its associated use case generation model are used to understand the content of the operation document to obtain key test information, and a test case described in natural language is generated based on the key test information.

[0029] The first intelligent agent is an autonomous entity capable of perceiving its environment and making decisions. It can be implemented as a software program, robot, or virtual assistant. It can interact with the first system to drive the use case generation model to generate test cases. Optionally, the first intelligent agent can optimize the use case generation model based on feedback from executing the test cases, thereby improving the accuracy of the test cases.

[0030] The use case generation model is a model based on artificial intelligence (AI). For example, the use case generation model can be a large model with a relatively large parameter scale, such as a large language model with content understanding and generation capabilities. Further optionally, the use case generation model can also be a large language model that supports multimodality, has deep semantic understanding and generation capabilities across modalities and languages, and can better generate test cases described in natural language based on operation documents. In the process of generating test cases, natural language processing can be used to generate test cases described in natural language. The large language model can be a large language model with an encoder-decoder structure, a large language model with an encoder-only structure, a large language model with a decoder-only structure, a self-developed large language model, or a large language model with other architectures that may appear in the future.

[0031] Key test information refers to the key information relied upon for testing the software under test. Key test information includes test steps, which are semantic steps for using the software under test and are used to guide the test script on how to operate the software under test. Optionally, the content of the operation document is understood to obtain key test information, including: understanding the functional description information and operation guidance information of the function point in the operation document to obtain key test information for the function point. Different function points may correspond to different key test information.

[0032] Furthermore, the key test information may also include any one or more of the following information: use case name, function description, test title, precondition, expected result, test type and test priority. Among them, the use case name refers to the unique identification name of the test case. Function description refers to the function description information of the function points involved in the test case. The test title refers to the general content of the test case, and the purpose of the test case can be identified by the test case. Precondition refers to the conditions that must be met before executing the test case. Predicted result refers to the status or feedback information that should be presented after executing the test case. Test type refers to the test category to which the test case belongs. Test types include but are not limited to functional testing, regression testing, boundary value testing, exception testing, etc. Different types of tests focus on different dimensions of information of the software to be tested. Test priority indicates the importance of the test case and can be used to indicate the execution order of the test cases.

[0033] A test case is a natural language description designed to verify the functional points of the software to be tested. For example, it can verify whether the functionality of the functional point is complete or whether there are any anomalies. For a functional point, different test cases can be generated by the user performing different interactive operations with it. For example, for the function of adding a product, the test steps of test case 1 are: the user selects the product specifications, enters the quantity, and clicks the "Add to Cart" button; the test steps of test case 2 are: the user does not select the color or size, and directly clicks "Add to Cart". Optionally, for a functional point, test cases corresponding to normal input operations, boundary value input operations, and abnormal input operations can be generated for it to fully verify the correctness, stability, and fault tolerance of the functional point.

[0034] After obtaining the test case, the second intelligent agent and its associated script generation model are used, combined with the element information knowledge base, to map the test steps in the test case into operation description information for the target interface elements, and generate an executable test script based on the target interface elements and their corresponding operation description information.

[0035] The second agent can refer to the description of the first agent, and similarities are not repeated here. The second agent can interact with the first system to drive the script generation model to generate a test script. Optionally, the second agent can optimize the script generation model based on the feedback from executing the test script, thereby improving the accuracy of the test script.

[0036] The script generation model is used to generate test scripts based on test cases. It converts natural language into code descriptions. Similar to the use case generation model, the script generation model is also AI-based and can be a variety of large language models. I won't elaborate on this here.

[0037] A test script is a program code described in a programming language that is used to automatically perform end-to-end testing on the software being tested. In the embodiments of the present application, the programming language used by the test script is not limited and can be flexibly determined based on the programming language used by the software being tested and the test requirements. For example, it can be a programming language such as Java, C, Python, etc. Regardless of the programming language, the second agent-driven script generation model in the embodiments of the present application can generate a test script in the corresponding programming language.

[0038] The element information knowledge base is constructed based on the traffic data generated by user interactions with the software under test. By analyzing this traffic data, we can obtain the corresponding operation description information of the user's interaction with the software under test. Operation description information can refer to the semantic description of the content involved in the user's interaction with the software under test, including but not limited to the operation instruction, operation type, the identification of the interface element operated, and the logical location of the interface element within the corresponding page.

[0039] Operation instructions refer to operation instructions initiated by users to the software under test during its use, such as "click the login button" or "swipe up the page." These operation instructions can be obtained through event monitoring of the software under test, including but not limited to JavaScript event monitoring, automatic collection using the Software Development Kit (SDK), and plug-in monitoring. For the purpose of explanation, before testing the software under test, a trial version of the software under test can be released to external users. During the external users' use of the trial version, traffic data generated by their interactions with the trial version can be collected. External users are an example of the aforementioned users, which is a broad term encompassing all types of users who interact with the software under test. Alternatively, before conducting E2E testing of the software under test, a test version can be released to internal testers. During the testers' use of the test version, traffic data generated by their interactions with the test version can be collected. Similarly, testers are an example of the aforementioned users.

[0040] The identifier of an interface element refers to the identification information of the interface element operated by the user. The identifier of the interface element can be obtained based on the attribute information in the Hypertext Markup Language (HTML) tag corresponding to the interface element; it can also be obtained based on the attribute information of the operation control corresponding to the interface element; it can also be obtained based on the text keyword corresponding to the interface element, such as the buttons displayed on the interface as "Confirm", "Login", "Submit", "Cancel", etc. The same interface element identifier may exist on the same page, but the corresponding logical location information is different. The unique interface element is located based on the logical location information.

[0041] The logical location information of an interface element refers to the path of the interface element within the page and is used to locate the interface element within the page. This logical location information can be obtained by parsing the structure tree of the page to which the interface element is being operated. This structure tree can be implemented as a Document Object Model (DOM). The path generated after parsing the structure tree serves as the logical location information. The generated path can be implemented as an XML Path Language (XPath) or Cascading Style Sheets (CSS) path.

[0042] XPath not only describes the location of UI elements in the DOM tree, but also combines information such as UI element attributes and text content to construct matching conditions for fuzzy matching to locate UI elements. Although XPath can locate UI elements, it does not directly reflect the visual position of the UI element on the device display.

[0043] The embodiments of the present application do not limit the implementation method of the XPath path. In one implementation method, a complete path from the root node of the page to the interface element operated by the user is constructed as an XPath path based on the hierarchical relationship to reflect the nested structure of the elements. For example, XPath: / html / body / div[2] / ul / li[3], this path indicates starting from the root node, entering <body>, its second child node, and then entering the list therein, and finally locating the third element. In another implementation method, the XPath path of the interface element is constructed based on attribute information, for example, XPath: / / input[@id='username'], this path indicates matching all input boxes with the id of username from the DOM tree. In yet another implementation method, the XPath path of the interface element is constructed in combination with the hierarchical relationship and attribute information, for example, / / div[@class='menu'] / ul / li / a[text()='Home'] means searching for a link element with the text content of "Home" in the ul list within the div with the class of menu.

[0044] The logical location information obtained based on the XPath path can be divided into two categories. One is the static path, that is, its location information is unchanged relative to the page, which is referred to as the absolute path. This path starts from the root node of the page and determines each step of the path to the interface element operated by the user. The other is the dynamic path, that is, relative to the page, its location information changes with the changes of the page, which is referred to as the relative path. This path is obtained based on the relative position and structural relationship between the interface elements. It does not rely on the complete hierarchical path starting from the root node, but is based on the current context node or the stable and unchanging interface element in the page. The position of the interface element operated by the user is inferred through logical relationships. Preferably, the logical location information is dynamic, and the interface elements can be accurately located even when the interface structure changes.

[0045] The CSS path includes one or more declarations, each of which consists of attributes and values, defining the style of the selected interface element. The logical position information obtained based on the CSS path is a dynamic relative path. For example, the CSS path is: div.next-col>div.sls-easyRegionPicker-easyregionpicker>div.sls-easyRegionPicker-base-btn>span.sls-easyRegionPicker-input>input. This path means finding a div with the next-col class in the page, and one of its direct child elements is a div with the sls-easyRegionPicker-easyregionpicker class. Under this div is a div with the sls-easyRegionPicker-base-btn class, which has a span with the sls-easyRegionPicker-input class inside it, and the direct child element of this span is an <input> input box.

[0046] The logical location information of each interface element belongs to either a static path or a dynamic path. However, for the entire page, it is possible that all interface elements in the page are static paths, or all interface elements in the page are dynamic paths, or some interface elements are static paths and some interface elements are dynamic paths.

[0047] After obtaining the operation description information, a one-to-one mapping relationship is constructed between the operation description information obtained based on the user traffic data and the interface elements involved in the software to be tested, and the information is stored in the element information knowledge base. According to the target interface elements and their corresponding operation description information stored in the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface elements, and an executable test script is generated based on the target interface elements and their corresponding operation description information. A test step will operate on an interface element. For the sake of ease of description, the interface element that the test step needs to operate is called the target interface element. Different test steps may operate on different target interface elements, or different test steps may also operate on the same target interface element. It depends on whether the different functional points provided by the software to be tested are associated with the same interface element, and the specific test requirements. There is no limitation on this. The operation description information of each test step on the target interface element is used to describe the operation type of the test step on the target interface element, the operation instructions associated with the operation type, the identification of the target interface element, the logical location information of the target interface element on the page to which it belongs, etc.

[0048] Test cases and test scripts correspond one to one. The process of generating an executable test script based on the target interface elements and their corresponding operation description information is the process of converting natural language description information into executable code, so that the generated test script can be understood and executed by the machine. For example, the operation instruction "click" in the operation description information is converted into the ".click()" function call at the code level; for another example, the operation instruction "select the region" in the operation description information is converted into the code: page.locator('div.next-col> div.sls-easyRegionPicker-easyregionpicker>div.sls-easyRegionPicker-base-btn>span.sls-easyRegionPicker-input>input').click(); for another example, the operation instruction "experience board" in the operation description information is converted into the code: ##name:clickon a:experience board#target: / html / body / div[2] / div[2] / div[1] / div / ul / ul / li[2] / div / span / a.

[0049] The following describes in detail the test script generation method provided by the embodiment of the present application in conjunction with the detailed implementation process of the first agent. This embodiment includes the following steps: S21. Obtain the operation documentation of the software to be tested.

[0050] S22. Input the operation document into the first intelligent agent, generate a first prompt word based on the operation document, and the first prompt word is used to guide the use case generation model to convert the operation document into a test case described in natural language in the role of the first test engineer; call the use case generation model according to the first prompt word, and under the guidance of the first prompt word, understand the content of the operation document in the role of the first test engineer to obtain key test information, and generate a test case described in natural language based on the key test information.

[0051] S23. Utilize the second intelligent agent and its associated script generation model, combined with the element information knowledge base, to map the test steps in the test case into operation description information for the target interface elements, and generate an executable test script based on the target interface elements and their corresponding operation description information.

[0052] The first prompt is constructed based on the role of the first test engineer and is used to guide the use case generation model to convert the operation document into a test case described in natural language, using the role of the first test engineer. This can be understood as endowing the use case generation model with professional capabilities similar to those of the first test engineer, enabling it to simulate the first test engineer's thought processes and job responsibilities to convert the operation document into a test case. This includes understanding the operation document to obtain the various contents of the key test information and generating test cases based on the key test information. Through role-based prompts, the use case generation model can not only understand the explicit information in the operation document, but also combine it with test expertise for reasoning and generalization, generating higher-quality test cases and improving the accuracy of test cases.

[0053] In an optional implementation, to implement the method of the embodiment of the present application, construct Figure 3 As shown in the first agent architecture, the first agent 100 may include a first access module 100A, a first prompt word generation module 100B, a first calling module 100C and a use case generation model 100D.

[0054] The first access module 100A is configured to receive the operation document of the software to be tested and send the operation document to the first prompt word generation module 100B. The first prompt word generation module 100B is configured to generate a first prompt word based on the operation document and send the first prompt word to the first calling module 100C. The first calling module 100C is configured to call the use case generation model 100D based on the first prompt word. Under the guidance of the first prompt word, the first calling module 100C interprets the content of the operation document in the role of a first test engineer to obtain key test information and generates a test case described in natural language based on the key test information. It should be noted that this structure is merely an example and is not limited to this. Any other intelligent agent structure that can be reasonably modified based on this structure is within the scope of protection of this application.

[0055] In the embodiments of the present application, the method for generating the first prompt word is not limited. In one optional implementation, generating the first prompt word based on the operation document includes: embedding the operation document into the first input prompt word of a first prompt word template to obtain the first prompt word. The first prompt word template includes a first input prompt word, which is a blank prompt word used to carry the operation document. In addition, the first prompt word template also includes: a first role prompt word, a content understanding prompt word, and a use case generation prompt word, which are prompt words for existing content. The role prompt word is used to define the use case generation model's role as a first test engineer; the content understanding prompt word is used to guide the use case generation model to conduct a multi-dimensional content understanding of the first input prompt word; and the use case generation prompt word is used to guide the use case generation model to generate a test case described in natural language based on the content understanding results of the content understanding prompt word. By constructing the first role prompt word, content understanding prompt word, and use case generation prompt word in the first prompt word template, the use case generation model can be guided in a step-by-step manner, which facilitates the use case generation model's logical reasoning and improves the accuracy of test case generation.

[0056] The first prompt word template is used to guide the use case generation model in understanding the operational documentation of the software under test. The first input prompt word refers to the content to be filled in the first prompt word template. The first prompt word refers to the input information formed by the use case generation model after the operational documentation is embedded in the first prompt word template.

[0057] Multi-dimensional content understanding refers to understanding the content according to the various dimensions in the generated test key information. For example, if the use case name and function description are used as the test key information, the multi-dimensionality refers to the use case name dimension and the function description dimension. The content understanding prompt words guide the use case generation model to understand the content of the use case name dimension and the function description dimension for the first input prompt word.

[0058] A first prompt word template can be pre-maintained, and based on this template, test cases can be generated from any operational document of the software under test. Different operational documents may correspond to different software under test, and different operational documents can generate different first prompt words based on the first prompt word template, and different first prompt words can generate different test cases. The first role prompt words, content comprehension prompt words, and use case generation prompt words may also vary depending on the input operational document.

[0059] In an optional implementation, before embedding the operation document into the first input prompt word of the first prompt word template, the method also includes: combining the text keywords of at least one interface element recorded in the element information knowledge base, and performing text correction on the text description involving the interface element in the operation document.

[0060] The text keywords of an interface element refer to the key text content involved in the interface element, and are important semantic information for identifying the interface element. Text keywords include but are not limited to text content, prompt information, etc. on the associated operation controls. For example, the text description of the interface element in the operation document is "OK", and the text keyword corresponding to the interface element recorded in the element information knowledge base is "Confirm", then the text description in the operation document is corrected based on the text keyword, that is, "OK" is changed to "Confirm", so as to adapt to the element information knowledge base, so that the information obtained based on the understanding of the operation document is consistent with the actual result presented on the page. It avoids errors in test cases in the process of generating test scripts due to text inconsistencies, improves the accuracy of converting operation documents into test cases, and thus generates test scripts more stably.

[0061] In this implementation, the first agent may further include a correction module, which is used to implement the aforementioned text correction method.

[0062] In an optional implementation, under the guidance of a first prompt word, the content of the operation document is understood in the role of a first test engineer to obtain key test information, and a test case described in natural language is generated based on the key test information, including: parsing the first prompt word to obtain a first input prompt word, a first role prompt word, a content understanding prompt word and a use case generation prompt word, the first input prompt word includes the operation document; under the guidance of the first role prompt word and the content understanding prompt word, in the role of a first test engineer, a multi-dimensional content understanding of the operation document is performed to obtain key test information; under the guidance of the use case generation prompt word, a test case described in natural language is generated based on the key test information.

[0063] The present embodiments do not limit the construction of the first input prompt, first role prompt, content comprehension prompt, and use case generation prompt. Taking the construction of a use case generation prompt as an example, the use case generation prompt can consist of a task description and an output structure. The task description can be "Generate a complete test case based on the key test information," and the output structure can be "Requirements include the use case name, function description, preconditions, test steps, and expected results." Based on this, the resulting use case generation prompt can be "Please generate a complete test case based on the following key test information. Requirements include: test title, preconditions, operation steps, and expected results. Ensure clear language and logical integrity." Constraints can also be added to the use case generation prompt, such as requiring each operation step to be independent, single, and executable, and requiring that the expected result correspond to each operation step one-to-one, ensuring that each step has clear and observable feedback. The use case generation prompt can also include other content, which will not be illustrated here. Similarly, the first input prompt, first role prompt, and content comprehension prompt can also be constructed based on specific task requirements. Different constructed prompts may also generate different test cases.

[0064] In an optional implementation, the first agent can optimize the current first prompt word based on the feedback result of the current test case generated by the use case generation model using the current first prompt word; call the use case generation model again based on the optimized first prompt word to generate a new test case and receive the feedback result of the new test case, through multiple iterations, until the test case obtained by the optimized first prompt word meets the preset conditions. The feedback result of the test case can be determined by the executableness of the generated test script, the accuracy of the assertion, the stability of the positioning of the interface elements, etc. The optimization of the first prompt word can be achieved by supplementing the context information, adjusting the instruction expression, etc. In the process of optimizing the first prompt word, one or more prompt words among the first input prompt word, the first role prompt word, the content understanding prompt word or the use case generation prompt word can be adjusted.

[0065] In an optional implementation, the content understanding prompt words prompt multiple dimensions of content understanding including: use case name dimension, function description dimension, operation step dimension, precondition dimension and expected result dimension.

[0066] Under the guidance of the first role prompt and the content understanding prompt, the user, in the role of the first test engineer, conducts a multi-dimensional content understanding of the operation document to obtain key test information. This includes: under the guidance of the first role prompt, the user, in the role of the first test engineer, conducts a multi-dimensional content understanding of the operation document from the dimensions of use case name, function description, operation steps, preconditions, and expected results, respectively, to obtain the use case name, function description, operation steps, preconditions, and expected results corresponding to the function point as key test information. This guides the use case generation model to gain a more comprehensive understanding of the operation document from multiple dimensions, further improving the accuracy of the use case generation model's understanding.

[0067] Among them, the use case name dimension is used to guide the use case generation model to understand the use case name of the first input prompt word; the function description dimension is used to guide the use case generation model to understand the function point description information of the first input prompt word; the operation step dimension is used to guide the use case generation model to understand the operation steps required for the function point of the first input prompt word; the precondition dimension is used to guide the use case generation model to understand the precondition required for the function point of the first input prompt word; the expected result dimension is used to guide the use case generation model to understand the result that should be obtained after the first input prompt word executes the function point.

[0068] In one optional implementation, under the guidance of a use case generation prompt, a test case described in natural language is generated based on key test information. This includes: under the guidance of the use case generation prompt, the use case generation model semantically associates and contextually supplements the extracted key test information, and generates a test case based on the associated and supplemented key test information. For example, if the test step in the key test information includes "click the login button," the use case generation model may associate it with the semantic content "if the information is correct, the page should be redirected after clicking."

[0069] In the embodiments of the present application, there is no limitation on the underlying model architecture adopted by the use case generation model. The use case generation model can be an encoder-only architecture, a decoder-only architecture, or a combined encoder and decoder architecture.

[0070] Based on the underlying model architecture, a functional architecture can be constructed for the use case generation model. In an embodiment of the present application, the functional architecture of the use case generation model includes a first parsing layer, a content understanding layer, and a first generation layer.

[0071] The first parsing layer parses the first prompt to obtain the first input prompt, the first role prompt, the content understanding prompt, and the use case generation prompt. The first input prompt includes the operation document. The content understanding layer, guided by the first role prompt and the content understanding prompt, performs a multi-dimensional understanding of the operation document in the role of the first test engineer to obtain key test information. The first generation layer, guided by the use case generation prompt, generates a test case described in natural language based on the key test information.

[0072] Furthermore, the content understanding layer is also used to: under the guidance of the first role prompt word, in the role of the first test engineer, perform multi-dimensional content understanding of the operation document from the dimensions of use case name, function description, operation steps, prerequisites and expected results, so as to obtain the use case name, function description, test steps, prerequisites and expected results corresponding to the function point as the key test information.

[0073] The test script generation method provided by the embodiment of the present application is described in detail below in conjunction with the detailed implementation process of the second agent. In this embodiment, the detailed implementation process of the first agent can be found in the above embodiment and will not be repeated in this embodiment. This embodiment includes the following steps: S31. Obtain the operation documentation of the software to be tested.

[0074] S32. Utilize the first agent and its associated use case generation model to understand the content of the operation document to obtain key test information, and generate a test case described in natural language based on the key test information, wherein the test case includes test steps.

[0075] S33. Input the test case into the second intelligent agent, generate a second prompt word according to the test case, and the second prompt word is used to guide the script generation model to convert the test case into an executable test script in the role of the second test engineer; call the script generation model according to the second prompt word, and under the guidance of the second prompt word, combine the element information knowledge base to map the test steps in the test case to the operation description information of the target interface element, and generate an executable test script according to the target interface element and its corresponding operation description information.

[0076] The second prompt word is constructed based on the role of the second test engineer, and is used to guide the script generation model to convert the test case into an executable test script in the role of the second test engineer. It can be understood as giving the script generation model a professional ability similar to that of the second test engineer based on the second prompt word, so that it can simulate the thinking process and work responsibilities of the second test engineer to convert the test case into a test script, including mapping the test steps in the test case to the operation description information of the target interface element, and generating an executable test script according to the target interface element and its corresponding operation description information. Through the role-based prompt, the script generation model can not only understand the explicit information in the test case, but also reason and generalize in combination with the test expertise, generate higher quality test scripts, and improve the accuracy of the test script. The second test engineer can be the same as the second test engineer in Example 1, or different. Preferably, the first test engineer is an experienced test engineer, and the second test engineer is a professional automation test engineer.

[0077] In an optional implementation, to implement the method of the embodiment of the present application, construct Figure 4 As shown in the schematic diagram of the second agent architecture, the second agent 200 includes a second access module 200A, a second prompt word generation module 200B, a second calling module 200C and a script generation model 200D.

[0078] The second access module 200A is used to receive test cases for the software to be tested and send the test cases to the second prompt word generation module 200B. The second prompt word generation module 200B is used to generate a second prompt word based on the test case and send the second prompt word to the second calling module 200C. The second calling module 200C is used to call the script generation model 200D based on the second prompt word. Under the guidance of the second prompt word, combined with the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface element, and an executable test script is generated based on the target interface element and its corresponding operation description information. It should be noted that this structure is only an example and is not limited to this. Any other intelligent agent structure that can be reasonably transformed on this basis is within the scope of protection of this application.

[0079] In one optional implementation, generating a second prompt based on a test case includes embedding the test case into a second input prompt of a second prompt template to obtain the second prompt. The second prompt template includes a second input prompt, which is a blank prompt used to carry the test case. In addition, the second prompt template also includes a second role prompt, a positioning prompt, and a script generation prompt, each of which is a prompt with existing content. The second role prompt is used to define the script generation model's role as a second test engineer; the positioning prompt is used to guide the script generation model to locate interface elements and operational behaviors based on the second input prompt in conjunction with an element information knowledge base; and the script generation prompt is used to guide the script generation model to generate an executable test script based on the positioning prompt's results. By constructing the second role prompt, positioning prompt, and script generation prompt in the second prompt template, the script generation model can be guided step by step in its thinking, facilitating logical reasoning and improving the accuracy of test script generation.

[0080] The second prompt word template is used to guide the script generation model in understanding the test case of the software to be tested. The second input prompt word refers to the content to be filled in the second prompt word template. The second prompt word refers to the text information to be input into the script generation model after the test case is embedded in the second prompt word template.

[0081] A pre-maintained second prompt word template can be used to generate a test script for any test case of the software under test. Different operation cases can generate different second prompt words based on the second prompt word template, and different second prompt words can generate different test scripts. The second role prompt word, positioning prompt word, and script generation prompt word may also vary depending on the test case.

[0082] In an optional embodiment, under the guidance of the second prompt word, combined with the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface element, and an executable test script is generated based on the target interface element and its corresponding operation description information, including: parsing the second prompt word to obtain a second input prompt word, a second role prompt word, a positioning prompt word and a script generation prompt word, the second input prompt word includes a test case; under the guidance of the second role prompt word and the positioning prompt word, in the role of the second test engineer, combined with the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface element; under the guidance of the script generation prompt word, an executable test script is generated based on the target interface element and its corresponding operation description information.

[0083] The present embodiments do not limit the construction of the second input prompt, second role prompt, positioning prompt, and script generation prompt. Taking the construction of the script generation prompt as an example, the script generation prompt can consist of a task description, a target language, an input specification, and an output structure. The task description specifies the test script generation requirement, the target language specifies the programming language used to output the test script, the input specification describes the format of the target interface elements and operation descriptions, and the output structure specifies the code structure. For example, the script generation prompt may be: "You are an automated test engineer. Please generate an automated test script written in Python and Selenium based on the following target interface elements and user operation descriptions. Requirements: Use a specific browser; correspond to one line of code for each operation; add an explicit wait for each operation to ensure that the target interface element is interactive; use the operation description to locate the target interface element; and do not generate redundant logic beyond assertions." The script generation prompt may also include other content, which will not be illustrated here. Similarly, the second input prompt, second role prompt, and positioning prompt can also be constructed based on specific task requirements. Different constructed prompts may also generate different test scripts.

[0084] In an optional implementation, the second agent can optimize the current second prompt word based on the feedback result of the current test script generated by the script generation model using the current second prompt word; based on the optimized second prompt word, the script generation model is called again to generate a new test script and receive the feedback result of the new test script, through multiple iterations, until the test script obtained by the optimized second prompt word meets the preset conditions. In particular, the execution effect of the test script can be determined by the executability of the test script, the accuracy of the assertion, the stability of the positioning of the interface elements, etc., depending on the execution effect type of the test case. In the process of optimizing the second prompt word, one or more prompt words among the second input prompt word, the second role prompt word, the positioning prompt word and the script generation prompt word can be adjusted.

[0085] In an optional embodiment, in the role of a second test engineer, in combination with an element information knowledge base, the test steps in the test case are mapped to operational description information for the target interface element, including: in the role of a second test engineer, the test steps in the test case are parsed to obtain operational behavior information of the test steps on the target interface element described in natural language; based on the text keywords and / or operational context information of at least one interface element recorded in the element information knowledge base, the operational behavior information of the test steps on the target interface element described in natural language is converted into the identification and operation instructions of the target interface element; based on the identification of the target interface element, a match is performed in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical location information of the target interface element on the target page; and the identification, operation instructions and logical location information of the target interface element are used as the operational description information of the target interface element. In this embodiment, the operation description information includes the target interface element's identifier, operation instructions, and logical location information. Based on the identifier, it is possible to determine which target interface element to operate on; based on the operation instructions, it is possible to determine how to operate the target interface element; and based on the logical location information, it is possible to locate the target interface element. Therefore, using the identifier, operation instructions, and logical location information as the operation description information to generate a test script enables the machine to accurately perform operations on the pages of the software under test. During this process, the unique identifier, operation instructions, and logical location information of the target interface element can be quickly found using text keywords and / or operation context information in the element information knowledge base, thereby improving the efficiency of generating test scripts.

[0086] The structure of a page is the hierarchical structure generated by the HTML document and its parsing, representing all the interface elements on the page and their relationships. The structure of a page can be static or dynamic, depending on the page structure.

[0087] In the embodiment of the present application, the underlying model architecture used by the script generation model is not limited. The script generation model can be an encoder-only architecture, a decoder-only architecture, or a combined encoder and decoder architecture. The script generation model and the use case generation model can use the same underlying model architecture or different underlying model architectures. Based on the underlying model architecture, a functional architecture can be constructed for the script generation model. In the embodiment of the present application, the functional architecture of the use case generation model includes a second parsing layer, a mapping layer, and a second generation layer.

[0088] The second parsing layer parses the second prompt to obtain the second input prompt, the second role prompt, the positioning prompt, and the script generation prompt. The mapping layer, guided by the second role prompt and the positioning prompt, maps the test steps in the test case into operational descriptions for the target interface elements in the role of the second test engineer, in conjunction with the element information knowledge base. The second generation layer, guided by the script generation prompt, generates an executable test script based on the target interface elements and their corresponding operational descriptions.

[0089] Furthermore, the mapping layer is also used to: in the role of a second test engineer, parse the test steps in the test case to obtain the operational behavior information of the test steps on the target interface element described in natural language; convert the operational behavior information of the test steps on the target interface element described in natural language into the identification and operation instructions of the target interface element according to the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base; based on the identification of the target interface element, match in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical location information of the target interface element on the target page; use the identification, operation instructions and logical location information of the target interface element as the operation description information of the target interface element.

[0090] The embodiment of the present application does not limit the construction process of the element information knowledge base. In an optional implementation method, the interactive operations between the user and the software to be tested can be monitored, which can be understood as monitoring events corresponding to the operations, referred to as monitoring events. When an interactive operation is monitored, the flow data generated by the interactive operation between the user and the software to be tested is recorded (referred to as data collection operation), and the operation instructions and the interface element information operated by the operation instructions are extracted from the flow data. The operation instructions and the interface element information operated by the operation instructions are processed to construct an element information knowledge base.

[0091] In the embodiments of this application, Figure 5 As shown, the first system may include a monitoring service 400 and a knowledge base processing module 500, and the monitoring service 400 and the knowledge base processing module 500 cooperate with each other to build an element information knowledge base.

[0092] The monitoring service 400 is used to record the flow data generated by the user's interactive operation with the software to be tested, and to extract the operation instructions and the interface element information operated by the operation instructions from the flow data.

[0093] The knowledge base processing module 500 is used to obtain operation instructions and information of interface elements operated by the operation instructions; process the operation instructions and information of interface elements operated by the operation instructions to obtain operation description information to construct an element information knowledge base.

[0094] In an optional implementation, operation instructions and information about the interface elements operated by the operation instructions are extracted from traffic data, including: constructing a user session based on the traffic data; analyzing the user session to obtain operation instructions and information about the interface elements operated by the operation instructions. The user session is used to record and integrate continuous interactive operations of the same user within a certain time period. A user session may start with the user logging in or the first request for an operation, and end with the user's logout operation or no interactive operation within a preset time period. A user session may also correspond to an interactive operation performed by the user on a page. The construction method of the user session is not limited here. Optionally, the operation instructions and information about the interface elements operated by the operation instructions are written to a log, for example, a Simple Log Service (SLS).

[0095] In an optional implementation, the information of the interface element operated by the operation instruction may include the operation instruction, the identifier of the interface element operated by the operation instruction, and a structure tree of the page to which the interface element operated by the operation instruction belongs.

[0096] In an optional implementation, Figure 5 As shown, processing the operation instructions and the interface element information manipulated by the operation instructions to obtain the operation description information includes: preprocessing the multiple operation instructions and the interface element information manipulated by the operation instructions. Preprocessing the multiple operation description information to obtain the operation description information includes but is not limited to a cleaning operation, which includes identifying and correcting abnormal data in the multiple operation description information and removing duplicate data in the multiple operation description information.

[0097] In an optional implementation, Figure 5 As shown, after pre-processing, operation context information is added to the interface element operated by the operation instruction to obtain operation description information. The operation context information can be obtained based on the user session.

[0098] In an optional implementation, Figure 5As shown, after adding operation context information to the interface element operated by the operation instruction, an enhanced search operation can be performed to obtain the operation description information. In one implementation method, the text keywords of the interface element operated by the operation instruction can be extracted (referred to as data slicing operation), and the text keywords are associated with the corresponding operation description information and stored in the element information knowledge base. Each operation description information is stored as an information in the element information knowledge base, and the text keyword can be used as a retrieval index for the corresponding operation description information. The same text keyword can correspond to multiple operation description information. When using the element information knowledge base, the operation description information corresponding to the text keyword can be filtered out first, and then the operation description information obtained by filtering can be searched. By establishing an index with text keywords, relevant content can be quickly retrieved.

[0099] Preferably, the test script generation method also includes: using a monitoring service to record the traffic data generated by the user's interactive operation with the software to be tested; extracting the operation instructions, the identifier of the interface element operated by the operation instructions, and the structure tree of the page to which the interface element operated by the operation instructions belongs from the traffic data; extracting the text keywords of the interface element operated by the operation instructions, and adding operation context information for the interface element operated by the operation instructions; storing the operation instructions, the identifier of the interface element operated by the operation instructions, the text keywords and the operation context information, and the structure tree of the page to which the interface element operated by the operation instructions belongs in the element information knowledge base. In this embodiment, the element information knowledge base stores the operation instructions, the identifier of the interface element operated by the operation instructions, the text keywords and the operation context information, which can not only improve the retrieval efficiency by using keywords or context information as indexes, but also improve the accuracy of retrieval by matching multiple dimensional information, thereby improving the accuracy of test script generation.

[0100] The constructed element information knowledge base can be used to match text keywords to input information, recall the matched operation description information and configure it in the script generation method process, evaluate the matching results, and re-retrieve based on the evaluation results.

[0101] In an embodiment of the present application, the element information knowledge base can be dynamically updated as the user uses the software. During user use, the page of the software under test may change, and the content of the element information knowledge base will change accordingly. The test script will also be adjusted to follow the changes in the element information knowledge base, ensuring that the test script remains consistent with the page of the software under test, thereby improving the stability of the test script.

[0102] In an optional implementation, the method further includes: monitoring whether the element information knowledge base has changed; and when changes are detected in the element information knowledge base and the changed information in the element information knowledge base is related to the test script, repairing or updating the test script according to the changed information.

[0103] For example, the content of the element information knowledge base is as follows: Test script 1 is obtained based on interface element 1 and its corresponding operation description information, test script 2 is obtained based on interface element 2 and its corresponding operation description information, and test script 3 is obtained based on interface element 1 and its corresponding operation description information and interface element 2 and its corresponding operation description information in the element information knowledge base.

[0104] Assuming that the logical location information XPath1 corresponding to the interface element 1 in the element information knowledge base changes, and the changed information is XPath3, it is determined that the test script 1 and the test script 3 are affected, and the test script 1 and the test script 3 are modified according to the changed logical location information XPath3.

[0105] In an optional embodiment, before generating a test script, the first and second agents can be pre-trained based on traffic data generated by user interactions with the software under test to ensure coverage of the functional points in the operational documentation of the software under test. Generating a test script for the software under test based on the trained first and second agents allows for immediate access to the logical location information corresponding to interface elements, improving test script generation efficiency and test accuracy.

[0106] In an optional embodiment, the logical position information in the element information knowledge base may be classified and stored, the dynamic logical position information may be used to generate an executable test script, and the static logical position information may be used for text matching training.

[0107] In an optional embodiment, after the test case is generated, the account information may be injected into the test case, and a test script may be generated based on the test case injected with the account information.

[0108] In this method, after obtaining the test script, the execution process of the test script may include: locating the target interface element based on the identification and logical position information of the target interface element in the operation description information; and operating the target interface element based on the operation instructions in the operation description information.

[0109] The aforementioned embodiments can be used in any combination, and the technical solutions after any combination still fall within the protection scope of this application.

[0110] It should be noted that the execution entity of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution entity of steps S1 to S3 can be device A; for another example, the execution entity of steps S1 and S2 can be device A, and the execution entity of step S3 can be device B; and so on.

[0111] In addition, some of the processes described in the above embodiments and the accompanying drawings include multiple operations that appear in a specific order, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The sequence numbers of the operations, such as S1, S2, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence, nor do they limit "first" and "second" to be different types.

[0112] Figure 6 This is a schematic diagram of the structure of a test device provided in an embodiment of the present application. Figure 6 As shown, in practice, the test device includes: a memory 54 and a processor 55 .

[0113] The memory 54 is used to store computer programs and may be configured to store various other data to support operations on the test device. Examples of such data include instructions for any application or method operating on the test device, data structures, contact data, phone book data, messages, images, videos, etc.

[0114] The processor 55 is coupled to the memory 54 and is used to execute the computer program in the memory 54, so as to: obtain the operation document of the software to be tested, the software to be tested includes function points, and the operation document includes functional description information and operation guide information of the function points; use the first intelligent agent and its associated use case generation model to understand the content of the operation document to obtain key test information, and generate a test case described in natural language based on the key test information; use the second intelligent agent and its associated script generation model, combined with the element information knowledge base, to map the test steps in the test case into operation description information for the target interface element, and generate an executable test script according to the target interface element and its corresponding operation description information; the element information knowledge base is constructed based on the traffic data generated by the user's interactive operations with the software to be tested, including the mapping relationship between the interface elements involved in the software to be tested and the operation description information.

[0115] In an optional embodiment, a first intelligent agent and its associated use case generation model are used to understand the content of an operation document to obtain key test information, and a test case described in natural language is generated based on the key test information, including: inputting the operation document into the first intelligent agent, generating a first prompt word based on the operation document, the first prompt word being used to guide the use case generation model to convert the operation document into a test case described in natural language in the role of a first test engineer; calling the use case generation model based on the first prompt word, and under the guidance of the first prompt word, understanding the content of the operation document in the role of a first test engineer to obtain key test information, and generating a test case described in natural language based on the key test information.

[0116] In an optional embodiment, generating a first prompt word based on an operation document includes: embedding the operation document into a first input prompt word of a first prompt word template to obtain the first prompt word; the first prompt word template also includes: a first role prompt word, a content understanding prompt word and a use case generation prompt word; the role prompt word is used to limit the use case generation model to play the role of a first test engineer; the content understanding prompt word is used to guide the use case generation model to perform multi-dimensional content understanding of the first input prompt word; the use case generation prompt word is used to guide the use case generation model to generate a test case described in natural language based on the content understanding result of the content understanding prompt word.

[0117] In an optional embodiment, before embedding the operation document into the first input prompt word of the first prompt word template, the processor 55 is also used to: combine the text keywords of at least one interface element recorded in the element information knowledge base to perform text correction on the text description involving the interface element in the operation document.

[0118] In an optional embodiment, under the guidance of a first prompt word, the content of the operation document is understood in the role of a first test engineer to obtain key test information, and a test case described in natural language is generated based on the key test information, including: parsing the first prompt word to obtain a first input prompt word, a first role prompt word, a content understanding prompt word and a use case generation prompt word, the first input prompt word includes the operation document; under the guidance of the first role prompt word and the content understanding prompt word, in the role of the first test engineer, a multi-dimensional content understanding of the operation document is performed to obtain key test information; under the guidance of the use case generation prompt word, a test case described in natural language is generated based on the key test information.

[0119] In an optional embodiment, the content understanding prompt words prompt multiple dimensions of content understanding including: use case name dimension, function description dimension, operation step dimension, prerequisite dimension and expected result dimension; under the guidance of the first role prompt words and the content understanding prompt words, in the role of the first test engineer, the multi-dimensional content understanding of the operation document is performed to obtain key test information, including: under the guidance of the first role prompt words, in the role of the first test engineer, the multi-dimensional content understanding of the operation document is performed from the use case name dimension, function description dimension, operation step dimension, prerequisite dimension and expected result dimension respectively, to obtain the use case name, function description, test steps, prerequisites and expected results corresponding to the function point as key test information.

[0120] In an optional embodiment, a second intelligent agent and its associated script generation model are used, combined with an element information knowledge base, to map the test steps in the test case to operation description information for the target interface element, and generate an executable test script based on the target interface element and its corresponding operation description information, including: inputting the test case into the second intelligent agent, generating a second prompt word based on the test case, the second prompt word being used to guide the script generation model to convert the test case into an executable test script in the role of a second test engineer; calling the script generation model based on the second prompt word, and under the guidance of the second prompt word, combined with the element information knowledge base, mapping the test steps in the test case to operation description information for the target interface element, and generating an executable test script based on the target interface element and its corresponding operation description information.

[0121] In an optional embodiment, generating a second prompt word based on a test case includes: embedding the test case into the second input prompt word of the second prompt word template to obtain the second prompt word; the second prompt word template also includes: a second role prompt word, a positioning prompt word and a script generation prompt word; the second role prompt word is used to limit the script generation model to play the role of a second test engineer; the positioning prompt word is used to guide the script generation model to locate the interface elements and operation behaviors of the second input prompt word in combination with the element information knowledge base; the script generation prompt word is used to guide the script generation model to generate an executable test script based on the positioning result of the positioning prompt word.

[0122] In an optional embodiment, under the guidance of the second prompt word, combined with the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface element, and an executable test script is generated based on the target interface element and its corresponding operation description information, including: parsing the second prompt word to obtain a second input prompt word, a second role prompt word, a positioning prompt word and a script generation prompt word, the second input prompt word includes a test case; under the guidance of the second role prompt word and the positioning prompt word, in the role of the second test engineer, combined with the element information knowledge base, the test steps in the test case are mapped to the operation description information of the target interface element; under the guidance of the script generation prompt word, an executable test script is generated based on the target interface element and its corresponding operation description information.

[0123] In an optional embodiment, in the role of a second test engineer, in combination with an element information knowledge base, the test steps in the test case are mapped to operational description information for the target interface element, including: in the role of a second test engineer, the test steps in the test case are parsed to obtain operational behavior information of the test steps on the target interface element described in natural language; based on the text keywords and / or operational context information of at least one interface element recorded in the element information knowledge base, the operational behavior information of the test steps on the target interface element described in natural language is converted into the identification and operation instructions of the target interface element; based on the identification of the target interface element, a match is performed in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical location information of the target interface element on the target page; and the identification, operation instructions and logical location information of the target interface element are used as the operational description information of the target interface element.

[0124] In an optional embodiment, the processor 55 is also used to: use a monitoring service to record traffic data generated by user interactions with the software to be tested; extract operation instructions, identifiers of interface elements operated by the operation instructions, and a structure tree of the page to which the interface elements operated by the operation instructions belong from the traffic data; extract text keywords of the interface elements operated by the operation instructions, and add operation context information to the interface elements operated by the operation instructions; store the operation instructions, identifiers, text keywords and operation context information of the interface elements operated by the operation instructions, and the structure tree of the page to which the interface elements operated by the operation instructions belong in the element information knowledge base.

[0125] In an optional embodiment, the processor 55 is also used to: monitor whether the element information knowledge base has changed; when it is monitored that the element information knowledge base has changed, and the changed information in the element information knowledge base is related to the test script, repair or update the test script according to the changed information.

[0126] Further, if Figure 6 As shown, the test equipment also includes: a communication component 56, a display 57, a power component 58, an audio component 59 and other components. Figure 6 Only some components are shown schematically, which does not mean that the test equipment only includes Figure 6 In addition, Figure 6 The components in the dotted box are optional components, not mandatory components, and the specific components depend on the product form of the working node. The working node of this embodiment can be implemented as a terminal device such as a desktop computer, laptop computer, smart phone or IOT device, or a server device such as a conventional server, cloud server or server array. If the working node of this embodiment is implemented as a terminal device such as a desktop computer, laptop computer, smart phone, etc., it can include Figure 6 If the working node of this embodiment is implemented as a server device such as a conventional server, a cloud server or a server array, it may not include Figure 6 Components within the dotted box.

[0127] The detailed implementation and beneficial effects of each step in this embodiment have been described in detail in the aforementioned embodiments and will not be elaborated here.

[0128] The above-mentioned memory can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0129] The communication component is configured to facilitate wired or wireless communication between the device in which the communication component resides and other devices. The device in which the communication component resides can access a wireless network based on a communication standard, such as a 2G, 3G, 4G / LTE, 5G, or other mobile communication network, or a combination thereof. In an exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.

[0130] The display includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, it may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensors can detect not only the boundaries of a touch or slide action, but also the duration and pressure associated with the touch or slide operation.

[0131] The power supply assembly provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.

[0132] The above-mentioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC). When the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive external audio signals. The received audio signal can be further stored in the memory or sent via the communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0133] Accordingly, an embodiment of the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the above method embodiment. The computer-readable storage medium includes volatile or non-volatile or a combination thereof, and may be removable or non-removable. Examples of computer-readable storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic cassette, tape disk storage or other magnetic storage device or any other non-transmission medium. Accordingly, an embodiment of the present application further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the processor is enabled to implement the steps in the above-mentioned method embodiment. It should be understood that each process or a combination of multiple processes in the above-mentioned method flow can be implemented by a computer program or instruction. In addition, these computer programs or instructions can be applied to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device, so that the processor of the general-purpose computer, the special-purpose computer, the embedded processor or other programmable data processing device can be implemented as a device for implementing the corresponding functions in the above-mentioned method embodiment.

[0134] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0135] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A test script generation method, characterized in that: include: Obtaining an operation document of the software to be tested, wherein the software to be tested includes function points, and the operation document includes function description information and operation guide information of the function points; Using the first agent and its associated use case generation model, the operation document is understood to obtain key test information, and a test case described in a natural language is generated based on the key test information; Utilizing the second agent and its associated script generation model, combined with the element information knowledge base, the test steps in the test case are mapped into operation description information for the target interface element, and an executable test script is generated according to the target interface element and its corresponding operation description information; The element information knowledge base is constructed based on traffic data generated by the user's interactive operations with the software to be tested, and includes a mapping relationship between the interface elements involved in the software to be tested and the operation description information.

2. The method according to claim 1, characterized in that Using the first agent and its associated use case generation model, the operation document is understood to obtain key test information, and a test case described in a natural language is generated based on the key test information, including: Inputting the operation document into the first agent, generating a first prompt word based on the operation document, wherein the first prompt word is used to guide the use case generation model to convert the operation document into a test case described in natural language in the role of a first test engineer; The use case generation model is called according to the first prompt word. Under the guidance of the first prompt word, the content of the operation document is understood in the role of the first test engineer to obtain key test information, and a test case described in natural language is generated based on the key test information.

3. The method according to claim 2, characterized in that Generating a first prompt word according to the operation document includes: Embedding the operation document into the first input prompt word of the first prompt word template to obtain the first prompt word; The first prompt word template also includes: a first role prompt word, a content understanding prompt word and a use case generation prompt word; the role prompt word is used to limit the use case generation model to play the role of a first test engineer; the content understanding prompt word is used to guide the use case generation model to perform multi-dimensional content understanding of the first input prompt word; the use case generation prompt word is used to guide the use case generation model to generate a test case described in natural language based on the content understanding result of the content understanding prompt word.

4. The method according to claim 3, characterized in that Before embedding the operation document into the first input prompt word of the first prompt word template, the method further includes: In combination with the text keywords of at least one interface element recorded in the element information knowledge base, text correction is performed on the text description related to the interface element in the operation document.

5. The method according to claim 2, characterized in that Under the guidance of the first prompt word, the first test engineer interprets the content of the operation document to obtain key test information, and generates a test case described in natural language based on the key test information, including: Parsing the first prompt word to obtain a first input prompt word, a first role prompt word, a content understanding prompt word, and a use case generation prompt word, wherein the first input prompt word includes the operation document; Under the guidance of the first role prompt word and the content understanding prompt word, the user, in the role of the first test engineer, performs a multi-dimensional content understanding of the operation document to obtain the key test information; Under the guidance of the use case generation prompt words, a test case described in natural language is generated based on the key test information.

6. The method according to claim 5, characterized in that The content comprehension prompt words prompt multiple dimensions of content comprehension including: use case name dimension, function description dimension, operation step dimension, precondition dimension and expected result dimension; Under the guidance of the first role prompt and the content understanding prompt, the first test engineer performs a multi-dimensional content understanding of the operation document in the role of the first test engineer to obtain the key test information, including: Under the guidance of the first role prompt word, in the role of the first test engineer, the operation document is understood in multiple dimensions from the dimensions of the use case name, function description, operation steps, prerequisites and expected results, so as to obtain the use case name, function description, test steps, prerequisites and expected results corresponding to the function point as the key test information.

7. The method according to any one of claims 1 to 6, characterized in that Utilizing the second agent and its associated script generation model, combined with the element information knowledge base, mapping the test steps in the test case into operation description information for the target interface element, and generating an executable test script based on the target interface element and its corresponding operation description information, including: Inputting the test case into the second agent, generating a second prompt word according to the test case, wherein the second prompt word is used to guide the script generation model to convert the test case into an executable test script in the role of a second test engineer; The script generation model is called according to the second prompt word. Under the guidance of the second prompt word, combined with the element information knowledge base, the test steps in the test case are mapped to operation description information for the target interface element, and an executable test script is generated according to the target interface element and its corresponding operation description information.

8. The method according to claim 7, characterized in that Generating a second prompt word according to the test case includes: Embedding the test case into a second input prompt word of a second prompt word template to obtain the second prompt word; The second prompt word template also includes: a second role prompt word, a positioning prompt word and a script generation prompt word; the second role prompt word is used to limit the script generation model to play the role of a second test engineer; the positioning prompt word is used to guide the script generation model to locate the interface elements and operation behaviors of the second input prompt word in combination with the element information knowledge base; the script generation prompt word is used to guide the script generation model to generate an executable test script based on the positioning result of the positioning prompt word.

9. The method according to claim 7, characterized in that Under the guidance of the second prompt word, in combination with the element information knowledge base, the test steps in the test case are mapped into operation description information for the target interface element, and an executable test script is generated according to the target interface element and its corresponding operation description information, including: Parsing the second prompt word to obtain a second input prompt word, a second role prompt word, a positioning prompt word, and a script generation prompt word, wherein the second input prompt word includes the test case; Under the guidance of the second role prompt and the positioning prompt, in the role of the second test engineer, combined with the element information knowledge base, mapping the test steps in the test case into operation description information for the target interface element; Under the guidance of the script generation prompt word, an executable test script is generated based on the target interface element and its corresponding operation description information.

10. The method according to claim 9, characterized in that In the role of the second test engineer, in combination with the element information knowledge base, the test steps in the test case are mapped into operation description information for the target interface element, including: As the second test engineer, parse the test steps in the test case to obtain operational behavior information of the test steps on the target interface element described in natural language; Converting the operation behavior information of the test step on the target interface element described in natural language into an identifier and operation instruction of the target interface element based on the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base; Based on the identifier of the target interface element, matching is performed in a structure tree of at least one page recorded in the element information knowledge base to obtain logical position information of the target interface element on the target page; The identifier, operation instruction and logical position information of the target interface element are used as the operation description information of the target interface element.

11. The method according to any one of claims 1-6, 8-10, characterized in that: Also includes: Using a monitoring service to record traffic data generated by user interactions with the software under test; Extracting the operation instruction, the identifier of the interface element operated by the operation instruction, and the structure tree of the page to which the interface element operated by the operation instruction belongs from the traffic data; Extracting text keywords of the interface element operated by the operation instruction, and adding operation context information for the interface element operated by the operation instruction; The operation instruction, the identifier of the interface element operated by the operation instruction, text keywords and operation context information, and the structure tree of the page to which the interface element operated by the operation instruction belongs are correspondingly stored in the element information knowledge base.

12. The method according to any one of claims 1-6, 8-10, characterized in that Also includes: Monitoring whether the element information knowledge base changes; When a change in the element information knowledge base is detected, and the changed information in the element information knowledge base is related to the test script, the test script is repaired or updated according to the changed information.

13. An electronic device, characterized in that: include: memory and processor; The memory is used to store a computer program; the processor is coupled to the memory and is used to execute the computer program to implement the steps in the method according to any one of claims 1 to 12.

14. A computer-readable storage medium storing a computer program / instruction, characterized in that: When the computer program / instructions are executed by a processor, the processor is enabled to implement the steps of the method according to any one of claims 1 to 12.

15. A computer program product, characterized in that include: A computer program / instruction, when executed by a processor, causes the processor to implement the steps of the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Software test apparatus and test method

    CN101339534A

  • Method and device for constructing Android App automated test framework based on Appium

    CN108427646A

  • Method and device for generating test script and automatic test method

    CN110413524A

  • Test method, device, equipment, storage medium and computer program product

    CN116662143A

  • Method and device for generating UI automatic test script and medium

    CN118170686A

Cited By

  • Multi-modal data-based use case generation method, medium, equipment and product

    CN122332293A