A test script generation method, device, equipment, medium and program product

CN122963939APending Publication Date: 2026-10-23CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610988753.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-03
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0003]本申请通过一种测试脚本的生成方法、装置、设备、介质和程序产品,解决了现有技术中基于录制/回放的工具(如Selenium IDE)生成的脚本依赖脆弱的CSS/XPath选择器,UI稍变即失效而导致的脚本脆弱问题,以及由于录制工具仅记录操作,无法自动生成验证点(断言)和覆盖反向、边界等测试场景而导致的逻辑缺失问题以及由于测试脚本创建与维护脱节导致的维护困难问题

Benefits of technology

[0015]本申请通过一种测试脚本的生成方法,包括:根据用户针对目标应用进行示例测试时的操作以及在操作过程中所述目标应用的页面信息生成增强型操作序列;根据所述增强型操作序列确定所述示例测试中所涉及的操作类型;根据所述操作类型、所述增强型操作序列以及针对所述目标应用预设的领域知识库确定生成测试脚本的测试大纲;根据所述测试大纲生成针对所述目标应用的测试脚本。解决了现有技术中基于录制/回放的工具(如Selenium IDE)生成的脚本依赖脆弱的CSS/XPath选择器,UI稍变即失效而导致的脚本脆弱问题,以及由于录制工具仅记录操作,无法自动生成验证点(断言)和覆盖反向、边界等测试场景而导致的逻辑缺失问题以及由于测试脚本创建与维护脱节导致的维护困难问题。实现了强健壮、高逻辑以及长期复用的测试脚本生成。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122963939A_ABST
    Figure CN122963939A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of test script generation, and particularly relates to a test script generation method, device, equipment, medium and program product. The test script generation method, device, equipment, medium and program product solve the script fragility problem caused by the fact that the script generated by the existing technology based on recording / playback tools (such as Selenium IDE) depends on fragile CSS / XPath selectors, and the UI is invalid after being slightly changed, and solve the logic missing problem caused by the fact that the recording tool only records operations, and cannot automatically generate verification points (assertions) and cover reverse, boundary and other test scenarios, and solve the maintenance difficulty problem caused by the fact that test script creation and maintenance are disconnected. The test script generation is robust, strong, high-logic and long-term reusable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of test script generation, and specifically relates to a method, apparatus, device, medium, and program product for generating test scripts. Background Technology

[0002] With the ever-accelerating pace of software delivery, the introduction of DevOps (Development and Operation) into the software development process can greatly ensure the quality and efficiency of software delivery. Automated testing has become a key element for the successful implementation of DevOps. Since web applications primarily provide users with page operations and interactions, the efficiency of writing, success rate, and maintenance cost of their UI automated testing scripts largely determine the delivery pace and quality. However, current test scripts suffer from vulnerabilities, logical gaps, and maintenance difficulties. Vulnerability stems from the fact that scripts generated by recording / playback tools (such as Selenium IDE) rely on fragile CSS / XPath selectors, becoming ineffective with slight UI changes. Logical gaps arise because recording tools only record operations and cannot automatically generate verification points (assertions) or cover reverse and boundary test scenarios. Maintenance difficulties arise from the disconnect between test script creation and maintenance, leading to high script maintenance costs during application iterations. Summary of the Invention

[0003] This application addresses the vulnerabilities of existing test script generation technologies through a method, apparatus, device, medium, and program product. These solutions address the issues of scripts generated by recording / playback tools (such as Selenium IDE) being susceptible to fragility due to their reliance on fragile CSS / XPath selectors and failure with slight UI changes; logical gaps caused by recording tools only recording operations and failing to automatically generate verification points (assertions) or cover reverse and boundary test scenarios; and maintenance difficulties resulting from the disconnect between test script creation and maintenance. The application achieves robust, logically sound, and long-term reusable test script generation.

[0004] To address the aforementioned technical problems, this application proposes five aspects.

[0005] In a first aspect, this application proposes a method for generating test scripts, comprising: generating an enhanced operation sequence based on user operations during example testing of a target application and page information of the target application during the operation; determining the operation type involved in the example test based on the enhanced operation sequence; determining a test outline for generating test scripts based on the operation type, the enhanced operation sequence, and a pre-set domain knowledge base for the target application; and generating a test script for the target application based on the test outline.

[0006] In some embodiments, generating an enhanced operation sequence based on the user's actions during example testing of the target application and the page information of the target application during the operations includes: acquiring each operation performed by the user during example testing of the target application and the page information of the target page at the time of each operation; determining multi-dimensional features of the elements corresponding to each operation based on the page information; generating a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation; associating the current operation, the multi-dimensional element fingerprint, and the page information of the same operation to form an operation-element mapping graph; and converting the operation-element mapping graph into the enhanced operation sequence based on the temporal relationship of each operation.

[0007] In some embodiments, determining the test outline for generating test scripts based on the operation type, the enhanced operation sequence, and a pre-defined domain knowledge base for the target application includes: using a logic inference agent to determine the reverse test scenario, boundary test scenario, and forward test scenario corresponding to each operation based on the operation type, the page information, and the domain knowledge base; generating a test logic outline based on the enhanced operation sequence of each operation; using an assertion generation agent to generate semantic test assertions for each scenario in the test logic outline; and associating the test assertions with each scenario in the test logic outline to generate the test outline.

[0008] In some embodiments, the multi-dimensional features include: semantic features of the element, structural features of the element, visual features of the element, content features of the element, and state features of the element; generating a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation includes: aggregating the semantic features, structural features, visual features, content features, and state features of the element with the operation mode and operation value of the current operation in a preset format to generate a multi-dimensional element fingerprint of the element; wherein, the structural features include: the stable relative path of the element in the DOM tree and the positional relationship with neighboring elements; the state features include: the visibility of the element, whether it is interactive, whether it is disabled, and whether it is selected / checked.

[0009] In some embodiments, the method further includes: when the test script fails to test the target application, obtaining failure information at the time of the test failure; and determining the cause of the failure based on the failure information.

[0010] In some embodiments, when the failure reason is a script locator failure, the method further includes: determining a failed operation based on the failure information; determining a multidimensional element fingerprint corresponding to the failed operation in the operation-element mapping graph based on the failed operation; obtaining an operation page corresponding to the failed operation; generating candidate element fingerprints based on each element in the operation page; determining a target element fingerprint in the candidate element fingerprints based on the similarity between each candidate element fingerprint and the multidimensional element fingerprint; updating the multidimensional element fingerprint corresponding to the failed operation based on the target element fingerprint; and determining the enhanced operation sequence based on the updated operation-element mapping graph.

[0011] Secondly, this application proposes a test script generation apparatus, comprising: a first execution module, configured to generate an enhanced operation sequence based on user operations during example testing of a target application and page information of the target application during the operation; a first determination module, configured to determine the operation type involved in the example test based on the enhanced operation sequence; a second determination module, configured to determine a test outline for generating the test script based on the operation type, the enhanced operation sequence, and a pre-set domain knowledge base for the target application; and a second execution module, configured to generate a test script for the target application based on the test outline.

[0012] Thirdly, this application proposes an electronic device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in any of the first aspects.

[0013] Fourthly, this application proposes a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of the method described in any one of the first aspects.

[0014] Fifthly, this application proposes a computer program product, including a computer program, characterized in that, when executed by a processor, the computer program implements the steps of the method described in any one of the first aspects.

[0015] This application provides a method for generating test scripts, comprising: generating an enhanced operation sequence based on user operations during example testing of a target application and page information of the target application during the operation; determining the operation types involved in the example test based on the enhanced operation sequence; determining a test outline for generating test scripts based on the operation types, the enhanced operation sequence, and a pre-defined domain knowledge base for the target application; and generating test scripts for the target application based on the test outline. This method solves the problems of script fragility in existing technologies, where scripts generated by recording / playback tools (such as Selenium IDE) rely on fragile CSS / XPath selectors and fail with slight UI changes; logical gaps caused by recording tools only recording operations and failing to automatically generate verification points (assertions) and cover reverse and boundary test scenarios; and maintenance difficulties caused by the disconnect between test script creation and maintenance. It achieves robust, highly logical, and long-term reusable test script generation. Attached Figure Description

[0016] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrative descriptions do not constitute a limitation on the embodiments.

[0017] Figure 1 The main flowchart of a test script generation method provided in this application embodiment; Figure 2 A main structural block diagram of a test script generation device provided in an embodiment of this application; Figure 3 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0018] With the ever-accelerating pace of software delivery, the introduction of DevOps (Development and Operation) into the software development process can greatly ensure the quality and efficiency of software delivery. Automated testing has become a key element for the successful implementation of DevOps. Since web applications primarily provide users with page operations and interactions, the efficiency of writing, success rate, and maintenance cost of their UI automated testing scripts largely determine the delivery pace and quality. However, current test scripts suffer from vulnerabilities, logical gaps, and maintenance difficulties. Vulnerability stems from the fact that scripts generated by recording / playback tools (such as Selenium IDE) rely on fragile CSS / XPath selectors, becoming ineffective with slight UI changes. Logical gaps arise because recording tools only record operations and cannot automatically generate verification points (assertions) or cover reverse and boundary test scenarios. Maintenance difficulties arise from the disconnect between test script creation and maintenance, leading to high script maintenance costs during application iterations.

[0019] To address the aforementioned technical problems, this invention proposes a method for generating test scripts. The implementation details of this method are described below. The following content is for illustrative purposes only and is not essential for implementing this solution.

[0020] Example 1: like Figure 1 As shown, this application provides a method for generating test scripts, applicable to electronic production equipment, which can be a server, mobile terminal, computer, cloud platform, etc. The functions implemented by the data processing of the production equipment provided in this application embodiment can be achieved by the processor of the electronic production equipment calling program code, wherein the program code can be stored in a computer storage medium. The method for generating test scripts includes: Step S1: Generate an enhanced operation sequence based on the user's actions during the example test of the target application and the page information of the target application during the operation.

[0021] In some embodiments, step S1, "generating an enhanced operation sequence based on the user's actions during example testing of the target application and the page information of the target application during the operation," includes: Step S11: Obtain each operation performed by the user during the example test of the target application, and the page information of the target page when each operation is executed.

[0022] When a user performs an exemplary operation on the target application, tools such as Playwright are used to capture the user's operation events in real time, as well as the page information of the page the user is on at the time of the operation. The page information includes multi-dimensional features of each element on the page, the URL in the browser address bar (identifying which page or route the user is on), possible frame / iframe layers, network activity summaries (such as recently completed API requests, used to understand asynchronously loaded data), and the visible scroll position of the page.

[0023] Step S12: Determine the multi-dimensional features of the element corresponding to each operation based on the page information.

[0024] The multi-dimensional features of the element corresponding to the operation include: semantic features of the element, structural features of the element, visual features of the element, content features of the element, and state features of the element.

[0025] Semantic features: Element's ARIA role, accessible name, localized tags (such as associated tags) <label>text).

[0026] Structural characteristics: The element’s stable relative path in the DOM tree (e.g., a path down from the nearest ancestor with the data-testid or id attribute, avoiding absolute paths), and its positional relationship with neighboring elements with the data-testid attribute (e.g., "inside the div with id='login-form', after the 3rd input").

[0027] Visual / content features: the element's internal text (textContent), placeholder, value, CSS class name (excluding dynamically generated index classes), and key CSS properties (such as display, visibility), etc.

[0028] State characteristics: the visibility of an element, whether it is interactive, whether it is disabled, whether it is selected / checked, etc.

[0029] Step S13: Generate a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation.

[0030] In some embodiments, step S13, "generating a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation," includes: Step S131: Aggregate the semantic features, structural features, visual features, content features, and state features of the element with the operation mode and operation value of the current operation in a preset format to generate a multidimensional element fingerprint of the element.

[0031] The above features are aggregated in JSON format, along with the operation type (click / input / select, etc.) and operation value (such as the input text), to form the "multidimensional element fingerprint" of this step.

[0032] This invention extracts five major categories of features simultaneously: semantic, structural, visual, content, and state, and generates a complete fingerprint for each manipulated element in real time and dynamically. This fingerprint is then used to intelligently generate test logic and closed-loop self-healing matching.

[0033] Step S14: Associate the current operation, the multidimensional element fingerprint, and the page information of the same operation to form an operation-element mapping graph.

[0034] Step S15: Convert the operation-element mapping graph into the enhanced operation sequence according to the temporal relationship of each operation.

[0035] The multidimensional element fingerprints obtained above can only prove the characteristics of elements on the page. However, to generate test scripts, it is necessary to associate these multidimensional features of elements with operations. Therefore, this application associates the operations, multidimensional element fingerprints, and page information corresponding to the same operation to form an operation-element mapping graph. The graph is a directed graph with step nodes as vertices and temporal relationships as edges. Each node contains: operation + multidimensional element fingerprint + page information. The graph stores a complete and structured representation of all recorded information.

[0036] An enhanced operation sequence is a view extracted from a graph: it unfolds the graph in chronological order to form a linear sequence, where each element is an "enhanced operation unit," meaning the original operation is accompanied by rich fingerprints and contextual information.

[0037] The specific conversion method is as follows: Extract all nodes from the graph and sort them in ascending order according to the timestamp or stepIndex field. For each node, serialize its three parts (action event, element fingerprint, and page information) into a structured JSON object. Place all nodes sequentially into an array, which is the enhanced action sequence.

[0038] Step S2: Determine the type of operation involved in the example test based on the enhanced operation sequence.

[0039] By clustering nodes in the enhanced operation sequence using an operational analysis agent, the operation type can be identified, such as "login process" or "product search process".

[0040] This invention uses an enhanced operation sequence, rather than the original operation sequence. The original operation sequence only records event types and simple parameters such as "what was clicked" and "what was entered," lacking the multi-dimensional element fingerprints, page information, and other information required by the subsequent agent. In contrast, the enhanced operation sequence in this invention provides rich semantic, structural, visual, and contextual data for each operation step. This is the necessary foundation for the operation analysis agent to perform clustering and for the logical inference agent to infer counterexamples / boundaries.

[0041] Step S3: Determine the test outline for generating test scripts based on the operation type, the enhanced operation sequence, and the domain knowledge base preset for the target application.

[0042] In some embodiments, step S3, "determining a test outline for generating test scripts based on the operation type, the enhanced operation sequence, and a pre-defined domain knowledge base for the target application," includes: Step S31: Using a logic inference agent, determine the reverse test scenario, boundary test scenario, and forward test scenario corresponding to each operation based on the operation type, the page information, and the domain knowledge base.

[0043] Step S32: Generate a test logic outline based on the enhanced operation sequence of each operation.

[0044] The logical inference agent in this application can extract semantic information of the current page from page information, wherein the semantic information includes: accessibility attributes, tag text, ARIA roles, type attributes (such as...). <input type="password"> The "meaningful information" is extracted from elements such as placeholders. It originates from the browser's Accessibility API and DOM API calls during the recording phase. For example, an element with role="button" and text "login" has the semantic meaning of "login button"; an input with type="password" has the semantic meaning of "password input box".

[0045] The logical inference intelligent projection in this application can utilize the element semantics of each step (e.g., discovering a password input box) and combine it with business rules in the knowledge base (e.g., "incorrect password should prompt and allow retry") to automatically infer the reverse scenario: the user succeeded during recording, but the system should test "login failed after entering an incorrect password and display a prompt".

[0046] At the same time, based on the type and constraints of the input box (such as the maximum length of the username), and combined with common boundary rules in the knowledge base, boundary scenarios are generated: empty username, empty password, exceeding the character limit, etc.

[0047] In this application, possible reverse testing scenarios, possible boundary testing scenarios, and possible forward testing scenarios for the current operation can be determined first based on the operation type and a preset domain knowledge base. Then, based on semantic information, the reverse testing scenarios, boundary testing scenarios, and forward testing scenarios that match the current operation and page can be determined from these possible scenarios.

[0048] Then, the reverse test scenarios, boundary test scenarios, and forward test scenarios for each operation are merged to form the logical structure of each operation. The logical structure of each operation is then written into the enhanced operation sequence to form a complete test logic outline covering multiple scenarios. This outline is more comprehensive than the operation sequence recorded by the user.

[0049] Step S33: Use assertion generation agent to generate semantic test assertions for each scenario in the test logic outline.

[0050] Step S34: Associate the test assertions with the various scenarios in the test logic outline to generate the test outline.

[0051] This application asserts intelligent agents as key steps in each scenario of the test logic outline, automatically generating semantic test assertions, such as "should redirect to the user center page" and "should display 'incorrect password' message". Then, the test assertions are associated with the corresponding scenarios to generate a highly logical test outline.

[0052] The core function and purpose of this step is not to provide "reference test results," but to achieve an intelligent leap from "recording an operation" to "automatically generating a complete test suite." Specifically: Function: Solves the pain point of "lack of logic" in traditional recording tools. The user only demonstrates a successful operation once, but the system can automatically generate multiple test cases, including positive examples, negative examples, and boundary conditions.

[0053] Results: Significantly improves test coverage, reduces the workload of manually writing test cases, and can automatically discover abnormal scenarios that are easily overlooked by humans (such as incorrect passwords, empty inputs, exceeding limits, etc.).

[0054] Objective: To allow testers to understand business semantics and automatically expand test logic simply by demonstrating the normal process once, without having to record or write scripts for each exception.

[0055] Step S4: Generate a test script for the target application based on the test outline.

[0056] Once the test outline is obtained, the code optimization agent can be used to convert the test outline into the final executable test script (such as Playwright+Jest) and automatically apply best practices, such as prioritizing robust locators like getByRole, adding smart waits, and extracting the Page Object (POM).

[0057] In some embodiments, the method further includes: Step S51: When the test script fails to test the target application, obtain the failure information when the test fails.

[0058] Step S52: Determine the cause of failure based on the failure information.

[0059] When testing a target application using test scripts, test failures are inevitable. However, identifying the cause of the failure is crucial. Some failures may be application-related, such as due to defective references; others may be caused by problems with the test script itself; and still others may be due to environmental or timing instability. Therefore, it is necessary to determine the cause of the failure based on the failure information.

[0060] Specifically, this application categorizes failure reasons into three types: Type A: application functional defects, Type B: environment / timing issues, and Type C: script locator failure. For each of these three types of failure reasons, this application proposes a corresponding failure reason determination strategy.

[0061] For Category A (application functional defects): When the test script fails to execute, if the locator successfully finds the element and performs the operation, but subsequent assertions fail (such as the page not redirecting or the expected text not existing), or if the network request returns a 500 error or a business error code, the system determines it to be a functional defect of the application itself.

[0062] For Category B (Environment / Timing Issues): When failure is accompanied by timeout exceptions, network connection errors, incomplete page loading, or screenshots showing the page in an unexpected state (such as a blank page or an error page), and re-execution of the same script occasionally succeeds, it is classified as an environment or timing instability issue.

[0063] For Category C (Script Locator Failure): When the exception message clearly points to an element not found (such as "Element not found" or "Locator failed"), and the multi-dimensional element fingerprint of the step can be extracted from the historical "operation-element mapping graph" corresponding to the failed step, the system attempts to match the fingerprint in the current DOM. If the match fails or the locator cannot uniquely identify the element, it is classified as a locator failure.

[0064] Type A failures require handling by the application's R&D personnel, while Type B failures can be resolved through retries or environmental adjustments. Type C failures, however, require updating and correcting the test scripts. Current technologies necessitate manual intervention to fix script issues, which is costly, and existing root cause analysis techniques do not recognize the specific failure type of "script aging."

[0065] Therefore, in some embodiments, when the failure reason is that the script locator has failed, the method further includes: Step S53: Determine the failed operation based on the failure information.

[0066] Step S54: Determine the multidimensional element fingerprint corresponding to the failed operation in the operation-element mapping graph based on the failed operation.

[0067] Step S55: Obtain the operation page corresponding to the failed operation.

[0068] Step S56: Generate candidate element fingerprints based on each element in the operation page.

[0069] Step S57: Determine the target element fingerprint from the candidate element fingerprints based on the similarity between each candidate element fingerprint and the multidimensional element fingerprint.

[0070] Extract the multidimensional element fingerprint from the historical operation-element mapping graph corresponding to the failed step. Then, in the DOM of the page corresponding to the failed operation, perform multidimensional feature similarity matching based on this multidimensional element fingerprint to locate the changed new element.

[0071] When performing similarity matching, it is necessary to generate multi-dimensional element fingerprints for all elements on the operation page. For ease of differentiation, the multi-dimensional element fingerprints of each element on the operation page corresponding to the failed operation are called candidate element fingerprints. These candidate element fingerprints are then matched with the multi-dimensional element fingerprints corresponding to the failed operation. Similarity matching allows for a certain degree of difference. By weighting the matching degree of each feature dimension, the candidate element with the most similarity is selected. Even if some features change (such as the CSS class name changes, but the text and role remain the same), the target can still be found.

[0072] Specifically, this application can use five categories of element fingerprint features (semantic features: ARIA roles, accessible names; structural features: stable relative paths, neighboring element relationships; visual / content features: internal text, placeholders, CSS class names; state features: visibility, interactivity, etc.). Each feature is assigned a different weight (e.g., semantic features have the highest weight). First, the candidate set is narrowed down using various fast strategies (e.g., role, text). Then, the real-time fingerprint of each candidate element fingerprint is extracted, and the weighted similarity score with the multi-dimensional element fingerprint across various features is calculated. The candidate element fingerprint with the highest score exceeding a threshold (e.g., 85%) is selected as the target element fingerprint. If no candidate reaches the threshold, automatic repair is not performed, and manual intervention is prompted.

[0073] Step S58: Update the multidimensional element fingerprint corresponding to the failed operation based on the target element fingerprint.

[0074] Step S59: Determine the enhanced operation sequence based on the updated operation-element mapping graph.

[0075] After determining the target element fingerprint, the multidimensional element fingerprint corresponding to the failed operation is updated using the target element fingerprint, and then step S15 and the candidate steps are re-executed to complete the update of the test script.

[0076] This application addresses the vulnerability and maintenance difficulties of existing technologies by binding operations to multi-dimensional element fingerprints. This allows for script updates based on UI changes, resolving the script fragility issue. Furthermore, the application utilizes logical inference and assertion generation agents to generate highly logical test outlines based on the multi-dimensional element features and page information corresponding to each operation, thus resolving the script logic gap issue in existing technologies. Consequently, the generated test scripts automatically adjust to UI changes, achieving automatic program evolution. This eliminates the need for manual maintenance, provides high adaptability to the application under test, and ensures a more rigorous and comprehensive testing process.

[0077] Example 2: Based on the foregoing embodiments, this application provides a test script generation device. The modules and units included in the device can be implemented by a processor in a computer device; of course, they can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0078] like Figure 2 As shown, the generation of a test script includes: a first execution module 1, a first determination module 2, a second determination module 3, and a second execution module 4.

[0079] The first execution module 1 is used to generate an enhanced operation sequence based on the user's operations during example testing of the target application and the page information of the target application during the operation. The first determination module 2 is used to determine the operation types involved in the example test based on the enhanced operation sequence. The second determination module 3 is used to determine a test outline for generating test scripts based on the operation types, the enhanced operation sequence, and a preset domain knowledge base for the target application. The second execution module 4 is used to generate a test script for the target application based on the test outline.

[0080] In some embodiments, the first execution module 1 is further configured to acquire each operation performed by the user for example testing of the target application and the page information of the target page when each operation is executed; determine the multi-dimensional features of the element corresponding to each operation based on the page information; generate a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation; associate the current operation, the multi-dimensional element fingerprint, and the page information of the same operation with each other to form an operation-element mapping graph; and convert the operation-element mapping graph into the enhanced operation sequence according to the time relationship of each operation.

[0081] In some embodiments, the second determining module 3 is further configured to use a logic inference agent to determine the reverse test scenario, boundary test scenario, and forward test scenario corresponding to each operation based on the operation type of each operation, the page information, and the domain knowledge base; generate a test logic outline based on the enhanced operation sequence of each operation; generate semantic test assertions for each scenario in the test logic outline using an assertion generation agent; and associate the test assertions with each scenario in the test logic outline to generate the test outline.

[0082] In some embodiments, the first execution module is further configured to: aggregate the semantic features, structural features, visual features, content features, and state features of an element with the operation mode and operation value of the current operation in a preset format to generate a multidimensional element fingerprint of the element; wherein, the structural features include: the stable relative path of the element in the DOM tree and the positional relationship between the element and its neighboring elements; the state features include: the visibility of the element, whether it is interactive, whether it is disabled, and whether it is selected / checked.

[0083] When the test script fails to test the target application, the device is further configured to: obtain failure information when the test fails; and determine the cause of failure based on the failure information.

[0084] When the failure reason is script locator failure, the device is further configured to: determine the failed operation based on the failure information; determine the multidimensional element fingerprint corresponding to the failed operation in the operation-element mapping graph based on the failed operation; obtain the operation page corresponding to the failed operation; generate candidate element fingerprints based on each element in the operation page; determine the target element fingerprint in the candidate element fingerprints based on the similarity between each candidate element fingerprint and the multidimensional element fingerprint; update the multidimensional element fingerprint corresponding to the failed operation based on the target element fingerprint; and determine the enhanced operation sequence based on the updated operation-element mapping graph.

[0085] The modules in the aforementioned test script generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor within the device in hardware form, or stored in the memory of the processing device in software form, so that the processor can call and execute the operations corresponding to each module. It should be noted that the module division in this embodiment is illustrative and represents only a logical functional division; in actual implementation, other division methods may be used.

[0086] Example 3: Thirdly, this application provides an electronic device, such as Figure 3 As shown, it includes: at least one processor 100; and a memory 200 communicatively connected to the at least one processor 100; wherein the memory 200 stores instructions executable by the at least one processor 100, the instructions being executed by the at least one processor 100 to enable the at least one processor 100 to execute a test script generation method of the above embodiments.

[0087] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.

[0088] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.

[0089] In addition, the computer device may include (but is not limited to) a data bus, an input / output (I / O) bus, a display, and input / output devices (e.g., keyboard, mouse, speakers, etc.).

[0090] The processor can communicate with external devices via the I / O bus through wired or wireless networks.

[0091] In one embodiment, the at least one computer-executable instruction may also be compiled into or comprise a software product / computer program product, wherein one or more computer-executable instructions are executed by a processor to perform the steps of the various functions and / or methods in the embodiments described herein.

[0092] Example 4: Fourthly, this application proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any of the first aspects.

[0093] Computer-readable storage media can be implemented by any type of volatile or non-volatile storage device or a combination thereof. Computer-readable storage media may include, but are not limited to, random access memory (RAM), read-only memory (ROM), flash memory, EPROM memory, EEPROM memory, registers, and computer storage media (e.g., hard disks, floppy disks, solid-state drives, removable disks, CD-ROMs, DVD-ROMs, Blu-ray discs, etc.).

[0094] Computer-readable storage media may also store at least one computer-executable program / instruction, such as computer-readable instructions. Computer-readable storage media include, but are not limited to, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Computer-readable storage media may include, for example, read-only memory (ROM), hard disk, flash memory, etc. For example, a non-transitory computer-readable storage medium may be connected to a computing device such as a computer, and then, when the computing device executes the computer-readable instructions stored on the computer-readable storage medium, the various methods described above can be performed.

[0095] Example 5: Fifthly, this application proposes a computer program product, including a computer program / instructions, characterized in that, when the computer program is executed by a processor, it implements the steps of the method described in any one of the first aspects.

[0096] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0097] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0098] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0099] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0100] In the embodiments provided in this disclosure, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0101] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a controller to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0102] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein.

[0103] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.< / label>

Claims

1. A method for generating test scripts, characterized in that, include: An enhanced operation sequence is generated based on the user's actions during sample testing of the target application and the page information of the target application during the operation. The types of operations involved in the example test are determined based on the enhanced operation sequence; A test outline for generating test scripts is determined based on the operation type, the enhanced operation sequence, and a pre-defined domain knowledge base for the target application. Generate test scripts for the target application based on the test outline.

2. The method according to claim 1, characterized in that, The step of generating an enhanced operation sequence based on the user's actions during example testing of the target application and the page information of the target application during the operation includes: Obtain each operation performed by the user during an example test of the target application, as well as the page information of the target page at the time of each operation. Based on the page information, determine the multi-dimensional features of the element corresponding to each operation; Generate a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation; The current operation, the multi-dimensional element fingerprint, and the page information of the same operation are correlated to form an operation-element mapping graph; The operation-element mapping graph is transformed into the enhanced operation sequence based on the temporal relationship of each operation.

3. The method according to claim 2, characterized in that, The step of determining the test outline for generating test scripts based on the operation type, the enhanced operation sequence, and a pre-defined domain knowledge base for the target application includes: The logical inference agent determines the reverse test scenario, boundary test scenario, and forward test scenario corresponding to each operation based on the operation type, the page information, and the domain knowledge base. A test logic outline is generated based on the boundary test scenarios, the reverse test scenarios, and the forward test scenarios for each operation; The assertion-generating agent generates semantic test assertions for each scenario in the test logic outline. The test assertions are associated with the various scenarios in the test logic outline to generate the test outline.

4. The method according to claim 2, characterized in that, The multi-dimensional features include: semantic features of the element, structural features of the element, visual features of the element, content features of the element, and state features of the element; generating a multi-dimensional element fingerprint for the current operation based on the multi-dimensional features and the corresponding current operation includes: The semantic features, structural features, visual features, content features, and state features of an element are aggregated with the operation mode and operation value of the current operation in a preset format to generate a multidimensional element fingerprint of the element; The structural features include: the stable relative path of an element in the DOM tree and its positional relationship with neighboring elements; The state characteristics include: the visibility of the element, whether it is interactive, whether it is disabled, and whether it is selected / checked.

5. The method according to claim 4, characterized in that, The method further includes: When the test script fails to test the target application, obtain the failure information when the test fails; The cause of failure is determined based on the failure information.

6. The method according to claim 5, characterized in that, When the failure reason is that the script locator is invalid, the method further includes: The failed operation is determined based on the failure information; Based on the failed operation, a multidimensional element fingerprint corresponding to the failed operation is determined in the operation-element mapping graph; Obtain the operation page corresponding to the failed operation; Generate candidate element fingerprints based on each element on the operation page; The target element fingerprint is determined from the candidate element fingerprints based on the similarity between each candidate element fingerprint and the multidimensional element fingerprint; Update the multi-dimensional element fingerprint corresponding to the failed operation based on the target element fingerprint; The enhanced operation sequence is determined based on the updated operation-element mapping graph.

7. A test script generation apparatus, characterized in that, include: The first execution module is used to generate an enhanced operation sequence based on the user's operations when performing sample tests on the target application and the page information of the target application during the operation. The first determining module is used to determine the type of operation involved in the example test based on the enhanced operation sequence; The second determining module is used to determine the test outline for generating test scripts based on the operation type, the enhanced operation sequence, and the domain knowledge base preset for the target application. The second execution module is used to generate test scripts for the target application based on the test outline.

8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6.