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

By using an AI model-driven two-stage test script generation method and combining operation documents and user interaction data to build a knowledge base, the problems of low efficiency and poor stability in E2E test script generation are solved, and efficient and stable test script generation and maintenance are achieved.

CN120723657BActive Publication Date: 2026-01-23ALIBABA CLOUD COMPUTING CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing E2E test script generation methods are inefficient and unstable, making it difficult to adapt to complex and ever-changing application scenarios. Recording and playback methods are affected by changes in page layout, and manually writing scripts requires a lot of manpower and has high maintenance costs.

Method used

An AI model driven by a first and second intelligent agent is adopted, and an element information knowledge base is built by combining operation documents and user interaction traffic data to realize two-stage test script generation. Executable test scripts are generated by mapping interface elements through test cases described in natural language and operation description information.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723657B_ABST
    Figure CN120723657B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a test script generation method and device, a storage medium and a program product. In the embodiments of the present application, based on an AI model driven by a first agent and a second agent associated with each other, and based on operation documents of the software to be tested and traffic data generated by the user interacting with the software to be tested, a two-stage test script generation scheme is implemented, and the generation efficiency of the test script is improved. Furthermore, an element information knowledge base is constructed based on the traffic data to assist the second agent in searching, so that the test steps of the test case generated based on the operation documents can be mapped to the operation description information of the interface elements, thereby accurately locating the interface elements based on the operation description information, realizing that the content of the page on the software to be tested is consistent with the content written in the test script, and being conducive to improving the stability of the test script.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[0002] With the development of cloud computing technology, more and more cloud products have emerged. In order to verify the functional integrity, abnormal processing capability, etc. of these cloud products, it is necessary to perform E2E (End to End) testing on the cloud products. The current E2E testing is to generate an E2E test script based on recording and playback, or to manually write an E2E test script by a user according to test requirements. The current generation of test scripts is low in efficiency and poor in stability. SUMMARY

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

[0004] Embodiments of the present application provide a test script generation method, which comprises: obtaining an operation document of a software to be tested, the software to be tested comprising a function point, and the operation document comprising function description information and operation guide information of the function point; using a first intelligent agent and an associated use case generation model to understand the content of the operation document to obtain test key information, and generating test cases described in natural language based on the test key information; using a second intelligent agent and an associated script generation model, combining an element information knowledge base, mapping test steps in the test cases to operation description information of target interface elements, and generating executable test scripts according to the target interface elements and the corresponding operation description information; the element information knowledge base is constructed according to traffic data generated by user interaction with the software to be tested, and comprises a mapping relationship between interface elements and operation description information involved in the software to be tested.

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

[0006] Embodiments of the present application also provide a computer readable storage medium storing a computer program / instruction, which enables the processor to implement the steps in any one of the test script generation methods when the computer program / instruction is executed by the processor.

[0007] The embodiment of the present application further provides a computer program product, which comprises computer programs / instructions, when the computer programs / instructions are executed by a processor, the processor can implement the steps in any one of the test script generation methods.

[0008] The embodiment of the present application is based on the AI model driven by the first intelligent agent and the second intelligent agent, and is based on the operation document of the to-be-tested software and the traffic data generated by the user interacting with the to-be-tested software, and a two-stage test script generation scheme is implemented, and the generation efficiency of the test script is improved. And the element information knowledge base is constructed based on the traffic data to assist the second intelligent agent in searching, 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, so as to accurately locate the interface element based on the operation description information, realize that the content of the page on the to-be-tested software and the content written in the test script are consistent, and it is beneficial to improve the stability of the test script. BRIEF DESCRIPTION OF DRAWINGS

[0009] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application, the illustrative embodiments of the present application and the description thereof serve to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:

[0010] Figure 1 The structure schematic diagram of the first system for implementing the test script generation method provided by an exemplary embodiment of the present application is shown in the figure;

[0011] Figure 2 The flowchart of the test script generation method provided by another exemplary embodiment of the present application is shown in the figure;

[0012] Figure 3 The architecture schematic diagram of the first intelligent agent provided by another exemplary embodiment of the present application is shown in the figure;

[0013] Figure 4 The architecture schematic diagram of the second intelligent agent provided by another exemplary embodiment of the present application is shown in the figure;

[0014] Figure 5 The architecture schematic diagram of the element information knowledge base provided by another exemplary embodiment of the present application is shown in the figure;

[0015] Figure 6 The structure schematic diagram of the test device provided by another exemplary embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0016] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described clearly and completely below in combination with specific embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0017] It should be noted that, in the case where the embodiments of the present 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 for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal. In addition, the various models (including but not limited to language models or large models) involved in the present application are in compliance with relevant laws and standard regulations.

[0018] In addition, it should be noted that, in the case where the embodiments of the present application involve user interaction operations or trigger operations, the user interaction operations or trigger 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 various modes of interactive operations; wherein the touch operation includes but is not limited to: click operation, double-click operation, long-press operation, sliding operation, pinch operation or mouse hovering operation, etc. The sliding operation includes but is not limited to: straight line sliding, curve sliding, etc.

[0019] The E2E test is described taking cloud products as an example, but is not limited to cloud products. Cloud products mainly refer to various products provided by cloud vendors relying on cloud computing, which are used to provide users with computing, storage, network and other resources. Cloud products are deployed in complex distributed environments and rely on network, virtualization, multi-tenancy and other technologies. This architecture makes it vulnerable to network delays, hardware failures and other uncertain factors. Therefore, it is necessary to perform E2E testing on cloud products to verify their functional integrity, exception handling capability, etc., to ensure that cloud products can stably and efficiently provide services in actual running environment.

[0020] In E2E testing, a common way to generate test scripts is to generate E2E test scripts based on recording and playback. This method usually takes a screenshot of the page through a visual large model, identifies the text information and the position coordinates of the interface elements in the picture, and generates an executable test script based on these position coordinates. Since this method relies on image analysis and obtains the actual display position of the interface elements on the page, the position coordinates of the interface elements may be affected by changes in the page layout. For example, when the page is scaled, the resolution is adjusted, or it is displayed on different devices, the page layout may change, causing the position coordinates obtained during recording to be invalid. That is, the test script generated under the first page layout may not be able to accurately find the interface elements when applied to the second page layout. Therefore, changes in the page layout in this method will cause inaccurate positioning of the interface elements, resulting in low stability of the test script. In addition, the resolution of the screenshot is affected by factors such as display screen DPI (Dots Per Inch), browser zoom ratio, and device pixel ratio. Low-resolution screenshots may result in inaccurate text recognition, affecting the determination of the position coordinates of the interface elements. At the same time, screenshots also have other limitations, such as the possibility of incomplete screenshots, which may result in some interface elements not being captured. When there are multiple controls with the same text content in the page, it is difficult to distinguish the operation objects based on text information only. For the above reasons, the test script generated by the recording and playback method has poor stability, high maintenance cost, low input-output ratio, and is difficult to adapt to complex and variable application scenarios.

[0021] Another way to generate test scripts is for users to manually write E2E test scripts according to test requirements. In this method, each test script needs to be written from scratch, covering page navigation, element positioning, user operation, assertion logic, and other aspects, requiring a large amount of human resources. Manual scripting has a long development cycle and is difficult to quickly respond to frequent changes in application requirements. Once the page structure and interface elements change after the test script is written, the original element positioning logic may fail, causing the test to fail, and the script stability is poor. When maintaining or modifying the test script, manual adjustments are often required, resulting in high maintenance costs and low efficiency. Therefore, manually writing E2E test scripts has the problems of low generation efficiency, poor stability, high labor cost, and difficulty in maintenance.

[0022] The following embodiments of the present application provide a test script generation method. In the method, an AI model driven by a first agent and a second agent is used, and based on operation documents of a software to be tested and traffic data generated by a user interacting with the software to be tested, a two-stage test script generation scheme is implemented to improve the generation efficiency of test scripts. An element information knowledge base is constructed based on the traffic data to assist the second agent in searching, so that the test steps of the test cases generated based on the operation documents can be mapped to operation description information of interface elements, thereby accurately locating the interface elements based on the operation description information, realizing that the content of a page on the software to be tested is consistent with the content written in the test script, and facilitating to improve the stability of the test script. Further, since the stability of the test script is high, the maintenance difficulty and cost can be reduced.

[0023] The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings. Figures 1-6 The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0024] Figure 2 A flowchart of a test script generation method provided by an exemplary embodiment of the present application is shown in FIG. 1. As shown in FIG. 1, the method includes the following steps. Figure 2

[0025] S1, obtaining operation documents of a software to be tested, the software to be tested including function points, and the operation documents including function description information and operation guide information of the function points.

[0026] S2, using a first agent and a use case generation model associated with the first agent to understand the content of the operation documents to obtain test key information, and generating test cases described in natural language based on the test key information.

[0027] S3, using a second agent and a script generation model associated with the second agent to map test steps in the test cases to operation description information of target interface elements in combination with an element information knowledge base, and generating executable test scripts according to the target interface elements and the corresponding operation description information.

[0028] The element information knowledge base is constructed according to traffic data generated by a user interacting with the software to be tested, and includes a mapping relationship between interface elements involved in the software to be tested and operation description information.

[0029] ​The software to be tested refers to an object to be tested, which can be a software program corresponding to a cloud product or a cloud service developed based on cloud computing technology, or a traditional software program. For example, the software to be tested can be various database services, application programming interface (API) gateways, load balancing services, global wide web (Web) applications, Web services, and other software products provided in the form of services.

[0030] The software to be tested includes one or more function points, and the function point refers to a function that can be implemented by the software to be tested. The function that can be implemented can be understood as a function that is expected to be implemented. For example, if the software to be tested is instant messaging software, the function points can be chat functions, file transfer functions, and emoticon functions. For another example, if the software to be tested is a shopping software, the function points can be functions such as collecting functions, displaying product detail pages, and payment functions. If the software to be tested is a cloud server service software, the function points can be functions such as creating instances, deleting instances, purchasing instances, selling instances, binding instances, or managing instances.

[0031] The above function points can be implemented during the running of the software to be tested. Further, during the running of the software to be tested, interaction with the user is supported, for example, receiving an interactive operation of the user, and outputting a response result to the user after responding to the interactive operation. The user can interact with the software to be tested through various ways such as a keyboard, a mouse, a touch screen, and voice. The interactive behavior can be clicking a button, text input, screen sliding, page jumping, voice control, and the like. For example, during the implementation of the product detail page display function, the software to be tested receives an operation of the user clicking a picture or a name of a product. Each function point corresponds to event processing logic. There can be a dependency relationship between different function points.

[0032] In order to perform E2E testing on the software to be tested, a test script can be generated for the software to be tested in the embodiments of the present application. In the embodiments of the present application, the test script corresponding to the software to be tested is generated based on the operation document of the software to be tested and the traffic data generated by the user interacting with the software to be tested. To this end, the operation document of the software to be tested can be obtained.

[0033] The operation document is a file provided for a user to understand the to-be-tested software, and records introduction information and a use method of the to-be-tested software. In the embodiment of the present application, the operation document includes function description information and operation guide information of a function point involved in the to-be-tested software. The function description information is a summary introduction of "what" the function point is, including but not limited to the purpose and role of the function point. For example, the function description information corresponding to a create instance function point can be to create a new instance in the to-be-tested software. The operation guide information refers to the content of how to use the function point, including but not limited to a prerequisite condition, an operation step, a matter needing attention, an expected result and the like for using the function point. The prerequisite condition is a condition to be met before the function point is executed, the operation step is a step required for using the function point, the matter needing attention refers to a matter needing attention when the function point is used, and the expected result refers to a state or feedback information to be presented after the function point is executed. For example, the operation guide information corresponding to the create instance function point includes: the prerequisite condition is to log in to a cloud platform console and have a permission to create a resource; the operation step is to enter a cloud server instance management page, click a create instance button, select a region, an available zone, an image, an instance specification, a storage configuration in sequence, set a network and a security group, configure login credentials, confirm a configuration and a cost, click an immediate purchase button and complete payment; the matter needing attention is that a region cannot be changed after an instance is created; and the expected result is that an instance state is displayed as running, and the instance can be viewed and managed in an instance list.

[0034] The present application does not limit the way of obtaining the operation document of the to-be-tested software. The operation document of the software can be obtained from an official document platform of the to-be-tested software, or the operation document of the to-be-tested software can be obtained from a document collaboration platform. To implement step S1, a obtaining module 300 can be deployed in the first system.

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

[0036] The first intelligent agent is an autonomous entity capable of perceiving an environment and making decisions, which can be implemented in the form of a software program, a robot or a virtual assistant, and can interact with the first system to drive the use case generation model to generate a test case. Optionally, the first intelligent agent can optimize the use case generation model through a feedback result of executing the test case, to improve the accuracy of the test case.

[0037] The use case generation model is an artificial intelligence (AI) based model. For example, the use case generation model can be a large model with relatively large parameters, 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 supporting multi-modal, with cross-modal and cross-language deep semantic understanding and generation capabilities, 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 using an encoder-decoder structure, or a large language model using only an encoder structure, or a large language model using only a decoder structure, or a self-developed large language model, or other architectures that may appear in the future.

[0038] The test key information refers to key information relied on for testing the to-be-tested software. The test key information includes test steps, which are semanticized steps for using the to-be-tested software, and are used to guide how the test script operates the to-be-tested software. Optionally, the content understanding of the operation document is performed to obtain the test key information, including: performing content understanding on the function description information and operation instruction information of the function points in the operation document to obtain the test key information about the function points. Different function points can correspond to different test key information.

[0039] Further, the test key information can further include any one or more of a use case name, a function description, a test title, a precondition, an expected result, a test type, and a test priority. The use case name refers to a unique identification name of the test case. The function description refers to the function description information of the function point involved in the test case. The test title refers to the summary content of the test case, which can use the purpose identifier of the test case. The precondition refers to the condition that needs to be met before executing the test case. The prediction result refers to the state or feedback information that should be presented after executing the test case. The test type refers to the test category to which the test case belongs, and the test type includes, but is not limited to, function test, regression test, boundary value test, and exception test. Different types of tests focus on different dimension information of the to-be-tested software. The test priority indicates the importance of the test case, and can be used to indicate the execution order of the test case.

[0040] A test case is a natural language description information designed to verify a function point of the software to be tested, for example, whether the function of the function point is complete or whether there are exceptions, etc. For a function point, different test cases can be generated by different user interactions. For example, for the add goods function, the test steps of test case 1 are: the user selects the goods specification, inputs the quantity, and clicks the "add to shopping cart" button; the test steps of test case 2 are: the user does not select the color or size, and directly clicks "add to shopping cart". Alternatively, for a function point, test cases corresponding to normal input operations, boundary value input operations, and abnormal input operations can be generated to comprehensively verify the correctness, stability, and fault tolerance of the function point.

[0041] After obtaining the test case, the test steps in the test case are mapped to operation description information of the target interface element by using the second agent and its associated script generation model, combining the element information knowledge base, and generating an executable test script according to the target interface element and its corresponding operation description information.

[0042] The second agent can refer to the description of the first agent, and the same will not be described in detail. The second agent can interact with the first system to drive the script generation model to generate a test script. Alternatively, the second agent can optimize the script generation model through the feedback result of executing the test script to improve the accuracy of the test script.

[0043] The script generation model is a model for generating a test script based on a test case, which is a model for converting natural language into code description. The script generation model is similar to the use case generation model and is also an AI-based model, which can be various large language models, and will not be described in detail here.

[0044] The test script refers to a program code described in a certain programming language, which is used to automatically perform E2E testing on the software to be tested. In the embodiments of the present application, the programming language used by the test script is not limited, and can be flexibly determined according to the programming language used by the software to be tested and the testing requirements, for example, it can be a programming language such as java, C, python, etc. No matter which programming language, the second agent of the embodiments of the present application can generate a test script of the corresponding programming language by driving the script generation model.

[0045] The element information knowledge base is constructed according to the traffic data generated by the user interacting with the software to be tested. By analyzing the traffic data, the operation description information corresponding to the user interacting with the software to be tested can be obtained. The operation description information can refer to the semantic description information of the content involved in the process of the user interacting with the software to be tested, including but not limited to operation instructions, operation types, identifiers of the interface elements operated, and logical position information of the interface elements in the page.

[0046] The operation instruction refers to an operation instruction initiated by a user to the to-be-tested software during use of the to-be-tested software, for example, "click the login button", "slide the page up", and the like. The operation instruction can be acquired by performing event listening on the to-be-tested software, and the listening manner includes, but is not limited to, JavaScript event listening, software development kit (SDK) automatic collection, plug-in monitoring, and the like. It is explained herein that, before testing the to-be-tested software, a trial version of the to-be-tested software can be published to external users, and during use of the trial version by the external users, traffic data generated by interactive operation of the users on the trial version is collected. The external users herein are an example of the above-mentioned users, and the above-mentioned users are users in a broad sense, including various users who perform interactive operation on the to-be-tested software. And / or, before performing E2E testing on the to-be-tested software, a test version can also be published to internal testers, and during use of the test version by the testers, traffic data generated by interactive operation of the testers on the test version is collected. Similarly, the testers herein are an example of the above-mentioned users.

[0047] The identification of the interface element refers to identification information of an interface element operated by a user. The identification of the interface element can be obtained based on attribute information in a Hyper Text Markup Language (HTML) tag corresponding to the interface element; can be obtained based on attribute information of an operation control corresponding to the interface element; or can be obtained based on a text keyword corresponding to the interface element, for example, buttons displayed as "confirm", "login", "submit", "cancel", and the like on an interface. The same interface element can exist in the same page, but the corresponding logical position information is different, and the unique interface element is located based on the logical position information.

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

[0049] The XPath path can not only describe the position of the interface element in the DOM tree, but also can construct a matching condition to fuzzy match the interface element by combining the attribute, text content and other information of the interface element. Although the XPath path can locate the interface element, it does not directly reflect the visual position of the interface element on the display screen of the device.

[0050] The embodiments of the present application do not limit the implementation of the XPath path. In one implementation, a complete path from the root node of the page to the interface element operated by the user is constructed as the XPath path based on the hierarchical relationship, so as to reflect the nesting structure of the element. Exemplarily, the XPath: / html / body / div[2] / ul / li[3] indicates that from the root node, the <body> is entered, the second child node is entered, the list in the is entered, and finally the third element is located. In another implementation, the XPath path of the interface element is constructed based on the attribute information, for example, the XPath: / / input[@id='username'] indicates that all input boxes with the id of username are matched in the DOM tree. In yet another implementation, the XPath path of the interface element is constructed by combining the hierarchical relationship and the attribute information, for example, / / div[@class='menu'] / ul / li / a[text()='Home'] indicates that in the list in the with the class of menu, the link element with the text content of "Home" is found.

[0051] The logical position information obtained based on the XPath path can be divided into two categories. One is a static path, that is, the position information thereof is not changed relative to the page, and is referred to as an absolute path. The path is from the root node of the page, and each step path to the interface element operated by the user is determined. The other is a dynamic path, that is, the position information thereof is changed following the change of the page, and is referred to as a relative path. The path is obtained based on the relative position and structural relationship between the interface elements, and does not depend on the complete hierarchical path from the root node. Instead, the current context node or the interface element which is stable and unchanged in the page is taken as a reference, and the position of the interface element operated by the user is inferred by logical relationship. Preferably, the logical position information is dynamic, that is, even when the interface structure changes, the interface element can still be accurately located.

[0052] The CSS path includes one or more declarations, each of which consists of an attribute and a value, defining the style of the selected interface element. The logical position information obtained based on the CSS path belongs to 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, which indicates that a div with the class next-col is found in the page, and among its direct child elements, there is a div with the class sls-easyRegionPicker-easyregionpicker, and under the div, there is a div with the class sls-easyRegionPicker-base-btn, which internally has a span with the class sls-easyRegionPicker-input, and the direct child element of the span is an <input> input box.

[0053] The logical position information of each interface element belongs to one of a static path or a dynamic path, but for the entire page, the interface elements in the page can all be static paths, or all be dynamic paths, or part of the interface elements are static paths and part of the interface elements are dynamic paths.

[0054] After obtaining the operation description information, a one-to-one mapping relationship between the operation description information and the interface elements involved in the to-be-tested software is obtained based on the user traffic data, and is stored in the element information knowledge base. According to the target interface element and the 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 element, and an executable test script is generated according to the target interface element and the corresponding operation description information. A test step will operate on an interface element. For ease of description, the interface element to be operated by the test step is referred to as a target interface element. Different test steps can operate on different target interface elements, or different test steps can operate on the same target interface element, depending on whether different function points provided by the to-be-tested software are associated with the same interface element and specific test requirements, which are not limited. The operation description information of the target interface element by each test step is used to describe the operation type of the test step on the target interface element, the operation instruction associated with the operation type, and the identification of the target interface element, the logical position information of the target interface element on its own page, and the like.

[0055] The test case corresponds to the test script one by one. The process of generating an executable test script according to the target interface element and the 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 to which it belongs" 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 the board" in the operation description information is converted into the code: ##name: click on a: experience the board #target: / html / body / div[2] / div[2] / div[1] / div / ul / ul / li[2] / div / span / a.

[0056] The test script generation method provided by the embodiment of the application will be described in detail below in combination with the detailed implementation process of the first intelligent agent. In this embodiment, the following steps are included:

[0057] S21, obtaining the operation document of the software to be tested.

[0058] S22, inputting the operation document into the first intelligent agent, generating a first prompt word according to the operation document, the first prompt word being used to guide the test 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 test case generation model according to the first prompt word, and obtaining test key information by understanding the content of the operation document in the role of the first test engineer under the guidance of the first prompt word, to generate a test case described in natural language based on the test key information.

[0059] S23, using the second intelligent agent and its associated script generation model, combining the element information knowledge base, mapping the test steps in the test case into operation description information of the target interface element, and generating an executable test script according to the target interface element and the corresponding operation description information.

[0060] The first prompt word 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 in the role of the first test engineer. It can be understood that the use case generation model is given similar professional capabilities of the first test engineer based on the first prompt word, so that it can simulate the thinking process and work duties of the first test engineer to convert the operation document into a test case, including obtaining each content in the test key information by understanding the operation document and generating a test case based on the test key information. Through the role-based prompt, the use case generation model can not only understand the explicit information in the operation document, but also combine the test professional knowledge to reason and generalize to generate a test case with higher quality and improve the accuracy of the test case.

[0061] In an optional implementation, to implement the method of the embodiment of the present application, a first agent architecture as shown in Figure 3 The first agent 100 can 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.

[0062] The first access module 100A is configured to receive an operation document of a 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 according to 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 according to the first prompt word, and under the guidance of the first prompt word, obtain test key information by understanding the content of the operation document in the role of the first test engineer, and generate a test case described in natural language based on the test key information. It is stated herein that the structure is only an example and is not limited thereto, and any other agent structure that can be reasonably deformed on this basis is within the protection scope of the present application.

[0063] In the embodiments of the present application, the generation manner of the first prompt word is not limited. In an optional implementation, the first prompt word is generated according to the operation document, including: embedding the operation document into a first input prompt word in a first prompt word template to obtain the first prompt word. The first prompt word template includes the first input prompt word, which is a blank prompt word used to carry the operation document. In addition, the first prompt word template further includes a first role prompt word, a content understanding prompt word and a use case generation prompt word, which are prompt words of existing content. The role prompt word is used to limit the use case generation model to play the role of the first test engineer; the content understanding prompt word is used to guide the use case generation model to perform multi-dimensional content understanding on 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 result of the content understanding prompt word. By constructing the first role prompt word, the content understanding prompt word and the use case generation prompt word in the first prompt word template, the use case generation model can be guided step by step to think, which is beneficial to logical reasoning of the use case generation model and improves the accuracy of generating the test case.

[0064] The first prompt word template is used to guide the use case generation model how to understand the operation document of the software to be tested. 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 of the use case generation model after embedding the operation document into the first prompt word template.

[0065] The multi-dimensional content understanding refers to content understanding according to each dimension in the generated test key information. For example, if the test key information includes the use case name and the function description, the multi-dimensional content understanding refers to the use case name dimension and the function description dimension, and the content understanding prompt word guides the use case generation model to perform content understanding on the first input prompt word in the use case name dimension and the function description dimension.

[0066] The first prompt word template can be pre-maintained, and based on the first prompt word template, the operation document of any software to be tested can be used to generate a test case. Different operation documents of different software to be tested can be different, different first prompt words can be generated based on the first prompt word template for different operation documents, and different test cases can be generated based on different first prompt words. The first role prompt word, the content understanding prompt word and the use case generation prompt word can also be different due to different input operation documents.

[0067] In an optional implementation, before embedding the operation document into the first input prompt word in the first prompt word template, the method further includes: performing text correction on the text description of the interface element in the operation document in combination with the text keyword of at least one interface element recorded in the element information knowledge base.

[0068] The text keyword of the interface element refers to the key text content involved in the interface element, and is important semantic information for identifying the interface element. The text keyword includes, but is not limited to, the text content on the associated operation control, prompt information, etc. Illustratively, the text description of the interface element in the operation document is "determine", and the text keyword corresponding to the interface element recorded in the element information knowledge base is "confirm". The text description in the operation document is corrected based on the text keyword, that is, "determine" is modified to "confirm", so as to adapt to the element information knowledge base, so that the information obtained based on the operation document is consistent with the actual result presented by the page. Avoids errors in the process of generating a test script due to inconsistent text, improves the accuracy of converting an operation document into a test case, and thus more stably generates a test script.

[0069] In this implementation mode, the first intelligent agent can further include a correction module, and the correction module is configured to implement the aforementioned text correction method.

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

[0071] The embodiments of the present application do not limit the construction manner of the first input prompt word, the first role prompt word, the content understanding prompt word and the use case generation prompt word. Taking the construction of the use case generation prompt word as an example, the use case generation prompt word can be composed of a task description and an output structure. The task description can be "generate a complete test case according to the test key information", and the output structure can be "require to include the use case name, function description, precondition, test step and expected result". Based on this, the use case generation prompt word obtained by organization can be "please generate a complete test case according to the following test key information, and requirements include: test title, precondition, operation step and expected result. Ensure clear language and complete logic." The constraint conditions can also be added in the use case generation prompt word, for example, each step in the operation step is independent, single action and executable, the expected result corresponds to each step in the operation step one by one, and the explicit and observable feedback result is ensured for each step. The use case generation prompt word can also include other contents, which are not exemplified one by one here. Similarly, the first input prompt word, the first role prompt word and the content understanding prompt word can also be constructed according to specific task requirements. Different constructed prompt words can generate different test cases.

[0072] In an optional implementation manner, 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 calling the use case generation model based on the optimized first prompt word to generate a new test case and receive the feedback result of the new test case, and through multiple iterations, until the test case obtained by the optimized first prompt word meets the preset condition. The feedback result of the test case can be determined through the executability of the generated test script, the accuracy of the assertion, the stability of the interface element positioning and the like. The optimization of the first prompt word can be realized by supplementing the context information and adjusting the instruction expression. One or more of 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 in the process of optimizing the first prompt word.

[0073] In an optional implementation manner, the multiple dimensions of the content understanding prompt word for prompting content understanding include a use case name dimension, a function description dimension, an operation step dimension, a precondition dimension and an expected result dimension.

[0074] Under the guidance of the first role prompt word and the content understanding prompt word, the operation document is understood in multiple dimensions in the role of the first test engineer to obtain test key information, including: under the guidance of the first role prompt word, the operation document is understood in multiple dimensions in the role of the first test engineer from the use case name dimension, the function description dimension, the operation step dimension, the precondition dimension and the expected result dimension, to obtain the use case name, the function description, the operation step, the precondition and the expected result corresponding to the function point as the test key information. The use case generation model is guided to understand the operation document more comprehensively from multiple dimensions, and the accuracy of the understanding of the use case generation model is further improved.

[0075] 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 step required by 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 by the function point of the first input prompt word; and the expected result dimension is used to guide the use case generation model to understand the result obtained after executing the function point of the first input prompt word.

[0076] In an optional implementation, under the guidance of the use case generation prompt word, a test case described in natural language is generated based on the test key information, including: under the guidance of the use case generation prompt word, the use case generation model performs semantic association and context supplement on the extracted test key information, and generates a test case based on the associated and supplemented test key information. For example, the test step in the test key information includes "clicking the login button", and the use case generation model can associate the semantic content "if the information is correct after clicking, the page should be jumped".

[0077] In the embodiments of the present application, the underlying model architecture adopted by the use case generation model is not limited, and the use case generation model can be an encoder-only architecture, a decoder-only architecture, or a combination of an encoder and a decoder.

[0078] On the basis of the underlying model architecture, a function architecture can be constructed for the use case generation model. In the embodiments of the present application, the function architecture of the use case generation model includes a first analysis layer, a content understanding layer and a first generation layer.

[0079] The first analysis layer is configured to analyze 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, and the first input prompt word includes an operation document. The content understanding layer is configured to perform multi-dimensional content understanding on the operation document in the role of a first test engineer under the guidance of the first role prompt word and the content understanding prompt word to obtain test key information. The first generation layer is configured to generate a test case described in natural language based on the test key information under the guidance of the use case generation prompt word.

[0080] Further, the content understanding layer is further configured to perform multi-dimensional content understanding on the operation document in the role of a first test engineer from a use case name dimension, a function description dimension, an operation step dimension, a precondition dimension, and an expected result dimension under the guidance of the first role prompt word to obtain a use case name, a function description, a test step, a precondition, and an expected result corresponding to a function point as the test key information.

[0081] The test script generation method provided by the embodiment of the application will be described in detail below in combination with the detailed implementation process of the second agent. In this embodiment, the detailed implementation process of the first agent can be referred to the foregoing embodiments, and will not be described herein. This embodiment includes the following steps:

[0082] S31, obtaining an operation document of a software to be tested.

[0083] S32, using the first agent and the use case generation model associated therewith to perform content understanding on the operation document to obtain test key information, and generating a test case described in natural language based on the test key information, wherein the test case includes a test step.

[0084] S33, inputting the test case into the second agent, generating a second prompt word according to the test case, and using the second prompt word 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 according to the second prompt word, mapping the test step in the test case into operation description information of a target interface element in combination with the element information knowledge base under the guidance of the second prompt word, and generating an executable test script according to the target interface element and the corresponding operation description information.

[0085] 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 that the script generation model is given similar professional capabilities 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 operation description information of target interface elements, and generating an executable test script according to the target interface elements and the 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 infer and generalize based on test professional knowledge to generate a test script of higher quality and improve the accuracy of the test script. The second test engineer can be the same as or different from the second test engineer of embodiment 1. Preferably, the first test engineer is an experienced test engineer, and the second test engineer is a professional automated test engineer.

[0086] In an optional implementation, to implement the method of the embodiment of the application, a second intelligent agent architecture diagram as shown in Figure 4 is constructed. The second intelligent 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.

[0087] The second access module 200A is configured to receive a test case of a software to be tested and send the test case to the second prompt word generation module 200B. The second prompt word generation module 200B is configured to generate a second prompt word according to the test case and send the second prompt word to the second calling module 200C. The second calling module 200C is configured to call the script generation model 200D according to the second prompt word, and under the guidance of the second prompt word, map test steps in the test case to operation description information of target interface elements in combination with an element information knowledge base, and generate an executable test script according to the target interface elements and the corresponding operation description information. It is explained that this structure is only an example and is not limited thereto, and any other intelligent agent structure that can be reasonably deformed on this basis is within the protection scope of the application.

[0088] In an optional implementation, the second prompt word is generated according to the test case, including: 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 includes the second input prompt word, and the second input prompt word is a blank prompt word used to carry the test case. In addition, the second prompt word template also includes a second role prompt word, a positioning prompt word and a script generation prompt word, which are prompt words of existing content. 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 combine the element information knowledge base to position the interface elements and operation behaviors of the second input prompt word; and 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. By constructing the second role prompt word, the positioning prompt word and the script generation prompt word in the second prompt word template, the script generation model can be guided step by step to think, which is beneficial to logical reasoning of the script generation model and improves the accuracy of the generated test script.

[0089] The second prompt word template is used to guide the script generation model to understand 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 formed after embedding the test case into the second prompt word template and inputting into the script generation model.

[0090] The second prompt word template can be maintained in advance, and based on the second prompt word template, the test case of any software to be tested can be generated into a test script. Different operation cases can generate different second prompt words based on the second prompt word template, and different second prompt words generate different test scripts. The second role prompt word, the positioning prompt word and the script generation prompt word can also be different due to different test cases.

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

[0092] The embodiments of the present application do not limit the construction of the second input prompt word, the second role prompt word, the positioning prompt word and the script generation prompt word. Taking the construction of the script generation prompt word as an example, the script generation prompt word can be composed of a task description, a target language, an input specification and an output structure. The task description is used to require the generation of a test script, the target language is used to specify the programming language of the output test script, the input specification is used to describe the format of the target interface element and the operation description information, and the output structure is used to specify the code structure. For example, the script generation prompt word is: you are an automated test engineer, please generate an automated test script written in Python and Selenium according to the following target interface element and user operation description information. Requirements: use a certain browser; each operation corresponds to a line of code; add explicit waiting for each operation to ensure that the target interface element is interactive; use the operation description information to locate the target interface element; do not generate redundant logic other than assertions. The script generation prompt word can also include other content, which will not be exemplified one by one here. Similarly, the second input prompt word, the second role prompt word and the positioning prompt word can also be constructed according to specific task requirements. Different prompt words are constructed, and the generated test scripts can also be different.

[0093] 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 called based on the current second prompt word; call the script generation model again based on the optimized second prompt word to generate a new test script and receive the feedback result of the new test script, and through multiple iterations, until the test script obtained by the optimized second prompt word meets the preset condition. The execution effect of the test script can be determined through the test case execution effect type, the test script execution effect, the test script execution effect, the assertion accuracy, the stability of the interface element positioning and the like. One or more of the second input prompt word, the second role prompt word, the positioning prompt word and the script generation prompt word can be adjusted in the process of optimizing the second prompt word.

[0094] In an optional embodiment, in the role of a second test engineer, the test steps in the test case are mapped to operation description information of the target interface element in combination with the element information knowledge base, including: in the role of a second test engineer, the test steps in the test case are parsed to obtain operation behavior information of the target interface element described in natural language; according to the text keyword and / or operation context information of at least one interface element recorded in the element information knowledge base, the operation behavior information of the target interface element described in natural language is converted into the identification and operation instruction of the target interface element; based on the identification of the target interface element, matching is performed in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical position information of the target interface element on the target page; the identification, operation instruction and logical position information of the target interface element are taken as the operation description information of the target interface element. In this embodiment, the operation description information includes the identification, operation instruction and logical position information of the target interface element; based on the identification, it is known which target interface element is operated; based on the operation instruction, it is known how to operate the target interface element; based on the logical position information, the target interface element is located; therefore, the test script generated by taking the identification, operation instruction and logical position information as the operation description information can enable the machine to accurately perform operations on the page of the software to be tested. In this process, through the text keyword and / or operation context information in the element information knowledge base, the unique identification, operation instruction and logical position information of the target interface element can be quickly found, and the efficiency of generating the test script is improved.

[0095] The structure tree of the page refers to the hierarchical structure generated by parsing the HTML document, which represents all interface elements in the page and their mutual relationship. The structure tree of the page can be static or dynamic, which is determined according to the structure of the page.

[0096] In the embodiments of the present application, the underlying model architecture adopted by the script generation model is not limited, and the script generation model can be only an encoder architecture, only a decoder architecture, or a combination of an encoder and a decoder. The script generation model and the use case generation model can adopt the same underlying model architecture or different underlying model architectures. On the basis of the underlying model architecture, a functional architecture can be constructed for the script generation model, and in the embodiments 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.

[0097] The second analysis layer is configured to analyze 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 mapping layer is configured to, under the guidance of the second role prompt word and the positioning prompt word, map a test step in a test case to operation description information of a target interface element in a role of a second test engineer, in combination with an element information knowledge base. The second generation layer is configured to, under the guidance of the script generation prompt word, generate an executable test script based on the target interface element and the operation description information of the target interface element.

[0098] Further, the mapping layer is further configured to: analyze, in the role of the second test engineer, the test step in the test case to obtain operation behavior information of the test step on the target interface element described in natural language; convert the operation behavior information of the test step on the target interface element described in natural language into an identifier of the target interface element and an operation instruction according to text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base; match, based on the identifier of the target interface element, 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 a target page; and take the identifier of the target interface element, the operation instruction, and the logical position information as the operation description information of the target interface element.

[0099] The embodiments of the present application do not limit the construction process of the element information knowledge base. In an optional implementation manner, the interaction operation between a user and the software to be tested can be monitored, which can be understood as monitoring an event corresponding to the operation, referred to as monitoring an event. When the interaction operation is monitored, traffic data generated by the interaction operation between the user and the software to be tested is recorded (referred to as a data collection operation), and operation instruction and interface element information operated by the operation instruction are extracted from the traffic data. The operation instruction and the interface element information operated by the operation instruction are processed to construct the element information knowledge base.

[0100] In the embodiments of the present application, as shown in Figure 5 The first system can include a monitoring service 400 and a knowledge base processing module 500, which cooperate with each other to construct the element information knowledge base.

[0101] The monitoring service 400 is configured to record traffic data generated by the interaction operation between the user and the software to be tested, and extract operation instruction and interface element information operated by the operation instruction from the traffic data.

[0102] The knowledge base processing module 500 is configured to obtain the operation instruction and the interface element information operated by the operation instruction, process the operation instruction and the interface element information operated by the operation instruction to obtain operation description information, and construct the element information knowledge base.

[0103] In an optional implementation, the operation instruction and the interface element information operated by the operation instruction are extracted from the traffic data, including: constructing a user session based on the traffic data; and analyzing the user session to obtain the operation instruction and the interface element information operated by the operation instruction. The user session is used to record and integrate the continuous interaction operations of the same user within a certain time period. A user session can start from the login or the first request operation of the user, and end with the logout operation of the user or no interaction operation within a preset time period, or a user session can correspond to the interaction operation of the user on a page, and the construction manner of the user session is not limited herein. Optionally, the operation instruction and the interface element information operated by the operation instruction are written into a log, for example, a Simple Log Service (SLS).

[0104] In an optional implementation, the interface element information operated by the operation instruction can include the operation instruction, the identification 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.

[0105] In an optional implementation, as shown in Figure 5 the operation instruction and the interface element information operated by the operation instruction are processed to obtain operation description information, including: pre-processing the plurality of operation instructions and the interface element information operated by the operation instruction. The plurality of operation description information is pre-processed to obtain the operation description information. The pre-processing includes, but is not limited to, cleaning operation, and the cleaning operation includes identifying and correcting abnormal data in the plurality of operation description information, and removing repeated data in the plurality of operation description information.

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

[0107] In an optional implementation, as shown in 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 operation description information. In an implementation manner, a text keyword (referred to as a data slice operation for short) of the interface element operated by the operation instruction can be extracted, and the text keyword and the corresponding operation description information are stored in the element information knowledge base in association. Each piece of operation description information is stored as an information in the element information knowledge base, and the text keyword can be used as a search index of the corresponding operation description information. The same text keyword can correspond to multiple operation description information. When the element information knowledge base is used, the operation description information corresponding to the text keyword can be filtered out, and then a search is performed in the filtered operation description information. By indexing with the text keyword, the related content can be quickly searched.

[0108] Preferably, the test script generation method further comprises: recording, by the monitoring service, traffic data generated by the user interacting with the to-be-tested software; extracting, from the traffic data, the operation instruction, an identifier of the interface element operated by the operation instruction, and a structure tree of a page to which the interface element operated by the operation instruction belongs; extracting a text keyword of the interface element operated by the operation instruction, and adding operation context information to the interface element operated by the operation instruction; and storing the operation instruction, the identifier of the interface element operated by the operation instruction, the text keyword, and the operation context information, and the structure tree of the page to which the interface element operated by the operation instruction belongs in the element information knowledge base in correspondence. In this embodiment, the element information knowledge base stores the operation instruction, the identifier of the interface element operated by the operation instruction, the text keyword, and the operation context information. Not only can the element information knowledge base improve the search efficiency by indexing with the keyword or the context information, but also can improve the accuracy of the search and the precision of the generated test script by matching multiple dimension information.

[0109] The constructed element information knowledge base can be used for text keyword matching of input information, recalling of matched operation description information in the process of the script generation method, evaluation of the matching result, re-search based on the evaluation result, and the like.

[0110] In the embodiments of the present application, the element information knowledge base can be dynamically updated following the use of the user. In the use process of the user, the page of the to-be-tested software can change, and then the content of the element information knowledge base changes following the change of the page, and the test script is adjusted following the change of the element information knowledge base, so that the test script and the page on the to-be-tested software are kept consistent, and the stability of the test script is improved.

[0111] In an optional implementation, the method further includes: monitoring whether the element information knowledge base changes; and in a case where it is monitored that the element information knowledge base changes 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.

[0112] Exemplarily, the element information knowledge base contains the following information:

[0113]

[0114] Based on the interface element 1 and the corresponding operation description information, the test script 1 is obtained; based on the interface element 2 and the corresponding operation description information, the test script 2 is obtained; and based on the interface element 1 and the corresponding operation description information and the interface element 2 and the corresponding operation description information in the element information knowledge base, the test script 3 is obtained.

[0115] Suppose that the logical position information XPath1 corresponding to the interface element 1 in the element information knowledge base changes, and the changed information is XPath3, then 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 position information XPath3.

[0116] In an optional embodiment, before the test script is generated, the first agent and the second agent can be pre-trained based on traffic data generated by the user interacting with the software to be tested to cover the function points in the operation document of the software to be tested. Based on the trained first agent and the second agent, the generation of the test script for the software to be tested can instantly obtain the logical position information corresponding to the interface element, improve the efficiency of generating the test script, and improve the accuracy of the test.

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

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

[0119] In the method, after the test script is obtained, the execution process of the test script can include: locating a target interface element based on the identification and the logical position information of the target interface element in the operation description information; and operating the target interface element based on the operation instruction in the operation description information.

[0120] The foregoing embodiments can be used in any combination, and any combination of the technical solutions still falls within the protection scope of the present application.

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

[0122] In addition, in some of the processes described in the above embodiments and the accompanying drawings, a plurality of operations appearing in a certain order are included, but it should be clearly understood that these operations can be executed in the order appearing in the text or in parallel, and the serial numbers of the operations such as S1, S2, etc. are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and the operations can be executed in sequence or in parallel. It should be noted that the "first", "second", etc. described in the text are used to distinguish different messages, devices, modules, etc., and do not represent the order, nor do "first" and "second" represent different types.

[0123] Figure 6 A structural schematic diagram of a test device provided in an embodiment of the present application is shown in FIG. 1. As shown in the figure, in practice, the test device includes a memory 54 and a processor 55. Figure 6

[0124] The memory 54 is used to store computer programs and can be configured to store various other data to support operations on the test device. Examples of these data include instructions of any application program or method for operating on the test device, data structures, contact data, phonebook data, messages, pictures, videos, etc.

[0125] The processor 55 is coupled to the memory 54 and is used to execute the computer programs in the memory 54 for: obtaining an operation document of a software to be tested, the software to be tested including a function point, the operation document including function description information and operation guide information of the function point; using a first intelligent agent and an associated use case generation model to perform content understanding on the operation document to obtain test key information, and generating test cases described in natural language based on the test key information; using a second intelligent agent and an associated script generation model, in combination with an element information knowledge base, to map test steps in the test cases into operation description information of target interface elements, and generating executable test scripts according to the target interface elements and the corresponding operation description information; the element information knowledge base is constructed according to traffic data generated by user interaction with the software to be tested, and includes a mapping relationship between interface elements involved in the software to be tested and operation description information.

[0126] ​In an optional embodiment, the content of the operation document is understood to obtain test key information by using the first agent and the use case generation model associated therewith, and the test case described in natural language is generated based on the test key information, including: inputting the operation document into the first agent, generating 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 the test case described in natural language in the role of the first test engineer; the use case generation model is called according to the first prompt word, and the content of the operation document is understood to obtain the test key information in the role of the first test engineer under the guidance of the first prompt word, and the test case described in natural language is generated based on the test key information.

[0127] In an optional embodiment, the first prompt word is generated based on the operation document, including: 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 further 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 the first test engineer; the content understanding prompt word is used to guide the use case generation model to perform multi-dimensional content understanding on the first input prompt word; and the use case generation prompt word is used to guide the use case generation model to generate the test case described in natural language based on the content understanding result of the content understanding prompt word.

[0128] 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 further configured to: correct the text description of the interface element involved in the operation document in combination with the text keyword of at least one interface element recorded in the element information knowledge base.

[0129] In an optional embodiment, the content of the operation document is understood to obtain test key information by using the first agent and the use case generation model associated therewith, and the test case described in natural language is generated based on the test key information, including: inputting the operation document into the first agent, generating 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 the test case described in natural language in the role of the first test engineer; the use case generation model is called according to the first prompt word, and the content of the operation document is understood to obtain the test key information in the role of the first test engineer under the guidance of the first prompt word, and the test case described in natural language is generated based on the test key information.

[0130] In an optional embodiment, the content understanding prompt words prompt multiple dimensions of content understanding, including: a use case name dimension, a function description dimension, an operation step dimension, a precondition dimension, and an expected result dimension; under the guidance of the first role prompt words and the content understanding prompt words, a first test engineer performs multi-dimensional content understanding on the operation document to obtain test key information, including: under the guidance of the first role prompt words, the first test engineer performs multi-dimensional content understanding on the operation document from the use case name dimension, the function description dimension, the operation step dimension, the precondition dimension, and the expected result dimension to obtain the use case name, the function description, the test step, the precondition, and the expected result corresponding to the function point as the test key information.

[0131] In an optional embodiment, the test steps in the test case are mapped to operation description information of the target interface element by using the second intelligent agent and its associated script generation model in combination with the element information knowledge base, and the executable test script is generated according to the target interface element and the corresponding operation description information, including: inputting the test case into the second intelligent agent, generating a second prompt word according to the test case, and using the second prompt word to guide the script generation model to convert the test case into an executable test script in the role of a second test engineer; according to the second prompt word, the script generation model is called, and under the guidance of the second prompt word, the test steps in the test case are mapped to operation description information of the target interface element in combination with the element information knowledge base, and the executable test script is generated according to the target interface element and the corresponding operation description information.

[0132] In an optional embodiment, the second prompt word is generated according to the test case, including: 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 further 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 position the interface element and the operation behavior of the second input prompt word in combination with the element information knowledge base; and 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.

[0133] In an optional embodiment, under the guidance of the second prompt word, the test steps in the test case are mapped to the operation description information of the target interface element in combination with the element information knowledge base, and the executable test script is generated according to the target interface element and the corresponding operation description information, including: the second prompt word is analyzed 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 including the test case; under the guidance of the second role prompt word and the positioning prompt word, the test steps in the test case are mapped to the operation description information of the target interface element in combination with the element information knowledge base in the role of the second test engineer; under the guidance of the script generation prompt word, the executable test script is generated based on the target interface element and the corresponding operation description information.

[0134] In an optional embodiment, the test steps in the test case are mapped to the operation description information of the target interface element in combination with the element information knowledge base in the role of the second test engineer, including: the test steps in the test case are analyzed in the role of the second test engineer to obtain the operation behavior information of the target interface element described in natural language; the operation behavior information of the target interface element described in natural language is converted into the identification of the target interface element and the operation instruction according to the text keyword and / or operation context information of at least one interface element recorded in the element information knowledge base; the identification of the target interface element is matched in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical position information of the target interface element on the target page; the identification of the target interface element, the operation instruction and the logical position information are taken as the operation description information of the target interface element.

[0135] In an optional embodiment, the processor 55 is further configured to: record the traffic data generated by the user interacting with the software to be tested by using the monitoring service; extract the operation instruction, the identification 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; extract the text keyword of the interface element operated by the operation instruction, and add the operation context information to the interface element operated by the operation instruction; and store the operation instruction, the identification of the interface element operated by the operation instruction, the text keyword and the operation context information 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 into the element information knowledge base.

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

[0137] Further, asFigure 6 As shown, the test device further includes a communication component 56, a display 57, a power supply component 58, an audio component 59, and other components. Figure 6 Some components are only schematically shown in the drawings and do not mean that the test device only includes Figure 6 the components shown. In addition, Figure 6 The components in the dashed box in the drawings are optional components rather than mandatory components, and can be determined according to the product form of the working node. The working node of the present embodiment can be implemented as a terminal device such as a desktop computer, a notebook computer, a smart phone, or an IOT device, or a server device such as a conventional server, a cloud server, or a server array. If the working node of the present embodiment is implemented as a terminal device such as a desktop computer, a notebook computer, or a smart phone, it can include Figure 6 the components in the dashed box in the drawings; if the working node of the present embodiment is implemented as a server device such as a conventional server, a cloud server, or a server array, it can not include Figure 6 the components in the dashed box in the drawings.

[0138] The detailed implementation and beneficial effects of each step in the present embodiment have been described in detail in the foregoing embodiments, and will not be described in detail here.

[0139] The above-mentioned memory can be implemented by any type of volatile or non-volatile storage 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.

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

[0141] The display includes a screen, which can include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding movement, but also detect a duration and a pressure associated with the touching or the sliding movement.

[0142] The power component provides power to various components of the device in which the power component is located. The power component can include a power management system, one or more power sources, and other components associated with generating, managing and distributing power to the device in which the power component is located.

[0143] The audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) that is configured to receive an external audio signal when the device in which the audio component is located is in an operational mode, such as a call mode, a recording mode and a voice recognition mode. The received audio signal can be further stored in a memory or transmitted via the communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0144] Accordingly, the embodiments of the present application also provide a computer readable storage medium storing a computer program, when the computer program is executed by a processor, the processor is enabled to implement each step in the above-mentioned method embodiments. The computer readable storage medium includes volatile or non-volatile or a combination thereof, and can be removable or non-removable. Examples of the computer readable storage medium 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, compact disc read-only memory (CD-ROM), digital video disc (DVD) or other optical storage, magnetic cassette, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium

[0145] Accordingly, the embodiments of the present application also provide a computer program product, which comprises computer programs or instructions, and when the computer programs or instructions are executed by a processor, the processor can realize each step in the above-mentioned method embodiments. It should be understood that each process or a combination of multiple processes in the above-mentioned method flow can be realized by the computer programs or instructions. In addition, these computer programs or instructions can be applied to the processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing devices, so that the processor of the general-purpose computer, the special-purpose computer, the embedded processor or other programmable data processing devices can be realized as an apparatus for realizing the corresponding functions in the above-mentioned method embodiments.

[0146] It should also be noted that the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles or devices including a series of elements not only include those elements, but also include other elements not explicitly listed, or further include elements inherent in such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device including the element.

[0147] The above is only an embodiment of the present application and is not intended to limit the present application. The present application can have various changes and modifications for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the scope of claims of the present application.

Claims

1. A method for generating test scripts, characterized in that, include: Obtain the operation document of the software to be tested, wherein the software to be tested includes functional points, and the operation document includes functional description information and operation guidance information of the functional points; By combining the text keywords of at least one interface element recorded in the element information knowledge base, the text description of the interface element in the operation document is corrected; the element information knowledge base records the text keywords and operation context information of at least one interface element involved in the software to be tested. Using the first intelligent agent and its associated use case generation model, the revised operation document is analyzed to obtain key test information, and test cases described in natural language are generated based on the key test information. Using a second intelligent agent and its associated script generation model, combined with text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the test steps in the test case are mapped to operation description information of the target interface element. An executable test script is generated based on the target interface element and its corresponding operation description information. The operation description information includes the logical position information of the target interface element on its page. The logical position information is a dynamic path obtained based on the relative position and structural relationship between interface elements, which is used to accurately locate interface elements when the interface structure changes. The element information knowledge base is constructed based on traffic data generated by user interaction with the trial and / or test versions of the software under test, including the mapping relationship between interface elements and operation description information of the software under test.

2. The method according to claim 1, characterized in that, Using a first intelligent agent and its associated use case generation model, content understanding is performed on the revised operation document to obtain key test information. Based on the key test information, test cases described in natural language are generated, including: The operation document is input into the first intelligent agent, and a first prompt word is generated based on the operation document. The first prompt word is used to guide the test case generation model to convert the operation document into test cases described in natural language in the role of the first test engineer. The test case generation model is invoked based on the first prompt word. Guided by the first prompt word, the first test engineer interprets the operation document to obtain key test information and generates test cases described in natural language based on the key test information.

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

4. The method according to claim 2, characterized in that, Guided by the first prompt, the first test engineer, acting as the first engineer, interprets the operation document to obtain key test information. Based on this key test information, test cases described in natural language are generated, including: The first prompt word is parsed 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; Guided by the first role prompt and the content understanding prompt, the first test engineer performs multi-dimensional content understanding of the operation document in order to obtain the key test information. Guided by the test case generation prompts, test cases described in natural language are generated based on the key test information.

5. The method according to claim 4, characterized in that, The content understanding prompts indicate multiple dimensions for content understanding, including: use case name dimension, function description dimension, operation steps dimension, preconditions dimension, and expected result dimension. Guided by the first role prompt and the content understanding prompt, the first test engineer performs a multi-dimensional content understanding of the operation document to obtain the key test information, including: Guided by the first role prompt, the first test engineer, in the role of the first test engineer, performs a multi-dimensional understanding of the operation document from the dimensions of test case name, function description, operation steps, preconditions, and expected results, so as to obtain the test case name, function description, test steps, preconditions, and expected results corresponding to the function point as the key test information.

6. The method according to any one of claims 1-5, characterized in that, Using a second intelligent agent and its associated script generation model, combined with text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the test steps in the test case are mapped to operation description information of the target interface element. An executable test script is generated based on the target interface element and its corresponding operation description information, including: The test cases are input into the second intelligent agent, and a second prompt word is generated based on the test cases. The second prompt word is used to guide the script generation model to convert the test cases into executable test scripts in the role of a second test engineer. The script generation model is invoked based on the second prompt word. Under the guidance of the second prompt word, and combined with the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the test steps in the test case are mapped to operation description information of the target interface element. An executable test script is generated based on the target interface element and its corresponding operation description information.

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

8. The method according to claim 6, characterized in that, Guided by the second prompt word, and combining the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the test steps in the test case are mapped to operation description information of the target interface element. An executable test script is generated based on the target interface element and its corresponding operation description information, including: The second prompt word is parsed to obtain the second input prompt word, the second role prompt word, the location prompt word, and the script-generated prompt word, wherein the second input prompt word includes the test case; Guided by the second role prompt and the location prompt, the second test engineer, in the role of the second test engineer, combined with the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, maps the test steps in the test case to operation description information of the target interface element. Guided by the prompts generated by the script, an executable test script is generated based on the target interface elements and their corresponding operation descriptions.

9. The method according to claim 8, characterized in that, In the role of the second test engineer, combining the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the test steps in the test case are mapped to operation description information of the target interface element, including: In the role of the second test engineer, the test steps in the test cases are analyzed to obtain information on the operation behavior of the test steps on the target interface elements, described in natural language. Based on the text keywords and / or operation context information of at least one interface element recorded in the element information knowledge base, the operation behavior information of the test steps described in natural language on the target interface element is converted into the identifier and operation instructions of the target interface element. Based on the identifier of the target interface element, a match is made in the structure tree of at least one page recorded in the element information knowledge base to obtain the logical position information of the target interface element on the target page. The identifier, operation instructions, and logical location information of the target interface element are used as the operation description information of the target interface element.

10. The method according to any one of claims 1-5 and 7-9, characterized in that, Also includes: The monitoring service records the traffic data generated by the user's interaction with the software under test. Extract the operation instructions, the identifiers 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 from the traffic data. Extract the 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; The operation instruction, the identifier of the interface element operated by the operation instruction, the text keyword and operation context information, and the structure tree of the page to which the interface element operated by the operation instruction belongs are stored in the element information knowledge base.

11. The method according to any one of claims 1-5 and 7-9, characterized in that, Also includes: Monitor whether the element information knowledge base has changed; If a change is detected in the element information knowledge base, 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.

12. 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 of the method according to any one of claims 1-11.

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

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

Citation Information

Patent Citations

  • Software test apparatus and test method

    CN101339534A

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

    CN110413524A

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

    CN118170686A

  • Test method, device, equipment and medium

    CN120011219A