Software testing method and device based on recording step, and electronic equipment
By analyzing and intelligently recognizing the recording steps, redundant operations in UI automated testing are eliminated, and efficient test scripts are generated. This solves the problems of low efficiency and high maintenance costs caused by the recording steps, and improves testing efficiency and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-01
- Publication Date
- 2026-04-07
AI Technical Summary
Existing UI automation testing tools contain a large number of redundant operations in the recording process, resulting in bloated test scripts, high maintenance costs, and low execution efficiency.
By parsing the recorded steps, extracting the step descriptions, and using preset detection rules and preset analysis models to identify and eliminate invalid or redundant steps, an efficient target test script is generated.
It improved testing efficiency, reduced maintenance costs, and enhanced script reliability and test coverage.
Smart Images

Figure CN121807692A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of financial technology, and more specifically, to a software testing method, apparatus, and electronic device based on recording steps. Background Technology
[0002] With the shortening of software development cycles and the acceleration of version iterations, UI (User Interface) automated testing plays an increasingly important role in ensuring software quality and improving testing efficiency. Current UI automated testing tools typically generate test scripts by recording user actions. However, these recorded steps often contain a large number of redundant operations, such as repeated clicks and irrelevant page jumps, resulting in bloated test scripts, high maintenance costs, and low execution efficiency.
[0003] Therefore, there is an urgent need for a method that can intelligently analyze and streamline recorded test steps, eliminate useless steps, retain core operations, and generate efficient and concise test scripts.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a software testing method, apparatus, and electronic device based on recording steps, to at least solve the technical problem in related technologies where test script generation through recording steps containing a large number of redundant operations leads to low testing efficiency.
[0006] According to one aspect of the present invention, a software testing method based on recorded steps is provided, comprising: performing user interface operations on the software to be tested and recording the operation process to obtain recorded data, wherein the recorded data includes: multiple recorded steps; parsing each recorded step to obtain a step description corresponding to each recorded step; identifying each step description based on preset detection rules, and performing a deletion operation on the recorded data based on the identification results to obtain initial recorded data, wherein the initial recorded data includes: multiple candidate step descriptions; processing each candidate step description using a preset analysis model, and performing operations on each candidate step description based on the processing results to obtain target recorded data; generating a target test script based on the target recorded data, and using the target test script to test the software to be tested.
[0007] Furthermore, each recording step is parsed to obtain a step description corresponding to each recording step, including: parsing the recording step to determine the operation type, operation element, and operation timestamp of the recording step; extracting the first page structure before the execution of the recording step, and determining the first fingerprint feature before the execution of the recording step based on the first page structure; extracting the second page structure after the execution of the recording step, and determining the second fingerprint feature after the execution of the recording step based on the second page structure; and encapsulating the operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature to obtain the step description.
[0008] Furthermore, the steps of identifying each step description based on preset detection rules and deleting recorded data based on the identification results include: if the preset detection rules are valid, identifying the operation type and operation element in the step description based on the valid detection rules; if the operation type and operation element do not match, determining that the step description is an invalid step; and deleting invalid steps.
[0009] Furthermore, the steps of identifying each step description based on preset detection rules and deleting recorded data based on the identification results include: when the preset detection rule is a same element detection rule, identifying the operation type and operation element in two adjacent step descriptions based on the same element detection rule; determining that two adjacent step descriptions are the same step when the operation elements in two adjacent step descriptions are the same, and the operation type in the later step description is the same as or appended to the operation type in the earlier step description, where appended same means that the later operation type is different from the earlier operation type, and the page does not change after the step description indicated by the later operation type is executed; and deleting any step description in the same step.
[0010] Furthermore, the steps of identifying each step description based on preset detection rules and deleting recorded data based on the identification results include: when the preset detection rule is an empty operation detection rule, identifying the first fingerprint feature and the second fingerprint feature in the step description based on the empty operation detection rule; when the first fingerprint feature and the second fingerprint feature are the same, determining that the page has not changed after the execution of the step description; determining the step description as an empty operation step, and deleting the empty operation step.
[0011] Furthermore, the steps of processing each candidate step description using a preset analysis model include: determining the operation type of the candidate step description and determining the page structure of the current page; obtaining all recorded steps executed before the candidate step description to obtain a historical operation sequence; determining the target feature vector based on the operation type, page structure, and historical operation sequence; and inputting the target feature vector into the preset analysis model to obtain the processing result. The preset analysis model is a model trained based on the historical feature vector, which includes: the operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recorded step. The processing result includes: elimination processing and merging processing.
[0012] Furthermore, based on the processing result, the steps for operating on each candidate step description include: if the processing result is elimination processing, eliminating the candidate step description; if the processing result is merging processing, determining all candidate step descriptions to be merged and the merging type; determining the calling method class corresponding to the merging type, and using the calling method class to replace all candidate step descriptions to be merged.
[0013] Furthermore, after generating the target test script based on the target recording data, the process further includes: generating the original test script based on the recording data; executing the original test script and obtaining the original page structure of each page during the execution of the original test script and the original execution result after execution; executing the target test script and obtaining the target page structure of each page during the execution of the target test script and the target execution result after execution; calculating the similarity between the original page structure and the target page structure of each page to obtain the average similarity; and determining that the target test script is a valid test script if the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result.
[0014] According to another aspect of the present invention, a software testing apparatus based on recording steps is also provided, comprising: an operation unit for performing user interface operations on the software to be tested and recording the operation process to obtain recording data, wherein the recording data includes: multiple recording steps; a parsing unit for parsing each recording step to obtain a step description corresponding to each recording step; an identification unit for identifying each step description based on preset detection rules and performing deletion operations on the recording data based on the identification results to obtain initial recording data, wherein the initial recording data includes: multiple candidate step descriptions; a processing unit for processing each candidate step description using a preset analysis model and performing operations on each candidate step description based on the processing results to obtain target recording data; and a generation unit for generating a target test script based on the target recording data and using the target test script to test the software to be tested.
[0015] Furthermore, the parsing unit includes: a first determining module, used to parse the recording steps and determine the operation type, operation element, and operation timestamp of the recording steps; a first extraction module, used to extract the first page structure before the execution of the recording steps, and based on the first page structure, determine the first fingerprint feature before the execution of the recording steps; a second determining module, used to extract the second page structure after the execution of the recording steps, and based on the second page structure, determine the second fingerprint feature after the execution of the recording steps; and a first encapsulation module, used to encapsulate the operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature to obtain a step description.
[0016] Furthermore, the identification unit includes: a first identification module, used to identify the operation type and operation element in the step description based on the valid detection rule when the preset detection rule is a valid detection rule; a third determination module, used to determine that the step description is an invalid step when the operation type and operation element do not match; and a first deletion module, used to delete invalid steps.
[0017] Furthermore, the identification unit also includes: a second identification module, used to identify the operation type and operation element in two adjacent step descriptions based on the same element detection rule when the preset detection rule is the same element detection rule; a fourth determination module, used to determine that two adjacent step descriptions are the same step when the operation elements in two adjacent step descriptions are the same, and the operation type in the latter step description is the same as or appended to the operation type in the former step description, wherein appended same means that the latter operation type is different from the former operation type, and the page does not change after the step description indicated by the latter operation type is executed; and a second deletion module, used to perform a deletion operation on any one of the step descriptions in the same step.
[0018] Furthermore, the identification unit also includes: a third identification module, used to identify the first fingerprint feature and the second fingerprint feature in the step description based on the empty operation detection rule when the preset detection rule is the empty operation detection rule; a fifth determination module, used to determine that the page has not changed after the execution of the step description when the first fingerprint feature and the second fingerprint feature are the same; and a third deletion module, used to determine the step description as an empty operation step and perform a deletion operation on the empty operation step.
[0019] Further, the processing unit includes: a sixth determining module, used to determine the operation type described in the candidate step description and determine the page structure of the current page; a first acquiring module, used to acquire all recorded steps executed before the candidate step description to obtain a historical operation sequence; a seventh determining module, used to determine the target feature vector based on the operation type, page structure, and historical operation sequence; and a first input module, used to input the target feature vector into a preset analysis model to obtain the processing result, wherein the preset analysis model is a model trained based on the historical feature vector, and the historical feature vector includes: the operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recorded step; the processing result includes: elimination processing and merging processing.
[0020] Furthermore, the processing unit includes: a first elimination module, used to eliminate candidate step descriptions when the processing result is elimination processing; an eighth determination module, used to determine all candidate step descriptions to be merged and the merging type when the processing result is merging processing; and a ninth determination module, used to determine the calling method class corresponding to the merging type and use the calling method class to replace all candidate step descriptions to be merged.
[0021] Furthermore, the software testing device also includes: a first generation module, used to generate an original test script based on the recorded data after generating a target test script based on the target recorded data; a first execution module, used to execute the original test script and obtain the original page structure of each page during the execution of the original test script and the original execution result after execution; a second execution module, used to execute the target test script and obtain the target page structure of each page during the execution of the target test script and the target execution result after execution; a first calculation module, used to calculate the similarity between the original page structure and the target page structure of each same page to obtain the average similarity; and a tenth determination module, used to determine that the target test script is a valid test script when the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result.
[0022] According to another aspect of the present invention, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements any of the above-described software testing methods based on the recording steps.
[0023] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any of the above-described software testing methods based on the recording steps.
[0024] In this invention, user interface operations are performed on the software under test, and the operation process is recorded to obtain recorded data. Each recorded step is parsed to obtain a corresponding step description. Based on preset detection rules, each step description is identified, and based on the identification results, the recorded data is reduced to obtain initial recorded data. A preset analysis model is used to process each candidate step description, and based on the processing results, operations are performed on each candidate step description to obtain target recorded data. Based on the target recorded data, a target test script is generated, and the target test script is used to test the software under test. This solves the technical problem in related technologies where test script generation through recording steps containing a large number of redundant operations leads to low testing efficiency.
[0025] In this invention, user interface operations are recorded. By constructing an atomic description framework for operations, the user interface operations of the software under test are accurately recorded, resulting in recording data containing multiple recording steps. Each recording step is then parsed to extract its description. Redundant operations are intelligently identified and eliminated using preset detection rules, forming more refined initial recording data. A preset analysis model is then used to analyze each candidate step description, and further optimization is performed based on the model's processing results to obtain the target recording data. Finally, an efficient target test script is automatically generated based on the target recording data. This script is used for automated software testing, effectively solving the technical problems of low efficiency and high maintenance costs caused by redundant steps in test scripts. This achieves the technical effects of improving testing efficiency, reducing maintenance costs, enhancing script reliability, and increasing test coverage. Attached Figure Description
[0026] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0027] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a software testing method based on recording steps is shown.
[0028] Figure 2 This is a flowchart of a software testing method based on recording steps according to Embodiment 1 of the present invention;
[0029] Figure 3 This is a schematic diagram of the software testing system structure according to Embodiment 1 of the present invention;
[0030] Figure 4This is a schematic diagram of an optional software testing apparatus based on recording steps according to an embodiment of the present invention;
[0031] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0032] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first," "second," etc., used in this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] It should be noted that all relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) collected and involved in this invention are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data comply with the relevant laws, regulations, and standards of the relevant regions, necessary confidentiality measures have been taken, and it does not violate public order and good morals. Corresponding operation entry points are provided for users to choose to authorize or refuse. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface. The relevant information is obtained only after receiving consent from the aforementioned user or organization. If the user chooses to refuse, the process proceeds to an expert decision-making process.
[0035] In this invention, a method for intelligent simplification of UI automated recording steps is proposed. By automatically analyzing the recorded test steps through rules and large models, useless or redundant steps are identified and eliminated, and the minimum effective operation set is retained, thereby improving the efficiency and maintainability of test scripts. It can solve the following problems: (1) serious redundancy of steps: the recording tool mechanically records all operations, and the generated script contains 30%-70% useless steps; (2) high maintenance cost: redundant steps increase the workload of test case maintenance by 200% (taking the test of a certain application APP as an example, each UI revision requires manual correction of 50% of the recorded test cases); (3) lack of intelligent judgment: traditional solutions only rely on fixed rule filtering (such as deleting empty waits and repeated coordinate clicks), which cannot identify redundancy at the business semantic level.
[0036] The method for intelligently simplifying UI automation recording steps proposed in this invention can effectively optimize test scripts, improve the efficiency and quality of automated testing, and has important practical significance. It achieves the following effects: (1) Improve test efficiency: By eliminating redundant and invalid steps, the execution time of test scripts is reduced, thus improving test efficiency; (2) Reduce maintenance costs: The simplified scripts are more concise and clear, reducing the difficulty of maintenance and updates; (3) Enhance script reliability: The script execution failure caused by redundant operations is reduced, thus improving the stability of the scripts; (4) Improve test coverage: Through intelligent analysis, the test scripts are ensured to cover key operation steps, thus enhancing the comprehensiveness of the tests.
[0037] The present invention will now be described in detail with reference to various embodiments.
[0038] Example 1
[0039] According to an embodiment of this application, an embodiment of a software testing method based on recording steps is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0040] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a software testing method based on recording steps is shown. Figure 1 As shown, computer terminal 10 (or mobile device) may include one or more ( Figure 1The processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions may also be included. In addition, it may include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera, wherein the network interface can be connected to wired and / or wireless networks. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0041] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0042] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the software testing method based on recording steps in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned software testing method based on recording steps. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0043] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0044] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0045] Under the aforementioned operating environment, this application provides the following: Figure 2 The software testing method shown is based on recording steps. Figure 2 This is a flowchart of a software testing method based on recording steps according to Embodiment 1 of the present invention, as shown below. Figure 2 As shown, the method includes the following steps:
[0046] Step S201: Perform user interface operations on the software to be tested and record the operation process to obtain recording data, wherein the recording data includes: multiple recording steps.
[0047] In this embodiment of the invention, a software testing system can be used to execute a software testing method based on recording steps. Figure 3 This is a schematic diagram of the software testing system structure according to Embodiment 1 of the present invention, as shown below. Figure 3 As shown, it includes: a recording input layer, a rule engine, a large model processing layer, a validation module, and a simplified output layer.
[0048] In this embodiment of the invention, automated tools or plugins can capture every user interface operation performed by the user on the software under test, and convert these user interface operations into a data format that can be understood and processed by the system, namely a series of recording steps, to obtain recorded data. Here, each recording step is a structured description, such as JSON (JavaScript Object Notation) format, containing information such as operation type (e.g., click, input), element location information, fingerprint features of the interface state before and after the operation (e.g., hash value), and timestamp. For example, clicking the login button will be converted into a JSON structure containing the operation type, which records the click action, the location information of the login button, and the page state changes before and after the click.
[0049] Here, user interface operations refer to the various actions a user takes when interacting with the software, such as clicking a button, entering information, and scrolling through a page.
[0050] Then, the recorded data is input into the software testing system through the recording input layer for simplification.
[0051] Step S202: Analyze each recording step to obtain the step description corresponding to each recording step.
[0052] In this embodiment of the invention, the recording steps can be parsed to obtain an atomic description framework for the recording steps, thereby extracting the step descriptions corresponding to the recording steps. Here, the step descriptions include: operation type, operation element location, interface feature fingerprint before the operation, interface feature fingerprint after the operation, and timestamps accurate to milliseconds, etc., to facilitate subsequent rule analysis and model processing. For example, the JSON structure of clicking the login button can be parsed as: "Clicking the login button, located in the upper right corner of the screen, triggers the display of the login pop-up."
[0053] Step S203: Based on preset detection rules, identify each step description, and based on the identification results, perform deletion operations on the recorded data to obtain initial recorded data, wherein the initial recorded data includes: multiple candidate step descriptions.
[0054] In this embodiment of the invention, a rule engine performs multi-dimensional rule redundancy determination. This involves using preset detection rules (i.e., predefined logical judgment criteria in a preset rule base) to identify whether invalid or redundant operations exist in the recording steps. These rules include, but are not limited to: detection of consecutive identical element operations, detection of empty waits, identification of invalid scrolling, and identification of empty clicks. For example, the "detection of consecutive identical element operations" rule checks whether two or more consecutive operations act on the same element. If the operation type is the same or the latter can be considered a supplement to the former (e.g., input immediately after clicking), it is determined to be redundant and can be removed. Subsequently, based on the rule identification results, useless or redundant step descriptions are automatically removed to reduce the burden of subsequent processing and improve the quality of the test script. The set of step descriptions retained after operation reduction, where each step is considered a potentially valid operation in the test process, forms the basis of the simplified recording data.
[0055] Step S204: Process each candidate step description using a preset analysis model, and perform operations on each candidate step description based on the processing results to obtain the target recording data.
[0056] In this embodiment of the invention, further redundancy determination is performed through a large model processing layer. Specifically, a preset analysis model is used to process each candidate step description. Based on the processing results, operations are performed on each candidate step description to obtain the target recorded data. Here, the preset analysis model is a specially trained artificial intelligence model capable of understanding deeper business logic and operational intent, thereby determining the true value of the step description. The model's input typically includes the operation type, DOM (Document Object Model) page layout, and historical operation sequences. This information is used to comprehensively analyze and determine whether a step should be retained, whether it falls within the scope of public method calls, or whether it should be considered useless and discarded.
[0057] Step S205: Based on the target recorded data, generate a target test script and use the target test script to test the software to be tested.
[0058] In this embodiment of the invention, a highly efficient and low-redundancy target test script can be automatically generated based on the target recording data. This script directly reflects the key operational flow of the software, eliminating all unnecessary steps and ensuring both speed and accuracy during execution. Subsequently, the target test script can be applied to the software under test to execute the entire test process, verifying whether the various functions of the software are operating normally and identifying any potential defects or errors.
[0059] In summary, by recording user interface operations and constructing an atomic description framework for operations, the user interface operations of the software under test are accurately recorded, resulting in recording data containing multiple recording steps. Each recording step is then parsed to extract its description. Pre-defined detection rules are used to intelligently identify and eliminate redundant operations, forming more refined initial recording data. A pre-defined analysis model is then applied to analyze each candidate step description, and further optimization is performed based on the model's results, resulting in the target recording data. Finally, an efficient target test script is automatically generated based on the target recording data. Using this script for automated software testing effectively solves the technical problems of low efficiency and high maintenance costs caused by redundant steps in test scripts, achieving the technical effects of improved testing efficiency, reduced maintenance costs, enhanced script reliability, and increased test coverage.
[0060] To improve the accuracy of determining the step description corresponding to each recording step, in the software testing method based on recording steps provided in Embodiment 1 of this application, the recording steps are parsed to determine the operation type, operation element, and operation timestamp of the recording step; the first page structure before the execution of the recording step is extracted, and the first fingerprint feature before the execution of the recording step is determined based on the first page structure; the second page structure after the execution of the recording step is extracted, and the second fingerprint feature after the execution of the recording step is determined based on the second page structure; the operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature are encapsulated to obtain the step description.
[0061] In this embodiment of the invention, the system first parses each recording step into a more granular description, including the operation type (such as click, input, wait), operation element (specific buttons, text boxes, etc. in the interface), and operation timestamp (the specific time point when the operation occurred). This process can be implemented through a parsing algorithm to ensure that the information extracted from the original recording data is accurate.
[0062] Here, operation type refers to the specific action of user interaction with the software interface, such as clicking, inputting, or waiting. Each type of operation has its specific meaning and function. Operation element refers to the target of user operation, that is, the specific element on the interface, such as button, input box, etc. It is uniquely identified by the element's attributes (such as ID (Identifier) and XPath (XML Path Language, a language for locating and extracting information in XML (eXtensible Markup Language) documents) to facilitate subsequent analysis and location. Operation timestamp records the specific time when each operation occurs, accurate to milliseconds, and is used to analyze operation sequences and time dependencies.
[0063] In this embodiment of the invention, before the recording step is executed, the system obtains the DOM structure (DOM source code) of the current page from the browser. After filtering out irrelevant tags (such as scripts, dynamic CSS rendering, etc.), the system performs a hash calculation on the DOM structure to obtain a unique fingerprint feature representing the current page state (the hash value of the main DOM structure of the current page, used to represent the current page state), called the first fingerprint feature. For example, this can be implemented using Web-driven technology, ensuring the accuracy and consistency of the page state description. Furthermore, after the recording step is executed, the system again obtains the DOM structure of the current page through the browser driver, and obtains the second fingerprint feature after tag filtering and hash calculation. Here, the comparison between the second fingerprint feature and the first fingerprint feature is the basis for determining whether the operation is effective and whether it causes a change in the page state.
[0064] Next, all the parsed information is encapsulated into a structured data object, forming a step description. This description contains comprehensive information about the operation, facilitating subsequent processing and analysis by the rule engine and model. Here, the step description refers to a comprehensive information package consisting of operation type, operation elements, operation timestamp, first fingerprint feature, and second fingerprint feature; it is the core data structure for redundant operation identification and intelligent simplification.
[0065] For example, the following is an operation atomic description framework constructed after parsing a certain recording step, from which the step description of the recording step can be extracted.
[0066] {
[0067] "action_type": "click", # Action type;
[0068] "element_xpath": " / / Button[@id='login']", # Element positioning;
[0069] "pre_state_hash": "a1b2c3", # The interface fingerprint before the operation;
[0070] "post_state_hash": "d4e5f6", # Post-operation interface fingerprint;
[0071] "timestamp": 1678900 # Timestamp accurate to milliseconds;
[0072] }
[0073] In this embodiment, recorded test steps can be parsed and features extracted to construct the context of each operation, providing a solid data foundation for subsequent redundancy detection and intelligent simplification. Simultaneously, by comparing fingerprint features, it can automatically identify which operations actually affect the page state, effectively eliminating seemingly functional but actually ineffective or redundant steps. This improves the simplification and execution efficiency of test scripts, reduces maintenance costs, enhances test accuracy and stability, and achieves intelligent and optimized test automation processes. Through meticulous step parsing and intelligent redundancy identification, high-quality automated test scripts can be generated more quickly, effectively addressing rapid software iteration and complex business scenarios.
[0074] In order to prepare for the identification of step descriptions and remove redundant steps, in the software testing method based on recorded steps provided in Embodiment 1 of this application, if the preset detection rule is a valid detection rule, the operation type and operation element in the step description are identified based on the valid detection rule; if the operation type and operation element do not match, the step description is determined to be an invalid step; and invalid steps are deleted.
[0075] In this embodiment of the invention, steps can be intelligently reduced using a rule-plus-model approach. A rule base can be constructed first, containing various detection algorithms to identify whether a step-level operation is a discarded operation. These detection algorithms include the following:
[0076] Detection of consecutive identical element operations: By looping, it determines whether consecutive steps are identical elements and whether the operation type is the same type or an append operation (such as input after clicking).
[0077] Empty wait: If the step time exceeds the set value and the page remains unchanged.
[0078] Invalid scrolling: No new data was loaded on the page before or after scrolling.
[0079] Empty click: No DOM element is present at the clicked location, or the page layout does not change after the click.
[0080] Specifically, assuming the preset detection rules are valid, each step description can be checked one by one to identify the operation type (such as click, input) and operation element (such as buttons and text boxes on the interface). This process is achieved by parsing the structured information of the step description, ensuring the accuracy and consistency of the analysis. If the system identifies the operation type as "input" in a step description, but the operation element is a static image that cannot be input, this mismatch indicates that the step description is invalid. Based on this judgment, the step is automatically marked as invalid, preparing for subsequent deletion operations.
[0081] Here, mismatch between operation type and operation element refers to a logical conflict between the operation type and the operation element, such as performing an interactive operation on a non-interactive element or performing an operation on an expired element.
[0082] If a step is determined to be invalid, immediately perform a deletion operation to remove it from the recorded data.
[0083] In this embodiment, invalid steps in the test script can be identified and eliminated more intelligently and accurately, thereby generating more efficient and concise test scripts. This not only reduces test execution time but also lowers maintenance costs and improves the accuracy and reliability of the tests.
[0084] In order to prepare for the identification of step descriptions and remove redundant steps, in the software testing method based on recorded steps provided in Embodiment 1 of this application, when the preset detection rule is the same element detection rule, the operation type and operation element in two adjacent step descriptions are identified based on the same element detection rule; when the operation elements in two adjacent step descriptions are the same, and the operation type in the later step description is the same as or appended to the operation type in the earlier step description, the two adjacent step descriptions are determined to be the same step, wherein appended same means that the later operation type is different from the earlier operation type, and the page does not change after the step description indicated by the later operation type is executed; and a deletion operation is performed on any step description in the same step.
[0085] In this embodiment of the invention, when the preset detection rule is the same element detection rule, the operation type (such as click, input, wait, etc.) and operation element (specific control on the interface, such as button, text box) in the description of two adjacent steps can be identified first.
[0086] Next, determine whether the operation elements in two adjacent step descriptions are the same. This can be done by comparing the positioning attributes (such as ID, XPath, etc.) of the elements in the step descriptions. When two adjacent step descriptions point to the same interface element, further analyze the differences in operation types. If the operation type in the latter step description is exactly the same as the operation type in the former step description, or if they form an append relationship (i.e., the latter operation type adds a new operation based on the former operation, but in fact the former operation is sufficient and there is no need for repetition or additional operations), then these two adjacent step descriptions are considered redundant or invalid identical steps.
[0087] Here, adding the same situation means that if the first step is "click button A", and the second step is also "click button A", or if the first step is "click button A" followed by "enter text into input box B", and the second operation does not cause a substantial change in the page state, then the latter can be considered an addition to the former, but it is unnecessary.
[0088] Next, fingerprint features (hash values of interface features) are used to monitor whether the page layout or state has changed after the operation. If, after two identical or appended operations, the first fingerprint feature (page state before the operation) and the second fingerprint feature (page state after the operation) are highly similar or completely identical, it indicates that the second operation is redundant and has no substantial impact. For any step description determined to be in the same step, a deletion operation is performed, that is, the step description is removed from the recorded data to reduce redundancy and improve the execution efficiency of the script.
[0089] In this embodiment, the test script can be effectively simplified, and unnecessary repetitive operations can be removed. This reduction in redundant operations means that the execution time of the test script is shortened, which improves the speed and efficiency of automated testing. Furthermore, the removal of unnecessary operations avoids script errors or failures caused by redundant steps, thereby enhancing the stability and reliability of script operation.
[0090] In order to prepare for the identification of the step description and remove redundant steps, in the software testing method based on recorded steps provided in Embodiment 1 of this application, when the preset detection rule is the empty operation detection rule, the first fingerprint feature and the second fingerprint feature in the step description are identified based on the empty operation detection rule; when the first fingerprint feature and the second fingerprint feature are the same, it is determined that the page has not changed after the execution of the step description; the step description is determined to be an empty operation step, and the empty operation step is deleted.
[0091] In this embodiment of the invention, when the preset detection rule is a no-operation detection rule, the first fingerprint feature and the second fingerprint feature in the step description can be identified first. Here, the first fingerprint feature represents the page state before the step description is executed, and is usually composed of the hash value of the page's main DOM structure, used to accurately identify the static layout and content of the page at a certain moment; the second fingerprint feature represents the page state after the step description is executed, and is also represented by the hash value of the page's DOM structure. This is to capture any potential changes to the page after the operation, including layout adjustments and data updates. When the first fingerprint feature and the second fingerprint feature of the step description are identified to be completely identical, it means that the actual state of the page has not changed after the step description is executed. The operation in this case can be regarded as invalid or no-operation, that is, an operation that does not contribute anything positive to the test results.
[0092] Operations that do not cause changes to the page state are considered invalid operations (empty operation steps), and step reduction operations are performed, that is, these invalid operations are removed from the recorded data to reduce unnecessary execution burden.
[0093] In this embodiment, by eliminating invalid operations, the execution time of the test script is reduced, thus speeding up the entire testing process. Furthermore, removing unnecessary operations that do not affect the test results ensures the focus of the testing process, improving the reliability and effectiveness of the test cases.
[0094] To improve the accuracy of the preset analysis model in processing each candidate step description, the software testing method based on recorded steps provided in Embodiment 1 of this application determines the operation type of the candidate step description and the page structure of the current page; obtains all recorded steps executed before the candidate step description to obtain a historical operation sequence; determines the target feature vector based on the operation type, page structure, and historical operation sequence; and inputs the target feature vector into the preset analysis model to obtain the processing result. The preset analysis model is a model trained based on the historical feature vector, which includes: the operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recorded step. The processing result includes: elimination processing and merging processing.
[0095] In this embodiment of the invention, for some complex operations, such as multiple steps for logging in that can be combined into a login method call, or returning a modified value of an element that may invalidate some operations after the last operation, a preset analysis model can be used for intelligent simplification.
[0096] In this embodiment, the input feature vector for training the dedicated fine-tuning model (i.e., the preset analysis model) is: [operation type, DOM page layout, historical operation sequence, current operation result]. For each operation step (JSON format), the current DOM structure and all historical operation sequences (JSON format) are given to the model, and the current operation result is informed to the model. The results are divided into the following types: (1) useless steps, which can be eliminated; (2) steps that cannot be eliminated; (3) public method calls, which can be merged.
[0097] After training, the model possesses the ability to intelligently analyze and simplify complex operations. It can analyze the type of the current step (whether it needs to be removed or belongs to a public method call, etc.) by combining the current step context and page structure. When using it, the model's feature vector is passed in as: [operation type, DOM page layout, historical operation sequence], and the model returns the operation result. Based on the operation result, the current step is processed. It iterates through all steps, providing the analysis result for each step, and then processes each step accordingly.
[0098] Specifically, the operation type is determined by extracting the `action_type` field from the JSON format data describing the candidate steps. Simultaneously, the DOM structure of the current page is obtained using the browser driver, and necessary filtering and structural parsing are performed to extract page layout features. A set of all recorded steps executed before the candidate step descriptions is also obtained, resulting in a historical operation sequence. The operation type, page structure, and historical operation sequence are integrated into a structured data format (target feature vector), such as a list or dictionary, containing the current operation type, the feature vector of the page structure (e.g., a hierarchical representation of the DOM tree or a list of key elements), and the historical sequence of preceding operations.
[0099] Then, the target feature vector is input into a pre-defined analysis model. Based on its pattern recognition capabilities from the training data, the model outputs specific operational guidance, such as whether to eliminate or merge the operation. Here, the pre-defined analysis model is trained on historical feature vectors. Historical feature vectors include the operation type, page layout, historical operation sequence, and historical processing results corresponding to historical recorded steps. The model training process involves analyzing a large number of step descriptions and labeling the standardized processing results (elimination, merging, or retention) of these descriptions, enabling the model to learn to identify which operations are removable and which operations can be merged. The output of the pre-defined analysis model indicates the processing method for candidate step descriptions, including elimination (steps that can be directly deleted) and merging (operations that can be merged with previous or subsequent steps).
[0100] In this embodiment, redundant operations are removed and similar steps are merged by leveraging the model's intelligent judgment, making the test script more concise. Furthermore, by eliminating meaningless operations, test failures caused by redundant steps are avoided, enhancing the reliability of the test results. Thus, the efficiency and quality of UI automated testing are improved, testing costs are reduced, and this has a positive impact on software development.
[0101] To improve the accuracy of operating on each candidate step description, in the software testing method based on recorded steps provided in Embodiment 1 of this application, when the processing result is elimination processing, the candidate step descriptions are eliminated; when the processing result is merging processing, all candidate step descriptions to be merged and the merging type are determined; the calling method class corresponding to the merging type is determined, and the calling method class is used to replace all candidate step descriptions to be merged.
[0102] In this embodiment of the invention, when the processing result output by the preset analysis model is elimination processing, it indicates that the current candidate step description is redundant or invalid and does not make a substantial contribution to the execution of the test script. These steps can be eliminated to reduce redundant operations in the test script, improve the efficiency of script execution, and also reduce the maintenance cost of the script.
[0103] When the processing result indicates a merge, it's necessary to further determine which step descriptions need to be merged and the merge type for these step descriptions. The merge type may include, but is not limited to, login operation merging, data input merging, etc., depending on the identification results of the preset analysis model. Then, based on the merge type of the step description, the appropriate calling method class for that type of operation is determined. For example, if the merge type is a login operation, the calling method class is the implementation class of the login method; if it's data input, it might be the implementation class of the data input method. The determined calling method class is used to replace the candidate step descriptions marked as needing merging, thereby automating the replacement of merge operations in the test script. In this way, by efficiently executing the calling method class, lengthy operation sequences are replaced, simplifying the test script, reducing unnecessary lines of code, and improving script readability and execution speed.
[0104] For example, by returning results from the model, we can obtain the steps that need to be merged, and then delete these steps and replace them with public method calls. For instance, we can merge "Enter username → Enter password → Click Remember account" into "Execute login operation".
[0105] In this embodiment, by eliminating redundant steps and intelligently merging operations, unnecessary script execution time is reduced, the script structure is simplified, and the maintenance workload of subsequent test scripts is reduced.
[0106] To ensure the validity of the generated test script, in the software testing method based on recording steps provided in Embodiment 1 of this application, after generating a target test script based on target recording data, an original test script is generated based on the recording data; the original test script is executed, and the original page structure of each page during the execution of the original test script and the original execution result after execution are obtained; the target test script is executed, and the target page structure of each page during the execution of the target test script and the target execution result after execution are obtained; the similarity between the original page structure and the target page structure of each same page is calculated to obtain the average similarity; if the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result, the target test script is determined to be a valid test script.
[0107] In this embodiment of the invention, the verification module can invoke the automated scripts before and after simplification respectively, and compare the execution results. If the DOM similarity during the execution process reaches 80% and the execution results (all steps are executed normally and assertions pass) are consistent, then the simplification process is considered effective. If the verification passes, the original script can be replaced.
[0108] Specifically, based on the user's actions on the UI interface, a recording tool is used to completely record each operation, automatically generating an original test script containing all operation steps. The original test script retains all recorded operation details and serves as the baseline for test execution. Then, the generated original test script is executed, recording the original page structure of each page (i.e., the page state before the operation) and the original execution result (e.g., test case pass or fail) after the operation. Furthermore, the simplified target test script is executed, similarly recording the target page structure of each page (i.e., the page state before the operation after the simplified steps) and the target execution result (also the test case pass or fail status) after the operation. Next, for the same pages in the original and target test scripts, a similarity calculation is performed on the original and target page structures. For example, DOM tree structural difference analysis and comparison of rendering results after CSS / JavaScript execution are used to obtain an average similarity value. Then, the average similarity is compared with a preset threshold (e.g., 80%), while simultaneously checking whether the original execution result is consistent with the target execution result. If the average similarity exceeds the threshold and the execution results are the same, the target test script is determined to be a valid test script.
[0109] In this embodiment, by comparing the execution results with the original test script and calculating the similarity of the page structure, it is ensured that the target test script can accurately complete the test objectives. This not only improves the execution efficiency of UI automation testing but also ensures the accuracy and reliability of the testing process, providing strong support for automated testing in continuous integration and continuous deployment processes.
[0110] The software testing method based on recording steps provided in this application adopts the method of recording user interface operations. By constructing an atomic description framework for operations, the user interface operations of the software under test are accurately recorded, resulting in recording data containing multiple recording steps. Then, each recording step can be parsed to extract its step description. Subsequently, redundant operations are intelligently identified and eliminated using preset detection rules to form more refined initial recording data. A preset analysis model is then used to analyze each candidate step description, and further optimization operations are performed on the candidate step descriptions based on the model's processing results to obtain the target recording data. Finally, an efficient target test script is automatically generated based on the target recording data. This script is used to perform automated testing of the software, effectively solving the technical problems of low efficiency and high technical maintenance costs caused by redundant steps in the test script. It achieves the technical effects of improving testing efficiency, reducing maintenance costs, enhancing script reliability, and increasing test coverage.
[0111] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0112] Example 2
[0113] This application also provides a software testing apparatus based on recording steps. It should be noted that this software testing apparatus based on recording steps can be used to execute the software testing method based on recording steps provided in this application. The software testing apparatus based on recording steps provided in this application will be described below.
[0114] According to an embodiment of this application, an apparatus for implementing the above-described software testing method based on recording steps is also provided. Figure 4 This is a schematic diagram of an optional software testing apparatus based on recording steps according to an embodiment of the present invention, such as... Figure 4 As shown, the software testing device may include: an operation unit 40, a parsing unit 41, an identification unit 42, a processing unit 43, and a generation unit 44.
[0115] The operation unit 40 is used to perform user interface operations on the software to be tested and record the operation process to obtain recording data, wherein the recording data includes: multiple recording steps;
[0116] Parsing unit 41 is used to parse each recording step to obtain the step description corresponding to each recording step;
[0117] The identification unit 42 is used to identify each step description based on a preset detection rule, and to perform a deletion operation on the recorded data based on the identification result to obtain initial recorded data, wherein the initial recorded data includes: multiple candidate step descriptions;
[0118] The processing unit 43 is used to process each candidate step description using a preset analysis model, and to perform operations on each candidate step description based on the processing results to obtain target recording data.
[0119] The generation unit 44 is used to generate a target test script based on the target recorded data, and to use the target test script to test the software under test.
[0120] The software testing apparatus based on recording steps provided in this application adopts a method of recording user interface operations. By constructing an operation atomic description framework, it accurately records the user interface operations of the software to be tested, obtaining recording data containing multiple recording steps. Then, each recording step can be parsed to extract its step description. Subsequently, redundant operations are intelligently identified and eliminated using preset detection rules to form more refined initial recording data. A preset analysis model is then used to analyze each candidate step description, and further optimization operations are performed on the candidate step descriptions based on the model's processing results, simplifying them to obtain target recording data. Finally, an efficient target test script is automatically generated based on the target recording data. This script is used to perform automated testing of the software, effectively solving the technical problems of low efficiency and high technical maintenance costs caused by redundant steps in the test script. It achieves the technical effects of improving testing efficiency, reducing maintenance costs, enhancing script reliability, and increasing test coverage.
[0121] Optionally, the parsing unit includes: a first determining module, used to parse the recording steps and determine the operation type, operation element, and operation timestamp of the recording steps; a first extraction module, used to extract the first page structure before the execution of the recording steps and determine the first fingerprint feature before the execution of the recording steps based on the first page structure; a second determining module, used to extract the second page structure after the execution of the recording steps and determine the second fingerprint feature after the execution of the recording steps based on the second page structure; and a first encapsulation module, used to encapsulate the operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature to obtain a step description.
[0122] Optionally, the identification unit includes: a first identification module, used to identify the operation type and operation element in the step description based on the valid detection rule when the preset detection rule is a valid detection rule; a third determination module, used to determine that the step description is an invalid step when the operation type and operation element do not match; and a first deletion module, used to delete invalid steps.
[0123] Optionally, the identification unit further includes: a second identification module, used to identify the operation type and operation element in two adjacent step descriptions based on the same element detection rule when the preset detection rule is the same element detection rule; a fourth determination module, used to determine that two adjacent step descriptions are the same step when the operation elements in two adjacent step descriptions are the same, and the operation type in the latter step description is the same as or appended to the operation type in the former step description, wherein appended same means that the latter operation type is different from the former operation type, and the page does not change after the step description indicated by the latter operation type is executed; and a second deletion module, used to perform a deletion operation on any one of the step descriptions in the same step.
[0124] Optionally, the identification unit further includes: a third identification module, used to identify the first fingerprint feature and the second fingerprint feature in the step description based on the empty operation detection rule when the preset detection rule is the empty operation detection rule; a fifth determination module, used to determine that the page has not changed after the execution of the step description when the first fingerprint feature and the second fingerprint feature are the same; and a third deletion module, used to determine the step description as an empty operation step and perform a deletion operation on the empty operation step.
[0125] Optionally, the processing unit includes: a sixth determining module, used to determine the operation type described in the candidate step description and determine the page structure of the current page; a first obtaining module, used to obtain all recorded steps executed before the candidate step description to obtain a historical operation sequence; a seventh determining module, used to determine the target feature vector based on the operation type, page structure, and historical operation sequence; and a first input module, used to input the target feature vector into a preset analysis model to obtain the processing result, wherein the preset analysis model is a model trained based on the historical feature vector, and the historical feature vector includes: the operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recorded step; the processing result includes: elimination processing and merging processing.
[0126] Optionally, the processing unit includes: a first elimination module, used to eliminate candidate step descriptions when the processing result is elimination processing; an eighth determination module, used to determine all candidate step descriptions to be merged and the merging type when the processing result is merging processing; and a ninth determination module, used to determine the calling method class corresponding to the merging type and use the calling method class to replace all candidate step descriptions to be merged.
[0127] Optionally, the software testing device further includes: a first generation module, used to generate an original test script based on the recorded data after generating a target test script based on the target recorded data; a first execution module, used to execute the original test script and obtain the original page structure of each page during the execution of the original test script and the original execution result after execution; a second execution module, used to execute the target test script and obtain the target page structure of each page during the execution of the target test script and the target execution result after execution; a first calculation module, used to calculate the similarity between the original page structure and the target page structure of each same page to obtain the average similarity; and a tenth determination module, used to determine that the target test script is a valid test script when the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result.
[0128] The aforementioned software testing device may also include a processor and a memory. The aforementioned operation unit 40, parsing unit 41, identification unit 42, processing unit 43, generation unit 44, etc., are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0129] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, a target test script can be generated based on the target recorded data. This target test script is then used to test the software under test.
[0130] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0131] It should be noted that the above-mentioned operation unit 40, parsing unit 41, identification unit 42, processing unit 43, and generation unit 44 correspond to steps S201 to S205 in Embodiment 1. The instances and application scenarios implemented by the above units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above units can also be part of the device and run in the computer terminal 10 provided in Embodiment 1.
[0132] Example 3
[0133] Embodiments of this application may provide an electronic device. Figure 5 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Figure 5 As shown, the electronic device may include: one or more ( Figure 5 (Only one is shown) processor 502, memory 504, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0134] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the software testing method and apparatus based on recording steps in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned software testing method based on recording steps. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0135] The processor can access information and applications stored in memory via a transmission device to perform the following steps: Perform user interface operations on the software under test and record the operation process to obtain recorded data, wherein the recorded data includes multiple recording steps; parse each recording step to obtain a step description corresponding to each recording step; identify each step description based on preset detection rules, and based on the identification results, perform deletion operations on the recorded data to obtain initial recorded data, wherein the initial recorded data includes multiple candidate step descriptions; process each candidate step description using a preset analysis model, and based on the processing results, perform operations on each candidate step description to obtain target recorded data; generate a target test script based on the target recorded data, and use the target test script to test the software under test.
[0136] The processor can access information and applications stored in the memory via a transmission device to perform the following steps: parse the recording step to determine the operation type, operation element, and operation timestamp of the recording step; extract the first page structure before the recording step is executed, and determine the first fingerprint feature before the recording step is executed based on the first page structure; extract the second page structure after the recording step is executed, and determine the second fingerprint feature after the recording step is executed based on the second page structure; encapsulate the operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature to obtain a step description.
[0137] The processor can access information and applications stored in memory via a transmission device to perform the following steps: if the preset detection rule is a valid detection rule, identify the operation type and operation element in the step description based on the valid detection rule; if the operation type and operation element do not match, determine that the step description is an invalid step; and perform deletion operations on the invalid steps.
[0138] The processor can invoke information and application programs stored in the memory through the transmission device to perform the following steps: If the preset detection rule is a same element detection rule, identify the operation type and operation element in two adjacent step descriptions based on the same element detection rule; if the operation elements in two adjacent step descriptions are the same, and the operation type in the latter step description is the same as or appended to the operation type in the former step description, determine that the two adjacent step descriptions are the same step, where appended same means that the latter operation type is different from the former operation type, and the page remains unchanged after the execution of the step description indicated by the latter operation type; perform a deletion operation on any step description in the same step.
[0139] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: when the preset detection rule is the no-operation detection rule, identify the first fingerprint feature and the second fingerprint feature in the step description based on the no-operation detection rule; when the first fingerprint feature and the second fingerprint feature are the same, determine that the page has not changed after the execution of the step description; determine the step description as a no-operation step, and perform a deletion operation on the no-operation step.
[0140] The processor can access information and applications stored in the memory via a transmission device to perform the following steps: determine the operation type described in the candidate step description and determine the page structure of the current page; obtain all recorded steps executed before the candidate step description to obtain a historical operation sequence; determine the target feature vector based on the operation type, page structure, and historical operation sequence; input the target feature vector into a preset analysis model to obtain the processing result, wherein the preset analysis model is a model trained based on the historical feature vector, and the historical feature vector includes: the operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recorded step; the processing result includes: elimination processing and merging processing.
[0141] The processor can invoke information and application programs stored in memory via a transmission device to perform the following steps: if the processing result is elimination processing, eliminate candidate step descriptions; if the processing result is merging processing, determine all candidate step descriptions to be merged and the merging type; determine the calling method class corresponding to the merging type, and use the calling method class to replace all candidate step descriptions to be merged.
[0142] The processor can access the information and application programs stored in the memory via a transmission device to perform the following steps: generating an original test script based on recorded data; executing the original test script and obtaining the original page structure of each page during the execution of the original test script and the original execution result after execution; executing the target test script and obtaining the target page structure of each page during the execution of the target test script and the target execution result after execution; calculating the similarity between the original page structure and the target page structure of each page to obtain the average similarity; determining that the target test script is a valid test script if the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result.
[0143] This application provides a software testing scheme based on recorded steps. By recording user interface operations and constructing an atomic description framework for operations, the user interface operations of the software under test are precisely recorded, resulting in recorded data containing multiple recording steps. Each recorded step is then parsed to extract its description. Redundant operations are intelligently identified and eliminated using preset detection rules, forming more refined initial recorded data. A preset analysis model is then used to analyze each candidate step description, and further optimization is performed based on the model's processing results to obtain the target recorded data. Finally, an efficient target test script is automatically generated based on the target recorded data. This script is used for automated software testing, effectively solving the technical problems of low efficiency and high maintenance costs caused by redundant steps in test scripts. This achieves the technical effects of improving testing efficiency, reducing maintenance costs, enhancing script reliability, and increasing test coverage.
[0144] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be terminal devices such as smartphones, tablets, PDAs, and mobile internet devices (MIDs). Figure 5 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0145] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0146] Example 4
[0147] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the software testing method based on the recording steps provided in Embodiment 1.
[0148] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0149] This application also provides a computer program product that, when executed on a data processing device, is suitable for executing software testing method steps based on recorded steps.
[0150] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0151] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed technical content 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. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0153] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0154] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0155] If the integrated unit is implemented as 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 this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) 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 a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0156] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A software testing method based on recording steps, characterized in that, include: The user interface of the software to be tested is operated, and the operation process is recorded to obtain recording data, wherein the recording data includes: multiple recording steps; Each recording step is parsed to obtain a step description corresponding to each recording step; Based on preset detection rules, each step description is identified, and based on the identification results, the recorded data is reduced to obtain initial recorded data, wherein the initial recorded data includes: multiple candidate step descriptions; Each candidate step description is processed using a preset analysis model, and based on the processing results, operations are performed on each candidate step description to obtain target recording data; Based on the target recorded data, a target test script is generated, and the target test script is used to test the software to be tested.
2. The software testing method according to claim 1, characterized in that, Each recording step is parsed to obtain the step description corresponding to each recording step, including: The recording steps are parsed to determine the operation type, operation element, and operation timestamp of the recording steps; Extract the first page structure before the recording step is executed, and determine the first fingerprint feature before the recording step is executed based on the first page structure; Extract the second page structure after the recording step is executed, and determine the second fingerprint feature after the recording step is executed based on the second page structure; The operation type, operation element, operation timestamp, first fingerprint feature, and second fingerprint feature are encapsulated to obtain the step description.
3. The software testing method according to claim 1, characterized in that, The steps of identifying each step description based on preset detection rules and deleting the recorded data based on the identification results include: If the preset detection rule is a valid detection rule, the operation type and operation element in the step description are identified based on the valid detection rule. If the operation type does not match the operation element, the step description is determined to be an invalid step; The invalid steps are deleted.
4. The software testing method according to claim 1, characterized in that, The steps of identifying each step description based on preset detection rules and deleting the recorded data based on the identification results include: When the preset detection rule is the same element detection rule, the operation type and operation element in two adjacent step descriptions are identified based on the same element detection rule. If the operation elements in two adjacent step descriptions are the same, and the operation type in the later step description is the same as or appended to the operation type in the earlier step description, then the two adjacent step descriptions are determined to be the same step. The appended same means that the later operation type is different from the earlier operation type, and the page does not change after the step description indicated by the later operation type is executed. The description of any one of the steps in the same sequence is deleted.
5. The software testing method according to claim 1, characterized in that, The steps of identifying each step description based on preset detection rules and deleting the recorded data based on the identification results include: When the preset detection rule is a no-operation detection rule, the first fingerprint feature and the second fingerprint feature in the step description are identified based on the no-operation detection rule. If the first fingerprint feature and the second fingerprint feature are the same, it is determined that the page has not changed after the execution of the steps described above; The steps described are identified as empty operation steps, and these empty operation steps are then removed.
6. The software testing method according to claim 1, characterized in that, The steps of processing each candidate step description using a preset analysis model include: Determine the operation type described by the candidate steps, and determine the page structure of the current page; Obtain all the recorded steps executed before the candidate step description to obtain the historical operation sequence; Based on the operation type, the page structure, and the historical operation sequence, determine the target feature vector; The target feature vector is input into the preset analysis model to obtain the processing result. The preset analysis model is a model trained based on historical feature vectors. The historical feature vectors include: operation type, page layout, historical operation sequence, and historical processing result corresponding to each historical recording step. The processing result includes: elimination processing and merging processing.
7. The software testing method according to claim 1, characterized in that, Based on the processing results, the steps for performing the operation are described for each candidate step, including: If the processing result is a rejection process, the candidate step descriptions are rejected. If the processing result is a merge process, determine the descriptions of all candidate steps to be merged and the merge type; Determine the calling method class corresponding to the merging type, and use the calling method class to replace all the candidate step descriptions to be merged.
8. The software testing method according to claim 1, characterized in that, After generating the target test script based on the target recording data, the process also includes: Based on the recorded data, generate the original test script; Execute the original test script and obtain the original page structure of each page during the execution of the original test script, as well as the original execution result after execution; Execute the target test script and obtain the target page structure of each page during the execution of the target test script, as well as the target execution result after execution; For each page with the same original page structure and the target page structure, a similarity calculation is performed to obtain the average similarity. If the average similarity is greater than a preset threshold and the original execution result is consistent with the target execution result, the target test script is determined to be a valid test script.
9. A software testing device based on recording steps, characterized in that, include: An operation unit is used to perform user interface operations on the software to be tested and record the operation process to obtain recording data, wherein the recording data includes: multiple recording steps; The parsing unit is used to parse each of the recording steps to obtain a step description corresponding to each of the recording steps; The identification unit is used to identify each step description based on a preset detection rule, and to perform a deletion operation on the recorded data based on the identification result to obtain initial recorded data, wherein the initial recorded data includes: multiple candidate step descriptions; The processing unit is used to process each candidate step description using a preset analysis model, and to perform operations on each candidate step description based on the processing results to obtain target recording data. The generation unit is used to generate a target test script based on the target recorded data, and to use the target test script to test the software to be tested.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the software testing method based on recording steps as described in any one of claims 1 to 8.