Test script generation method and device, electronic equipment and storage medium

By recording user operations and calculating similarities to generate test scripts, it solves the problems of high time, cost and poor repeatability caused by traditional manual writing of test cases, achieves efficient and reliable test script generation, and improves test coverage and consistency. sex.

CN118535461APending Publication Date: 2024-08-23GUANGZHOU NENGDI CLOUD SERVICES TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410565726.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-09
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Traditional methods rely on manual writing of test cases, which results in high time consumption, high cost, poor repeatability and consistency, and difficulty in reproducing complex test scenarios.

Method used

Generate initial scripts by recording user operations, obtain historical scripts, calculate the similarity between input data and output data, and generate parameterized or target test scripts if the similarity reaches a specific threshold to improve test coverage and consistency.

Benefits of technology

Reduces the time and cost of manual scripting, improves test repeatability and consistency, and enhances test efficiency and coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535461A
    Figure CN118535461A
Patent Text Reader

Abstract

The embodiment of the invention provides a test script generation method and device, electronic equipment and a storage medium, and belongs to the technical field of testing. The method comprises the steps that user operation is recorded, and an initial script is generated; acquiring a historical script; when the historical script and the initial script contain the same function, calculating the similarity of input data and the similarity of output data between the historical script and the initial script; if the similarity of the input data and the similarity of the output data do not exceed a first similarity threshold and exceed a second similarity threshold, obtaining a parameterized target test script according to the historical script and the initial script, and storing the target test script; and if the similarity of the input data and the similarity of the output data do not exceed a second similarity threshold, obtaining a target test script according to the initial script, and storing the target test script. According to the embodiment of the invention, the time, the workload and the cost of manually writing the script can be reduced, the repeatability and the consistency of the test are improved, and the coverage range and the efficiency of the test are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to a test script generation method and device, an electronic device and a storage medium. Background Art

[0002] In application development, the traditional method is to rely on testers to write test cases to identify functional defects. Manually writing test cases has the following problems:

[0003] 1. Time-consuming

[0004] Inefficiency: Manual execution of test cases, especially for complex applications, can be very time-consuming.

[0005] 2. High cost

[0006] As the number of test cases increases, more manpower is required to perform these tests. Manual testing can be costly in the long run.

[0007] 3. Poor repeatability and consistency

[0008] Human Error: Manual testing is easily affected by factors such as the executor’s skill level, concentration, and fatigue, which may lead to inconsistent test results.

[0009] Difficult to reproduce: Certain complex test scenarios can be difficult to accurately repeat manually, especially tests involving multiple steps or elaborate interactions.

[0010] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention

[0011] The main purpose of the embodiments of the present application is to propose a test script generation method and device, an electronic device and a storage medium, aiming to reduce the time and cost of developing and writing scripts and improve the repeatability and consistency of tests.

[0012] To achieve the above object, an embodiment of the present application provides a test script generation method, the method comprising:

[0013] Record user operations and generate initial scripts;

[0014] Get the history script;

[0015] When the historical script and the initial script contain the same function, calculate the similarity of input data and output data between the historical script and the initial script;

[0016] If the similarity between the input data and the output data does not exceed the first similarity threshold and exceeds the second similarity threshold, a parameterized target test script is obtained according to the historical script and the initial script, and the target test script is saved;

[0017] If the similarity between the input data and the output data does not exceed a second similarity threshold, a target test script is obtained according to the initial script, and the target test script is saved.

[0018] In some embodiments, the method further comprises:

[0019] If the similarity between the input data and the output data exceeds a first similarity threshold, the initial script is deleted.

[0020] In some embodiments, the initial script includes asynchronous requests and dynamically generated elements, and recording user operations to generate the initial script includes:

[0021] Use event listeners to capture asynchronous requests;

[0022] Use XPath or style selectors to listen for dynamically generated elements.

[0023] In some embodiments, the method further comprises:

[0024] Obtaining the execution time of the initial script;

[0025] If the execution time of the initial script exceeds a first execution time threshold, a critical path of the initial script is identified, a target test script is obtained according to the critical path, and the target test script is saved.

[0026] In some embodiments, the method further comprises:

[0027] If the initial script test fails, the reason for the test failure is analyzed by the log analysis system to obtain an analysis result.

[0028] In some embodiments, the method further comprises:

[0029] The initial script is adjusted according to the analysis results.

[0030] In some embodiments, the method further comprises:

[0031] Get a first script set;

[0032] Executing the first script set;

[0033] The execution success rate, code coverage and performance indicators of the first script set are displayed on the real-time monitoring page.

[0034] To achieve the above object, another aspect of an embodiment of the present application provides a test script generating device, the device comprising:

[0035] Recording module, used to record user operations and generate initial scripts;

[0036] A historical script acquisition module is used to obtain historical scripts;

[0037] A calculation module, used for calculating the similarity of input data and output data between the historical script and the initial script when the historical script and the initial script contain the same function;

[0038] A parameterization module, configured to obtain a parameterized target test script according to the historical script and the initial script, and save the target test script if the similarity between the input data and the output data does not exceed a first similarity threshold and exceeds a second similarity threshold;

[0039] A saving module is used to obtain a target test script according to the initial script and save the target test script if the similarity between the input data and the output data does not exceed a second similarity threshold.

[0040] To achieve the above objective, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.

[0041] To achieve the above objectives, a fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0042] The embodiments of the present application include at least the following beneficial effects: the present application provides a test script generation method and device, an electronic device and a storage medium, which generates an initial script by recording user operations, thereby reducing the time, workload and cost of manually writing scripts; obtaining a historical script; when the historical script and the initial script contain the same function, calculating the similarity of input data and output data between the historical script and the initial script; if the similarity of the input data and the similarity of the output data do not exceed the first similarity threshold and exceed the second similarity threshold, obtaining a parameterized target test script based on the historical script and the initial script, saving the target test script, and improving the coverage and efficiency of the test; if the similarity of the input data and the similarity of the output data do not exceed the second similarity threshold, obtaining a target test script based on the initial script, saving the target test script, and improving the repeatability and consistency of the test. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 is a flowchart of a test script generation method provided in an embodiment of the present application;

[0044] Figure 2 is another flow chart of the test script generation method provided in the embodiment of the present application;

[0045] Figure 3 is another flow chart of the test script generation method provided in the embodiment of the present application;

[0046] Figure 4 It is a flowchart of a test script generation method provided in an embodiment of the present application;

[0047] Figure 5 It is a structural diagram of a test script generating device provided in an embodiment of the present application;

[0048] Figure 6 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0050] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0051] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0053] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0054] 1) XPath is a language used to find information in XML documents. XPath is designed to be extensible and can be used for many different document types. XPath is often used to locate elements and attributes in documents for data extraction, manipulation, and query.

[0055] 2) Puppeteer is an open source headless browser Node library developed by Google for controlling Chrome or Chromium browsers. Puppeteer allows developers to use JavaScript to automate various operations on web pages, including page navigation, form submission, simulated user interaction, etc.

[0056] 3) AutoHotkey, is an automation scripting language and program, mainly used in Windows operating system. AutoHotkey allows users to automate repetitive tasks by writing simple scripts, or perform complex operations through customized shortcut keys.

[0057] 4) AJAX (Asynchronous JavaScript and XML) request is a network request technology initiated by JavaScript on a web page. Unlike traditional network requests, AJAX requests are performed in the background and will not block the browser, allowing the page to remain responsive during the request process, while exchanging data with the server and updating part of the web page content.

[0058] In application development, the traditional method is to rely on testers to write test cases to identify functional defects. Manually writing test cases has the following problems:

[0059] 1. Time-consuming

[0060] Inefficiency: Manual execution of test cases, especially for complex applications, can be very time-consuming.

[0061] 2. High cost

[0062] As the number of test cases increases, more manpower is required to perform these tests. Manual testing can be costly in the long run.

[0063] 3. Poor repeatability and consistency

[0064] Human Error: Manual testing is easily affected by factors such as the executor’s skill level, concentration, and fatigue, which may lead to inconsistent test results.

[0065] Difficult to reproduce: Certain complex test scenarios can be difficult to accurately repeat manually, especially tests involving multiple steps or elaborate interactions.

[0066] In view of this, an embodiment of the present application provides a test script generation method and device, an electronic device and a storage medium. The scheme generates an initial script by recording user operations, thereby reducing the time, workload and cost of manually writing scripts; obtaining a historical script; when the historical script and the initial script contain the same function, calculating the similarity of input data and the similarity of output data between the historical script and the initial script; if the similarity of the input data and the similarity of the output data do not exceed the first similarity threshold and exceed the second similarity threshold, then a parameterized target test script is obtained according to the historical script and the initial script, and the target test script is saved to improve the coverage and efficiency of the test; if the similarity of the input data and the similarity of the output data do not exceed the second similarity threshold, then a target test script is obtained according to the initial script, and the target test script is saved to improve the repeatability and consistency of the test.

[0067] The test script generation method provided in the embodiment of the present application relates to the field of test technology. The test script generation method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The cloud server, the server can also be a node server in the blockchain network; the software can be an application that implements the test script generation method, etc., but is not limited to the above forms.

[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0069] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0070] Figure 1 is an optional flowchart of the test script generation method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S105.

[0071] Step S101, recording user operations and generating an initial script.

[0072] This application does not specifically limit the method of recording user operations, and can be flexibly selected in combination with actual test needs. For example, Puppeteer can be used to record user operations, UiPath can be used to record user operations, and AutoHotkey can also be used to record user operations.

[0073] In some embodiments, Puppeteer is used to record user operations. Puppeteer provides a series of APIs that can simulate various user operations.

[0074] Exemplarily, the method of Puppeteer simulating user interaction is as follows:

[0075] await page.click('selector'); / / Click on an element on the page

[0076] await page.type('selector','text'); / / Type text in the selected input box

[0077] await page.evaluate(()=>{window.scrollBy(0,window.innerHeight);}); / / Scroll down on the page

[0078] await page.mouse.move(startX,startY); / / Move the mouse to the starting position

[0079] await page.mouse.down(); / / Press the mouse button

[0080] await page.mouse.move(endX,endY); / / Move the mouse to the end position

[0081] await page.mouse.up(); / / Release the mouse button

[0082] await page.fill('selector','value'); / / Fill form fields

[0083] await page.click('submit-button-selector'); / / Click the submit button

[0084] await page.keyboard.press('Enter'); / / Simulate pressing a keyboard key

[0085] In this embodiment, user operations are recorded to generate an initial script, thereby reducing the time, workload and cost of manually writing scripts.

[0086] Step S102, obtaining the historical script.

[0087] Specifically, the historical script includes the historically saved script and metadata (classification, tags, etc.).

[0088] This application does not make specific restrictions on the historical script, and it can be flexibly selected in combination with actual test needs. Exemplarily, the historical script can be stored in a database or in a server.

[0089] In some embodiments, the historical scripts are obtained from a database.

[0090] In this embodiment, the historical script is obtained to prepare for the subsequent comparison between the historical script and the initial script.

[0091] Step S103, when the historical script and the initial script contain the same function, the similarity of input data and the similarity of output data between the historical script and the initial script are calculated.

[0092] This application does not specifically limit the method for determining whether the historical script and the initial script contain the same function, and can be flexibly selected in combination with actual test needs. For example, a text comparison method can be used to determine whether the historical script and the initial script contain the same function, or an abstract syntax tree method can be used to determine whether the historical script and the initial script contain the same function.

[0093] In some embodiments, an abstract syntax tree method is used to determine whether the historical script and the initial script contain the same function. Specifically, a parser of a programming language is used to convert the code of the historical script and the code of the initial script into an abstract syntax tree, and the abstract syntax trees of the historical script and the initial script are compared. If the corresponding function nodes are the same, the functions are the same.

[0094] This application does not specifically limit the method for calculating the similarity of input data and output data, and can be flexibly selected in combination with actual test needs. For example, a text similarity algorithm can be used to calculate the similarity of input data and output data, a data structure comparison method can be used to calculate the similarity of input data and output data, and a similarity measurement method after feature extraction can be used to calculate the similarity of input data and output data.

[0095] In this embodiment, when the historical script and the initial script contain the same function, the similarity of the input data and the similarity of the output data between the historical script and the initial script are calculated. Through the similarity calculation, the degree of similarity between the historical script and the initial script can be quantified, so as to better judge whether the target test script is obtained and improve the test coverage and efficiency.

[0096] Step S104: if the similarity between the input data and the output data does not exceed the first similarity threshold but exceeds the second similarity threshold, a parameterized target test script is obtained according to the historical script and the initial script, and the target test script is saved.

[0097] Specifically, the first similarity threshold is used to determine whether to generate a target test script, and the second similarity threshold is used to determine whether to parameterize the initial script. The first similarity threshold and the second similarity threshold are predetermined by a user, and the first similarity threshold is greater than the second similarity threshold.

[0098] It should be noted that if the similarity between the input data and the output data does not exceed the first similarity threshold and exceeds the second similarity threshold, the historical script and the initial script are determined to be repeated tests, and a parameterized target test script is obtained based on the historical script and the initial script. The historical script and the initial script are deleted, and the target test script is saved.

[0099] In some embodiments, if at least one of the similarity of the input data and the similarity of the output data does not exceed the first similarity threshold and the similarity of the input data and the similarity of the output data both exceed the second similarity threshold, a parameterized target test script is obtained based on the historical script and the initial script, and the target test script is saved.

[0100] Exemplarily, the first similarity threshold is 95%, and the second similarity threshold is 75%. If the similarity of the input data is 97% and the similarity of the output data is 80%, a parameterized target test script is obtained based on the historical script and the initial script, and the target test script is saved.

[0101] In some embodiments, variable parts are extracted from the historical script and the initial script, and the variable parts are used as parameters; the initial script is reconstructed according to the extracted parameters, the variable parts are replaced with parameters, and the logic and function of the target test script are ensured not to be affected; the parameterized parts in the target test script are adjusted to ensure that different input data can be correctly received and processed, and corresponding output data can be generated. Parameters can be input values, configuration items, environment variables, etc.

[0102] In this embodiment, if the similarity between the input data and the output data does not exceed the first similarity threshold and exceeds the second similarity threshold, a parameterized target test script is obtained based on the historical script and the initial script, and the target test script is saved to improve the test coverage and efficiency, and to improve the repeatability and consistency of the test.

[0103] Step S105: If the similarity between the input data and the output data does not exceed the second similarity threshold, a target test script is obtained according to the initial script, and the target test script is saved.

[0104] It should be noted that if the similarity between the input data and the output data does not exceed the second similarity threshold, the initial script is determined as the target test script and the target test script is saved.

[0105] In this embodiment, if the similarity between the input data and the output data does not exceed the second similarity threshold, a target test script is obtained according to the initial script, and the target test script is saved to improve the repeatability and consistency of the test.

[0106] Steps S101 to S105 shown in the embodiment of the present application generate an initial script by recording user operations, thereby reducing the time, workload and cost of manually writing scripts; obtaining a historical script; when the historical script and the initial script contain the same function, calculating the similarity of input data and the similarity of output data between the historical script and the initial script; if the similarity of the input data and the similarity of the output data do not exceed the first similarity threshold and exceed the second similarity threshold, then obtaining a parameterized target test script based on the historical script and the initial script, saving the target test script, and improving the coverage and efficiency of the test; if the similarity of the input data and the similarity of the output data do not exceed the second similarity threshold, then obtaining a target test script based on the initial script, saving the target test script, and improving the repeatability and consistency of the test.

[0107] Figure 2 is another optional flowchart of the test script generation method provided in an embodiment of the present application. Figure 2 The method may include but is not limited to steps S201 to S207:

[0108] Step S201: Use an event listener to capture an asynchronous request.

[0109] This application does not make specific restrictions on event listeners, and can be flexibly selected in combination with actual test needs. For example, Puppeteer can be used to listen to events, XMLHttpRequest can be used to listen to events, and Fetch API can also be used to listen to events.

[0110] In step S201 of some embodiments, the AJAX request is captured using Puppeteer's page.on('request') and page.on('response') event listeners.

[0111] In this embodiment, an event listener is used to capture asynchronous requests so that the asynchronous requests are taken into account by the generated script, so that the generated script covers the interaction and functions of the entire page, thereby improving the comprehensiveness and accuracy of the test.

[0112] Step S202: Use XPath or style selector to monitor dynamically generated elements.

[0113] In step S202 of some embodiments, XPath or CSS selectors are used to monitor dynamically generated elements.

[0114] In some embodiments, wait for elements to load, use MutationObserver to monitor DOM changes, and combine XPath or CSS selectors to monitor dynamically generated elements.

[0115] In this embodiment, XPath or style selectors are used to monitor dynamically generated elements so that dynamically loaded content is taken into account by the generated script, so that the generated script covers the interaction and functionality of the entire page, thereby improving the comprehensiveness and accuracy of the test.

[0116] Step S203, generating an initial script.

[0117] In step S203 of some embodiments, an initial script including an asynchronous request and dynamically generated elements is generated.

[0118] In this embodiment, the generated initial script covers the interactions and functions of the entire page, thereby improving the comprehensiveness and accuracy of the test.

[0119] Step S204: if the similarity between the input data and the output data exceeds a first similarity threshold, the initial script is deleted.

[0120] In step S204 of some embodiments, if the similarity between the input data and the output data exceeds a first similarity threshold, the initial script and the historical script are determined to be repeated tests, and the initial script is deleted.

[0121] In some embodiments, the initial script is deleted if the similarity of the input data and the similarity of the output data both exceed a first similarity threshold. Exemplarily, the first similarity threshold is 95%, and if the similarity of the input data is 97% and the similarity of the output data is 96%, the initial script is deleted.

[0122] In this embodiment, if the similarity between the input data and the output data exceeds a first similarity threshold, the initial script is deleted to avoid repeated testing, reduce code redundancy, and improve testing efficiency.

[0123] Step S205, obtaining the execution time of the initial script.

[0124] In step S205 of some embodiments, the initial script is executed and the execution time of the initial script is obtained.

[0125] In some embodiments, when recording user operations and generating an initial script, the execution time of the initial script is obtained.

[0126] In this embodiment, the execution time of the initial script is obtained to prepare for the subsequent determination of whether to generate a target test script.

[0127] Step S206, if the execution time of the initial script exceeds the first execution time threshold, identify the critical path of the initial script, obtain the target test script according to the critical path, and save the target test script.

[0128] Specifically, the first execution time threshold is used to determine whether a target test script is obtained according to a critical path, and the first execution time threshold is predetermined by a user.

[0129] In step S206 of some embodiments, if the execution time of the initial script exceeds a first execution time threshold, the initial script is determined to be an inefficient test, a critical path of the initial script is identified, a target test script is obtained based on the critical path, and the target test script is saved.

[0130] In some embodiments, the functions and dependencies of the initial script are analyzed by checking the initial code, called functions, and referenced external resources, the critical path of the initial script is determined, and the target script is written according to the critical path, functions, and dependencies.

[0131] Specifically, use static code analysis tools to check the code structure, function calls, and variable usage in the initial script, identify all function definitions and calls, and the dependencies between functions; create a dependency graph showing how the various parts of the initial script depend on each other; identify all external resource references (such as libraries, frameworks, APIs); identify the code parts that implement the core business logic; determine the critical path of the script based on the dependencies and core code. Write the target script based on the critical path, functions, and dependencies.

[0132] In this embodiment, if the execution time of the initial script exceeds the first execution time threshold, the critical path of the initial script is identified, the target test script is obtained according to the critical path, the target test script is saved, the test execution time is shortened, and the test efficiency is improved.

[0133] Step S207: If the initial script test fails, the reason for the test failure is analyzed by the log analysis system to obtain the analysis result.

[0134] In some embodiments, if the initial script test fails, data collection is performed, and the collected data types include test case execution logs, system logs, environment information, and goBack code change records.

[0135] The test case execution log contains information about each step, result, and time of the test execution. System logs include server logs, application logs, etc., which record the status, errors, and exceptions of the system during runtime. Environmental information includes the environment configuration during test execution, such as operating system version, browser type, network status, etc. The goBack code change record includes the most recent code submission record, which is used to analyze whether there are new code changes that cause test failures.

[0136] Furthermore, the collected data is preprocessed, which includes log cleaning, formatting, and time alignment.

[0137] Among them, log cleaning includes removing redundant and repeated log entries and extracting key information. Formatting includes converting log data into a structured format for subsequent analysis. Time alignment includes ensuring that the timestamps of all log data are consistent to facilitate tracking the order in which problems occur.

[0138] Optionally, a failure cause analysis is performed on the preprocessed data, and the failure cause analysis includes error code analysis, stack trace analysis, dependency analysis, resource usage analysis, and code change analysis.

[0139] Among them, error code analysis includes finding the corresponding error description and possible causes based on the error code returned by the system. Stack trace analysis includes analyzing the exception stack trace to locate the specific code line and function. Dependency analysis includes checking the dependencies between modules and functions called during the execution of test cases to find potential problems. Resource usage analysis includes analyzing the resource usage during test execution, such as memory, CPU, network, etc., to find out whether there are resource bottlenecks or leaks. Code change analysis includes combining code change records to analyze whether the newly introduced code may cause test failures.

[0140] In this embodiment, if the initial script test fails, the cause of the test failure is analyzed by the log analysis system to obtain analysis results, which is conducive to reducing manual operations and workload and improving analysis efficiency.

[0141] Figure 3 is another optional flowchart of the test script generation method provided in an embodiment of the present application. Figure 3 The method may include but is not limited to steps S301 to S307:

[0142] Step S301, obtaining a first script set.

[0143] Specifically, the first script set includes multiple scripts to be executed.

[0144] Step S302: execute the first script set.

[0145] In step S302 of some embodiments, multiple scripts to be executed are executed, and the running result (success or failure) of each script is recorded.

[0146] Furthermore, the test execution tool or system will record the execution status of each test case (ie, script) in real time, including the number of successes and failures.

[0147] In this embodiment, executing the first script set prepares for the subsequent calculation of the execution success rate, code coverage, and performance indicators.

[0148] Step S303: Display the execution success rate, code coverage, and performance indicators of the first script set on a real-time monitoring page.

[0149] In step S303 of some embodiments, the execution success rate is calculated by the following formula:

[0150] Execution success rate = (number of successful use cases / total number of use cases) * 100%

[0151] In some embodiments, before the test begins, a mapping relationship between code units (such as functions, classes, etc.) and test cases (i.e., scripts) is established. During the test, the test execution tool collects information about which code units are covered by the test cases, matches the collected coverage information with the code units, determines which codes have been covered by the test, and calculates the code coverage rate based on the number of covered code units and the total number of code units. The code coverage rate includes function coverage rate and line coverage rate.

[0152] In some embodiments, a performance test tool or system is used to perform a performance test according to a designed scenario. The performance test tool monitors key performance indicators in real time during the test execution, records the monitored performance indicator data in a log or database, and organizes the collected performance indicator data to remove abnormal values ​​or noise data. Optionally, the performance indicator is compared and analyzed with the expected target or historical data to evaluate the performance test results. Among them, the performance indicators include response time, throughput, and resource utilization.

[0153] In this embodiment, the execution success rate, code coverage and performance indicators of the first script set are displayed on the real-time monitoring page, and the execution success rate, code coverage and performance indicators are intuitively displayed, which is conducive to improving user experience.

[0154] Step S304: if the execution success rate exceeds the first success rate threshold, modify the first script set according to the first preset rule.

[0155] Specifically, the first success rate threshold is used to determine whether the first script set needs to be modified. The first success rate threshold is predetermined by a user. The first preset rule is preconfigured by a user. The first preset rule is formulated based on business logic and historical data.

[0156] In some embodiments, if the execution success rate exceeds a first success rate threshold, the test frequency, test priority, and test focus of the first script set are modified according to a first preset rule.

[0157] Exemplarily, the first success rate threshold is 90%, and the first preset rule is that when the success rate is lower than 90%, the frequency of regression testing is increased to once an hour, and the priority of the module involving the failed use case (ie, script) is raised to the highest.

[0158] In this embodiment, if the execution success rate exceeds the first success rate threshold, the first script set is modified according to the first preset rule, which helps to improve the test efficiency and the response speed of quality assurance.

[0159] Step S305: if the code coverage exceeds the first coverage threshold, modify the first script set according to a second preset rule.

[0160] Specifically, the first coverage threshold is used to determine whether the first script set needs to be modified. The first coverage threshold is predetermined by a user. The second preset rule is preconfigured by a user. The second preset rule is formulated based on business logic and historical data.

[0161] Exemplarily, the first coverage threshold is 90%. The second preset rule is that when the code coverage is lower than 80%, test cases (ie scripts) for uncovered code are automatically generated and added to the test suite, while the priority of these cases (ie scripts) is increased.

[0162] In this embodiment, if the code coverage exceeds the first coverage threshold, the first script set is modified according to the second preset rule to provide better coverage for the untested code parts, which helps to improve the code quality and ensure that the new code changes do not introduce undetected defects.

[0163] Step S306: if the performance indicator exceeds the first performance indicator threshold, modify the first script set according to a third preset rule.

[0164] Specifically, the first performance indicator threshold is used to determine whether the first script set needs to be modified. The first performance indicator threshold is predetermined by the user. The third preset rule is pre-configured by the user. The third preset rule is formulated based on business logic and historical data.

[0165] In some embodiments, if the performance indicator exceeds the first performance indicator threshold, the test depth and test frequency of the first script set are modified according to a third preset rule, and the performance test is triggered.

[0166] Exemplarily, the first performance indicator threshold is that the response time exceeds 500 milliseconds. The third preset rule is that when the response time exceeds 500 milliseconds, the performance test is triggered, and the test frequency and depth for the performance bottleneck module are increased.

[0167] In this embodiment, if the performance indicator exceeds the first performance indicator threshold, the first script set is modified according to the third preset rule, which better meets the needs of performance testing and helps to quickly identify and solve performance problems.

[0168] Step S307: Display the execution status and indicator changes of the modified first script set in real time on the real-time monitoring page.

[0169] In step S304 of some embodiments, the first preset rule, the second preset rule and the third preset rule are integrated into the test management system to ensure that when the monitoring data triggers the threshold, the system can automatically perform the corresponding adjustment operation. Among them, data collection and monitoring are performed to ensure that the test management system can collect and monitor the data of key indicators in real time; a rule engine is implemented to parse and execute automatic adjustment rules; and the test execution plan and scheduling are dynamically adjusted according to the output of the rule engine.

[0170] In some embodiments, after the automatic adjustment mechanism is triggered, its execution effect needs to be monitored to ensure that the adjustment achieves the expected goal.

[0171] Optionally, the adjusted test execution status and indicator changes are displayed on the real-time monitoring page, and the effect of automatic adjustment is evaluated regularly to analyze whether the test efficiency and quality have been successfully improved.

[0172] In this embodiment, the execution status and indicator changes of the modified first script set are displayed in real time on the real-time monitoring page, which provides instant feedback, improves transparency, and helps users to intuitively understand the changes after the modification.

[0173] Figure 4 is a flow chart of a test script generation method provided in an embodiment of the present application, Figure 4 The method may include, but is not limited to, the following steps:

[0174] Step 1: Simulate user behavior.

[0175] Among them, Puppeteer's API is used to simulate various user operations.

[0176] Understandably, Puppeteer simulates real browser environments and user interactions, and tests can more accurately reflect the problems and experiences that users may encounter when using the application. Compared with manual testing, using Puppeteer can greatly speed up the execution of tests and achieve efficient automated testing. This is especially important for frequent regression testing and continuous integration processes. Puppeteer test scripts are fully programmable, which means that tests can be easily repeated, and each run is performed under the same conditions, improving the consistency and reliability of the test.

[0177] Step 2, record the operation.

[0178] Among them, a Puppeteer-based tool is developed to record user operations on web pages, such as clicks, inputs, etc. Optionally, this can be achieved by monitoring related events of the page object. The code for monitoring the page object is as follows:

[0179] const puppeteer=require('puppeteer');

[0180] async function recordActions(){

[0181] const browser=await puppeteer.launch();

[0182] const page = await browser.newPage(); / / Monitor and record user operations

[0183] page.on('click',async(e)=>{

[0184] console.log(Click event recorded at${ex},${ey});

[0185] / / More logic, such as save operations

[0186] }); / / More event listeners...

[0187] recordActions();

[0188] In some embodiments, wait for elements to load, use MutationObserver to monitor DOM changes, and combine XPath or CSS selectors to monitor dynamically generated elements.

[0189] For example, the code to wait for an element to load is as follows:

[0190]

[0191]

[0192] Among them, isElementVisible(selector): defines a function to check whether the element of the specified selector is visible. It determines whether the element is visible by querying the element of the specified selector and then checking its calculated style.

[0193] waitForElementVisible(selector, timeout): defines a function that returns a Promise that waits for the element of the specified selector to become visible. Use an interval timer to continuously check whether the element is visible until the element is visible or the timeout expires. If the element is visible, the Promise will be resolved; if the timeout expires, the Promise will be rejected.

[0194] For example, the code for using MutationObserver to monitor DOM changes is as follows:

[0195]

[0196]

[0197] A MutationObserver instance is created to monitor DOM changes. When a DOM change is detected, each node that changes is checked. If it is an operation to add a node, the newly added node is traversed to check whether it is the dynamic element of interest. If the newly added node matches the specified dynamic element selector, the relevant operation is performed and the observation is stopped (if only one monitoring is required).

[0198] Exemplarily, the code combining XPath or CSS selectors is as follows:

[0199] / / 3. Combine XPath or CSS selector

[0200] / / Assuming waitForElementVisible has executed successfully, the element is now visible

[0201] const dynamicElement=document.querySelector('#dynamic-element');

[0202] / / You can now further manipulate the dynamicElement using XPath or CSS selectors

[0203] After successfully waiting for the dynamic element to be visible, the CSS selector querySelector is used to obtain a reference to the element for further operation or testing. Wait for the dynamic element to be loaded and perform corresponding operations after the element is loaded. It uses two main technologies: polling to check element visibility and using MutationObserver to monitor DOM changes to capture and process dynamic elements.

[0204] In some embodiments, the captured user actions are serialized into an executable script. This involves converting the user actions into Puppeteer commands and saving them. The code of the executable script is as follows:

[0205] / / Method to simulate user interaction

[0206] / / 1. Click

[0207] await page.click('selector'); / / Click on an element on the page

[0208] / / 2. Type text

[0209] await page.type('selector','text'); / / Type text in the selected input box

[0210] / / 3. Scroll the page

[0211] await page.evaluate(()=>{

[0212] window.scrollBy(0,window.innerHeight);

[0213] }); / / Scroll down on the page

[0214] / / 4. Drag elements

[0215] await page.mouse.move(startX,startY); / / Move the mouse to the starting position

[0216] await page.mouse.down(); / / Press the mouse button

[0217] await page.mouse.move(endX,endY); / / Move the mouse to the end position

[0218] await page.mouse.up(); / / Release the mouse button

[0219] / / 5. Simulate form submission

[0220] await page.fill('selector','value'); / / Fill form fields

[0221] await page.click('submit-button-selector'); / / Click the submit button

[0222] / / 6. Simulate keyboard keys

[0223] await page.keyboard.press('Enter'); / / Simulate pressing a keyboard key

[0224] It is understandable that by recording user interactions on a web page and converting these interactions into replayable test cases (i.e., test scripts), various user behaviors and interaction paths can be simulated by writing different test scripts, helping developers discover edge cases that may have been overlooked.

[0225] It should be noted that the present application also includes strategies for variable user paths, wherein the strategies for variable user paths include:

[0226] 1. User behavior simulation:

[0227] (1) Behavioral pattern learning: Use historical data or user logs to learn user behavior patterns.

[0228] (2) Simulation generation: Based on the learned behavior patterns, simulate and generate various user paths.

[0229] 2. Probability-based test case generation:

[0230] (1) Path probability calculation: Calculate the probability of each path being selected based on user behavior data.

[0231] (2) Probabilistic sampling: Sampling is performed based on path probability to generate test cases to reflect the diversity of user paths.

[0232] 3. Dynamic test case adjustment:

[0233] (1) Real-time feedback: Collect real-time feedback during system operation, such as changes in user behavior and system anomalies.

[0234] (2) Test case adjustment: Dynamically adjust test cases based on real-time feedback to adapt to changing user paths.

[0235] Step 3: Execute the test.

[0236] Among them, the generated script (ie, test case) is executed.

[0237] Step 4: Intelligent management of test cases.

[0238] Optionally, develop a log analysis system to automatically analyze the reasons for test failures. The analysis results may include page updates, new bugs, or problems with the test scripts.

[0239] Furthermore, based on the analysis results, repair code is automatically generated or the test script is adjusted to reduce manual intervention.

[0240] Among them, the self-repair mechanism includes:

[0241] 1. Natural Language Processing (NLP)

[0242] 1) Application scenarios:

[0243] (1) Log analysis: Use NLP technology to extract key information from logs, such as error descriptions, exception types, etc.

[0244] (2) Problem description parsing: Analysts may provide brief descriptions or comments for failed test cases, and NLP can help understand these descriptions and extract key information.

[0245] 2) Technical Implementation:

[0246] (1) Word segmentation and part-of-speech tagging: Segment the log or description text into words and mark the part of speech of each word to facilitate subsequent analysis.

[0247] (2) Named Entity Recognition: Identify key entities in the text, such as class names, method names, error codes, etc.

[0248] (3) Sentiment analysis: Analyze the sentiment of the descriptive text and determine the severity of the problem.

[0249] 2. Code understanding and generation

[0250] 1) Application scenarios:

[0251] (1) Error location: Locate the specific code location or module based on the analysis results.

[0252] (2) Code repair suggestion: Generate possible repair code snippets based on the error type and context information.

[0253] (3) Test script adjustment: adjust the parameters, assertions or execution order in the test script.

[0254] 2) Technical Implementation:

[0255] (1) Static code analysis: Understand the logic and dependencies of the code by analyzing the code structure.

[0256] (2) Dynamic execution tracking: Tracking the execution path and variable status of the code during execution.

[0257] (3) Template and rule matching: Generate corresponding code repair or test script adjustment suggestions based on known error types and repair patterns.

[0258] 3. Machine Learning

[0259] 1) Application scenarios:

[0260] (1) Error classification and prediction: Use machine learning models to automatically classify errors and predict possible repair solutions.

[0261] (2) Code quality assessment: Use models to assess code quality and predict potential problems.

[0262] 2) Technical Implementation:

[0263] (1) Feature extraction: Extract features from code, logs, and descriptions, such as code complexity, call relationships, historical error data, etc.

[0264] (2) Model training: Use labeled data to train classification, regression, or generation models.

[0265] (3) Model application: Apply the trained model to new error data to generate repair suggestions or adjust the test script.

[0266] It is understood that when the application is updated or expanded, the test cases are automatically updated to maintain their validity and relevance.

[0267] Step 5: Real-time monitoring and feedback.

[0268] Understandably, Puppeteer is not only capable of functional testing, but also of evaluating performance metrics such as page loading time and script execution time, allowing developers to continuously optimize product performance during the development process.

[0269] Among them, the execution success rate, code coverage and performance indicators of the first script set are displayed on the real-time monitoring page. If the execution success rate exceeds the first success rate threshold, the first script set is modified according to the first preset rule. If the code coverage exceeds the first coverage threshold, the first script set is modified according to the second preset rule. If the performance indicator exceeds the first performance indicator threshold, the first script set is modified according to the third preset rule, and the execution status and indicator changes of the modified first script set are displayed in real time on the real-time monitoring page.

[0270] For example, in a certain test, the success rate was monitored to suddenly drop to 85%, triggering the automatic adjustment mechanism. According to the preset rules, the test management system automatically increases the frequency of regression testing to once an hour and raises the priority of the module involving the failed test case to the highest level. At the same time, the system also generates a detailed report on the failed test case for developers to quickly locate and solve the problem. Through the automatic adjustment operation, the test success rate can be quickly restored and the overall test effect can be improved.

[0271] It is understandable that performance analysis is performed on the test case execution, and the test process is optimized based on the performance data, so that real-time monitoring during the test process can be achieved, and feedback can be provided and the test can be automatically adjusted based on the monitoring results.

[0272] See also Figure 5The embodiment of the present application also provides a test script generation device, which can implement the above test script generation method, and the device includes:

[0273] Recording module 501, used to record user operations and generate initial scripts;

[0274] A historical script acquisition module 502 is used to acquire historical scripts;

[0275] A calculation module 503, used for calculating the similarity of input data and output data between the historical script and the initial script when the historical script and the initial script contain the same function;

[0276] A parameterization module 504 is used to obtain a parameterized target test script according to the historical script and the initial script, and save the target test script if the similarity between the input data and the output data does not exceed the first similarity threshold and exceeds the second similarity threshold;

[0277] The saving module 505 is used to obtain a target test script according to the initial script and save the target test script if the similarity between the input data and the output data does not exceed a second similarity threshold.

[0278] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0279] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above test script generation method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0280] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0281] See also Figure 6 , Figure 6 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0282] The processor 601 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0283] The memory 602 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 602 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 602, and the processor 601 calls and executes the test script generation method of the embodiment of this application;

[0284] Input / output interface 603, used to implement information input and output;

[0285] Communication interface 604, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0286] Bus 605 , which transmits information between various components of the device (e.g., processor 601 , memory 602 , input / output interface 603 , and communication interface 604 );

[0287] The processor 601 , the memory 602 , the input / output interface 603 and the communication interface 604 are connected to each other in communication within the device via a bus 605 .

[0288] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned test script generation method is implemented.

[0289] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0290] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0291] The test script generation method, test script generation device, electronic device and storage medium provided in the embodiments of the present application generate an initial script by recording user operations, thereby reducing the time, workload and cost of manually writing scripts; obtaining a historical script; when the historical script and the initial script contain the same function, calculating the similarity of input data and the similarity of output data between the historical script and the initial script; if the similarity of the input data and the similarity of the output data do not exceed a first similarity threshold and exceed a second similarity threshold, obtaining a parameterized target test script based on the historical script and the initial script, saving the target test script, and improving the coverage and efficiency of the test; if the similarity of the input data and the similarity of the output data do not exceed the second similarity threshold, obtaining a target test script based on the initial script, saving the target test script, and improving the repeatability and consistency of the test.

[0292] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0293] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0294] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0295] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0296] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0297] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0298] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0299] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0300] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0301] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0302] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A test script generation method, characterized in that: The method comprises: Record user operations and generate initial scripts; Get the history script; When the historical script and the initial script contain the same function, calculate the similarity of input data and output data between the historical script and the initial script; If the similarity between the input data and the output data does not exceed the first similarity threshold and exceeds the second similarity threshold, a parameterized target test script is obtained according to the historical script and the initial script, and the target test script is saved; If the similarity between the input data and the output data does not exceed a second similarity threshold, a target test script is obtained according to the initial script, and the target test script is saved.

2. The method according to claim 1, characterized in that: The method further comprises: If the similarity between the input data and the output data exceeds a first similarity threshold, the initial script is deleted.

3. The method according to claim 1, characterized in that The initial script includes asynchronous requests and dynamically generated elements, and the recording of user operations includes: Use event listeners to capture asynchronous requests; Use XPath or style selectors to listen for dynamically generated elements.

4. The method according to claim 1, characterized in that: The method further comprises: Obtaining the execution time of the initial script; If the execution time of the initial script exceeds a first execution time threshold, a critical path of the initial script is identified, a target test script is obtained according to the critical path, and the target test script is saved.

5. The method according to claim 1, characterized in that The method further comprises: If the initial script test fails, the reason for the test failure is analyzed by the log analysis system to obtain an analysis result.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Get a first script set; Executing the first script set; The execution success rate, code coverage and performance indicators of the first script set are displayed on the real-time monitoring page.

7. The method according to claim 6, characterized in that The method further comprises: If the execution success rate exceeds a first success rate threshold, modifying the first script set according to a first preset rule; If the code coverage exceeds a first coverage threshold, modifying the first script set according to a second preset rule; If the performance indicator exceeds a first performance indicator threshold, the first script set is modified according to a third preset rule.

8. A test script generating device, characterized in that: The device comprises: Recording module, used to record user operations and generate initial scripts; A historical script acquisition module is used to obtain historical scripts; A calculation module, used for calculating the similarity of input data and output data between the historical script and the initial script when the historical script and the initial script contain the same function; A parameterization module, configured to obtain a parameterized target test script according to the historical script and the initial script, and save the target test script if the similarity between the input data and the output data does not exceed a first similarity threshold and exceeds a second similarity threshold; A saving module is used to obtain a target test script according to the initial script and save the target test script if the similarity between the input data and the output data does not exceed a second similarity threshold.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Software script processing method and apparatus, device, and computer-readable storage medium

    WO2026144922A1