Method, device, electronic device and storage medium for recovering from interruption in test link

By building a state snapshot library and performing exception backtracking, automated test interruption recovery solves the problem of automated test interruption relying on manual labor and improves test efficiency and accuracy.

CN120256321BActive Publication Date: 2025-09-09GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510741881.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-09-09
Estimated Expiration
2045-06-05

AI Technical Summary

Technical Problem

During the automated testing process, interruptions caused by network fluctuations, pop-up window interference, or element loading timeouts require manual intervention to recover, which is inflexible and inefficient.

Method used

Build a status snapshot library, obtain snapshot data in response to page changes, perform exception backtracking after detecting abnormal events, automatically execute target test operations, and reduce dependence on manual intervention.

Benefits of technology

Adaptive interrupt recovery is achieved, which improves test efficiency and accuracy, reduces data processing volume, and reduces reliance on manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256321B_ABST
    Figure CN120256321B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides an interruption recovery method, device, electronic device and storage medium in a test link, relating to the field of automated testing technology. The method includes: in response to page changes occurring in a test object during an automated test process, constructing a state snapshot library corresponding to the page changes; in response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library; performing abnormal backtracing based on the abnormal snapshot data and the first valid snapshot data, determining a first target test operation corresponding to the abnormal event, and executing the first target test operation, thereby reducing dependence on manual intervention and achieving adaptive interruption recovery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing technology, and in particular to a method for recovering from an interruption in a test link, a device for recovering from an interruption in a test link, an electronic device, and a computer-readable storage medium. Background Art

[0002] Automated testing is an integral part of the software development process, improving testing efficiency, reducing human error, and ensuring software quality. However, if the automated testing process is interrupted due to network fluctuations, pop-up window interference, or element loading timeouts, manual intervention by testers is often required to resume automated testing. This makes the testing process overly dependent on testers, lacks flexibility, and results in low execution efficiency. Summary of the Invention

[0003] The embodiments of the present invention provide a method, device, electronic device and computer-readable storage medium for recovering from an interruption in a test link, so as to solve or partially solve the problems that the test process is overly dependent on testers, has poor flexibility and low execution efficiency.

[0004] An embodiment of the present invention discloses a method for recovering from an interruption in a test link, comprising:

[0005] In response to page changes of the test object during the automated testing process, a state snapshot library corresponding to the page changes is constructed;

[0006] In response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library;

[0007] An exception backtracking is performed based on the abnormal snapshot data and the first valid snapshot data to determine a first target test operation corresponding to the abnormal event, and the first target test operation is executed.

[0008] In some feasible implementations, in response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library includes:

[0009] In response to detecting an abnormal event that triggers a test interruption, acquiring abnormal snapshot data corresponding to the abnormal event from the state snapshot library;

[0010] Perform process backtracking based on the abnormal snapshot data to determine the backtracking node for the abnormal event;

[0011] According to the backtracking nodes and in reverse time order, first valid snapshot data corresponding to the abnormal event is extracted from the state snapshot library.

[0012] In some feasible implementations, the abnormal snapshot data includes a first page screenshot, first DOM structure data corresponding to the first page screenshot, and a first semantic tag, and performing process backtracking based on the abnormal snapshot data to determine a backtracking node for the abnormal event includes:

[0013] The first page screenshot, the first DOM structure data, and the first semantic tag are used to perform process backtracing to determine a backtracing node for the abnormal event.

[0014] In some feasible implementations, the first valid snapshot data includes a second page screenshot, second DOM structure data corresponding to the second page screenshot, and a second semantic tag, and performing anomaly backtracking based on the abnormal snapshot data and the first valid snapshot data to determine a first target test operation corresponding to the abnormal event includes:

[0015] The first page screenshot, the first DOM structure data, the first semantic tag, the second page screenshot, the second DOM structure data, and the second semantic tag are used to perform exception backtracing to determine a first target test operation corresponding to the exception event.

[0016] In some feasible implementations, in response to page changes of the test object during the automated testing process, building a state snapshot library corresponding to the page changes includes:

[0017] In response to page changes occurring in the test object during the automated testing process, obtaining a page screenshot corresponding to the page change and DOM structure data corresponding to the page screenshot;

[0018] Using the page screenshot and the DOM structure data to perform page recognition, and obtain a semantic tag corresponding to the page screenshot;

[0019] Based on the page screenshot, the DOM structure data and the semantic tags, a state snapshot library corresponding to the page changes is constructed.

[0020] In some feasible implementations, constructing a state snapshot library corresponding to the page change based on the page screenshot, the DOM structure data, and the semantic tag includes:

[0021] Obtaining basic page data corresponding to the page screenshot;

[0022] Based on the page screenshot, the DOM structure data, the semantic tags and the page basic data, a state snapshot library corresponding to the page change is constructed.

[0023] In some feasible implementations, the first valid snapshot data is snapshot data corresponding to n valid execution events before the abnormal event, and the method further includes:

[0024] If the execution of the first target test operation fails, extracting second valid snapshot data corresponding to m valid execution events before the abnormal event from the state snapshot library according to the backtracking nodes and in reverse time order;

[0025] Performing anomaly backtracking based on the second valid snapshot data and the abnormal snapshot data, determining a second target test operation corresponding to the abnormal event, and executing the second target test operation;

[0026] wherein, n is smaller than m;

[0027] The first target test operation is the same as or different from the second target test operation.

[0028] Some possible implementations also include:

[0029] If the number of failures of the backtracking execution target test operation reaches a preset threshold, a backtracking execution log and an interruption exception log for the abnormal event are generated.

[0030] The embodiment of the present invention further discloses a device for recovering from an interruption in a test link, comprising:

[0031] A snapshot recording module is used to construct a state snapshot library corresponding to page changes of the test object during the automated testing process;

[0032] a data extraction module, configured to extract, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library;

[0033] The backtracking module is configured to perform an abnormality backtracking based on the abnormal snapshot data and the first valid snapshot data, determine a first target test operation corresponding to the abnormal event, and execute the first target test operation.

[0034] In some feasible implementations, the data extraction module is specifically configured to:

[0035] In response to detecting an abnormal event that triggers a test interruption, acquiring abnormal snapshot data corresponding to the abnormal event from the state snapshot library;

[0036] Perform process backtracking based on the abnormal snapshot data to determine the backtracking node for the abnormal event;

[0037] According to the backtracking nodes and in reverse time order, first valid snapshot data corresponding to the abnormal event is extracted from the state snapshot library.

[0038] In some feasible implementations, the abnormal snapshot data includes a first page screenshot, first DOM structure data corresponding to the first page screenshot, and a first semantic tag, and the data extraction module is specifically configured to:

[0039] The first page screenshot, the first DOM structure data, and the first semantic tag are used to perform process backtracing to determine a backtracing node for the abnormal event.

[0040] In some feasible implementations, the first valid snapshot data includes a second page screenshot, second DOM structure data corresponding to the second page screenshot, and a second semantic tag, and the data extraction module is specifically configured to:

[0041] The first page screenshot, the first DOM structure data, the first semantic tag, the second page screenshot, the second DOM structure data, and the second semantic tag are used to perform exception backtracing to determine a first target test operation corresponding to the exception event.

[0042] In some feasible implementations, the snapshot recording module is specifically configured to:

[0043] In response to page changes occurring in the test object during the automated testing process, obtaining a page screenshot corresponding to the page change and DOM structure data corresponding to the page screenshot;

[0044] Using the page screenshot and the DOM structure data to perform page recognition, and obtain a semantic tag corresponding to the page screenshot;

[0045] Based on the page screenshot, the DOM structure data and the semantic tags, a state snapshot library corresponding to the page changes is constructed.

[0046] In some feasible implementations, the snapshot recording module is specifically configured to:

[0047] Obtaining basic page data corresponding to the page screenshot;

[0048] Based on the page screenshot, the DOM structure data, the semantic tags and the page basic data, a state snapshot library corresponding to the page change is constructed.

[0049] In some feasible implementations, the first valid snapshot data is snapshot data corresponding to n valid execution events before the abnormal event, and the apparatus further includes:

[0050] a retry module configured to extract, if the execution of the first target test operation fails, second valid snapshot data corresponding to m valid execution events before the abnormal event from the state snapshot library according to the backtracking nodes and in reverse time order;

[0051] an execution module, configured to perform an exception backtracking based on the second valid snapshot data and the abnormal snapshot data, determine a second target test operation corresponding to the abnormal event, and execute the second target test operation;

[0052] wherein, n is smaller than m;

[0053] The first target test operation is the same as or different from the second target test operation.

[0054] Some possible implementations also include:

[0055] The log output module is used to generate a backtracking execution log and an interruption exception log for the abnormal event if the number of failures of the backtracking execution target test operation reaches a preset threshold.

[0056] An embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0057] The memory is used to store computer programs;

[0058] The processor is configured to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0059] An embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method according to the embodiment of the present invention.

[0060] The embodiments of the present invention include the following advantages:

[0061] In an embodiment of the present invention, during the process of automated testing of a test object, page changes of the test object can be monitored in real time. In response to page changes of the test object occurring during the automated testing process, a state snapshot library corresponding to the page changes can be constructed. Then, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data are extracted from the state snapshot library. Then, an abnormal backtracking is performed based on the abnormal snapshot data and the first valid snapshot data to determine the first target test operation corresponding to the abnormal event, and the first target test operation is executed. Therefore, during the automated testing process, snapshot data mapping is performed for each page change. When an abnormal event causing a test interruption occurs, the corresponding abnormal snapshot data and valid snapshot data can be extracted for backtracking to determine the target test operation corresponding to the abnormal event. Then, the target test operation is automatically executed, thereby reducing dependence on manual intervention and achieving adaptive interruption recovery. Backtracking can be achieved through limited snapshot data, reducing the amount of data processing. In addition, by extracting the corresponding snapshot data, the accuracy of backtracking is improved, which is conducive to increasing the possibility of successful interruption recovery. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 This is a flowchart of a method for recovering from an interruption in a test link provided in an embodiment of the present invention;

[0063] Figure 2 This is a schematic diagram of the automated testing process provided in an embodiment of the present invention;

[0064] Figure 3 It is a structural block diagram of an interruption recovery device in a test link provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0065] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0066] As an example, in automated testing processes, the inability to recover from test interruptions is one of the core issues leading to low execution efficiency. For example, network fluctuations, pop-up window interference, or page element loading timeouts can all lead to unexpected interruptions, requiring testers to review error log records and select appropriate workarounds to re-execute the test, or to wait for the interruption to disappear through a fixed number of retries or timeouts. This process lacks intelligent analysis of the cause of the interruption and requires testers to fully participate in the automated test execution process, resulting in "semi-automated" testing with many testing restrictions and low test efficiency.

[0067] Reference Figure 1, shows a flowchart of a method for recovering from an interruption in a test link provided in an embodiment of the present invention, which may specifically include the following steps:

[0068] Step 101: In response to page changes of a test object during an automated test, a state snapshot library corresponding to the page changes is constructed;

[0069] Optionally, the test object can be software that requires automated testing, such as applications, applets, and browser pages. During the testing of the test object, the corresponding test page can be presented in real time so that the tester can intuitively perceive the real-time progress of the test and the test results.

[0070] For example, the test object can be an application, and the test page can be the application interface corresponding to the application. The application interface can include corresponding page elements. The test process can involve testing whether the corresponding page elements are responsive, and triggering further page operations by entering corresponding content in the application page.

[0071] The page change can be a change in any page element on the test page, such as filling an input box with content, deleting the content originally filled in the input box, selecting a page element, deselecting a previously selected page element, and page redirection. Optionally, page elements include, but are not limited to, buttons, input boxes, drop-down boxes, check boxes, radio buttons, links, and text. When these page elements change, it can be determined that the test page has changed, thereby triggering the acquisition of corresponding page data and constructing a corresponding state snapshot based on the acquired page data.

[0072] In some feasible implementations, for the construction process of the state snapshot library, each time a page change occurs, by responding to the page change of the test object during the automated testing process, a page screenshot corresponding to the page change and the DOM structure data corresponding to the page screenshot are obtained, and then the page screenshot and DOM structure data are used to perform page identification, and the semantic tag corresponding to the page screenshot is obtained. Then, based on the page screenshot, DOM structure data and semantic tag, a state snapshot library corresponding to the page change is constructed, so that all page changes in the test process are completely recorded by taking all page changes as the basic node for snapshot storage, which is not only conducive to data backtracking, but also can realize adaptive interruption recovery by extracting the corresponding data for backtracking in the event of an abnormal interruption.

[0073] Optionally, during the process of building the state snapshot library, the page basic data corresponding to the page screenshot can also be obtained, and then based on the page screenshot, DOM structure data, semantic tags, and page basic data, the state snapshot library corresponding to the page change is built, further improving the integrity of the data.

[0074] Among them, the page screenshot can be the state image corresponding to the test page when the page changes. For example, when the corresponding target information is entered in the input box, after the information is entered, the image containing the target information obtained by taking a screenshot of the test page; when the target page element in the test page is selected, the image in which the target page element is selected obtained by taking a screenshot of the test page, etc.

[0075] For the test page, when any change occurs to the page, it will be accompanied by a change in the DOM element structure of the page. Therefore, based on the change of the DOM elements, the operation changes of the page can be recorded, and the data content of the operation layer corresponding to the page screenshot can be recorded. In some examples, each switch button in the test page can correspond to a DOM, which includes the display attribute indicating whether it is visible or hidden, the attribute indicating whether it is highlighted, and basic attributes such as the size and color of the basic button. And each DOM forms a complete page. For example, when automatically testing a power-on and power-off function, by parsing the DOM tree of the test page, the entire DOM tree structure in the power-off state is obtained. Then, after clicking the power-on button, the power-on button lights up. At this time, the entire DOM tree structure is also recorded. Then, by comparison, it can be seen that the power-on button changes from off (such as gray, etc.) to on (such as blue, etc.). Thus, by recording the DOM structure data, the page changes are recorded from the perspective of the operation layer.

[0076] Furthermore, the basic data of the page, such as URL, Cookies, LocalStorage, etc., can also be recorded. Specifically, the page is composed of a combination of DOM elements to form a page, and the overall rendering access of the page needs to be through the URL (Uniform Resource Locator). By concatenating corresponding parameters, such as www.xxx.com?query=“question” etc. for query access. Therefore, the URL needs to be recorded, and the page basic data such as Cookies and LocalStorage can be cached data in the browser, used to store the page state.

[0077] After obtaining the above-mentioned page screenshots, DOM structure data, and page basic data, semantic recognition can be further performed based on the obtained page screenshots and DOM structure data to identify whether there are abnormal elements in the page screenshots (such as pop-ups, loading icons that cannot be hidden, etc.), and thereby generate semantic tags that meet the model deduction (for example, the semantic tag can be "air conditioning control page-when starting cooling-loading icon abnormality", etc.), so as to build a state snapshot library corresponding to page changes based on page screenshots, DOM structure data, semantic tags, and page basic data, so as to completely record all page changes during the test process by taking all page changes as the basic node for snapshot storage, which is not only conducive to data backtracking, but also can achieve adaptive interruption recovery by extracting the corresponding data for backtracking in the event of an abnormal interruption.

[0078] It should be noted that during the automated testing process, corresponding semantic tags can be added to all page screenshots. The added tags can be executed synchronously with the automated testing, and can be added according to the automated testing script. For example, when the script executes the power-on script, the tag corresponding to the page screenshot can be defined as "air conditioning control page-power on". If there is no exception in the script execution, there is no need to splice subsequent exception tags. If the exception cannot be identified, the exception tag can be added by default, such as "air conditioning control page-power on-exception", so that the corresponding semantic tags can be used for auxiliary identification, thereby completing the record storage of all changes during the test process by building a corresponding state snapshot library.

[0079] Step 102: In response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library;

[0080] During the execution of the automated test process, when an abnormal event that triggers a test interruption is detected, the abnormal snapshot data corresponding to the abnormal event and the first valid snapshot data corresponding to the abnormal snapshot data can be extracted from the state snapshot library, so as to perform process backtracing based on the extracted abnormal snapshot data and the first valid snapshot data, and attempt to restore the automated test process, thereby realizing adaptive interruption recovery.

[0081] Among them, triggering an abnormal event means failing to execute the corresponding test operation, and for the currently executed test operation, it will cause changes in the test page, thereby recording the corresponding snapshot data. Therefore, when an abnormal event that triggers a test interruption is detected, the corresponding abnormal snapshot data can be obtained based on the abnormal event, so as to perform process backtracing based on the obtained snapshot data.

[0082] In some feasible implementations, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event is obtained from the state snapshot library, and then the process is backtraced based on the abnormal snapshot data to determine the backtracing node for the abnormal event. Then, according to the backtracing node and in reverse time order, the first valid snapshot data corresponding to the abnormal event is extracted from the state snapshot library, and the process is backtraced based on the extracted abnormal snapshot data to determine the corresponding backtracing node, which improves the targetedness of the process backtracing, so that the process backtracing can be performed quickly, and at the same time can significantly improve the test efficiency and the reliability of the backtracing.

[0083] Optionally, the abnormal snapshot data may include a first page screenshot, first DOM structure data corresponding to the first page screenshot, and a first semantic tag. In the process of determining the backtracing node, the first page screenshot, the first DOM structure data, and the first semantic tag may be used to backtrace the process, determine the backtracing node for the abnormal event, and then extract the corresponding first valid snapshot data based on the backtracing node. This improves the pertinence of the process backtracing by locating the valid snapshot data based on the abnormal snapshot data, so that the process backtracing can be performed quickly, and at the same time, the testing efficiency and the reliability of the backtracing can be significantly improved.

[0084] Among them, in the automated testing process, each test operation can be regarded as an execution node, and the test process can be composed of a series of execution nodes, and each execution node corresponds to the execution of a test operation. For example, in the test process of account login, it can include: ① Check the user agreement status before login; ② Enter the password status before login; ③ Enter the account password status before login; ④ Trigger login status, etc., which correspond to different execution operations respectively. Therefore, after detecting the abnormal event that triggers the test interruption, the corresponding abnormal snapshot data can be extracted from the state snapshot library, and the backtracking node can be determined based on the abnormal snapshot data. Assuming that the backtracking node is ④, the first valid snapshot data corresponding to the three valid execution events before the backtracking node can be further extracted, so as to further perform abnormal backtracking based on the extracted snapshot data, thereby realizing adaptive interruption recovery.

[0085] Step 103 : performing an abnormality backtracking based on the abnormal snapshot data and the first valid snapshot data, determining a first target test operation corresponding to the abnormal event, and executing the first target test operation.

[0086] After extracting the abnormal snapshot data and the first valid snapshot data, the two can be referenced against each other to achieve abnormal backtracking, determine the first target test operation corresponding to the abnormal time, and then re-execute the first target test operation, thereby achieving adaptive interruption recovery. Backtracking can be achieved through limited snapshot data, reducing the amount of data processing, and by extracting the corresponding snapshot data, the accuracy of backtracking is improved, which is conducive to increasing the possibility of successful interruption recovery.

[0087] In some feasible implementations, the first valid snapshot data includes the second page screenshot, the second DOM structure data corresponding to the second page screenshot, and the second semantic tag. The first page screenshot, the first DOM structure data, the first semantic tag, the second page screenshot, the second DOM structure data, and the second semantic tag can be used to perform exception backtracing to determine the first target test operation corresponding to the abnormal event, thereby realizing adaptive interruption recovery. Backtracing can be achieved through limited snapshot data, reducing the amount of data processing, and by extracting the corresponding snapshot data, the accuracy of backtracing is improved, which is conducive to increasing the possibility of successful interruption recovery.

[0088] For example, by monitoring the abnormal events thrown by the code during the test, the browser monitors and captures the abnormal events that trigger the interruption, thereby forming an error log, and obtaining the status snapshot data of the current abnormal situation from the status snapshot library, and by retrieving the valid snapshot data of the last three abnormal events without abnormal events from the status snapshot database in reverse chronological order, the abnormal snapshot data (including DOM structure data, page screenshots and semantic tags, etc.) can be input into the preset analysis model for deduction, and the best backtracking node can be recommended. For example, the current abnormal snapshot is (login failure - loading icon abnormality - and the intercepted Toast prompt is a network abnormality), and the three time snapshots selected in reverse chronological order are (1. Login failed - loading icon abnormality - and the intercepted Toast prompt is a network abnormality). If the following conditions are met: 1. Check the user agreement status before logging in 2. Enter the password status before logging in 3. Enter the account status before logging in), it can be inferred that the login failure was not caused by not checking the user agreement or entering an incorrect account and password. The process can be directly backtracked to the state of snapshot 1 where the user password was entered and the user agreement was checked and executed again. The waiting time for the login request is automatically extended to perform interrupted backtracking and recovery. By analyzing the backtracking nodes and performing process backtracking, the dependence on manual intervention is reduced, and adaptive interruption recovery is achieved. Backtracking can be achieved with limited snapshot data, reducing the amount of data processing. By extracting the corresponding snapshot data, the accuracy of backtracking is improved, which is conducive to increasing the possibility of successful interruption recovery.

[0089] In addition, the first valid snapshot data can be the snapshot data corresponding to n valid execution events before the abnormal event, such as the first three valid snapshot data of the login node in the aforementioned embodiment (snapshot data corresponding to ① the user agreement status checked before login; ② the password input status before login; ③ the account password input status before login, etc.). During the process backtracking, if the execution of the first target test operation fails, the second valid snapshot data corresponding to m valid execution events before the abnormal event can be extracted from the state snapshot library according to the backtracking node and in reverse time order, and then the abnormal backtracking is performed again based on the second valid snapshot data and the abnormal snapshot data to determine the second target test operation corresponding to the abnormal event, and execute the second target test operation, thereby increasing the possibility of successful process backtracking by setting a retry scenario. Wherein, n is less than m; the first target test operation is the same as or different from the second target test operation.

[0090] Furthermore, if the number of failures of the backtracking target test operation reaches a preset threshold, a backtracking execution log and an interruption exception log are generated for the abnormal event. Therefore, if the backtracking cannot be successful, the corresponding backtracking execution log and interruption exception log are input so that the tester can repair the exception based on the corresponding log reference, thereby ensuring that the test process can be executed completely.

[0091] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention does not limit this.

[0092] In an embodiment of the present invention, during the process of automated testing of a test object, page changes of the test object can be monitored in real time. In response to page changes of the test object occurring during the automated testing process, a state snapshot library corresponding to the page changes can be constructed. Then, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data are extracted from the state snapshot library. Then, an abnormal backtracking is performed based on the abnormal snapshot data and the first valid snapshot data to determine the first target test operation corresponding to the abnormal event, and the first target test operation is executed. Therefore, during the automated testing process, snapshot data mapping is performed for each page change. When an abnormal event causing a test interruption occurs, the corresponding abnormal snapshot data and valid snapshot data can be extracted for backtracking to determine the target test operation corresponding to the abnormal event. Then, the target test operation is automatically executed, thereby reducing dependence on manual intervention and achieving adaptive interruption recovery. Backtracking can be achieved through limited snapshot data, reducing the amount of data processing. In addition, by extracting the corresponding snapshot data, the accuracy of backtracking is improved, which is conducive to increasing the possibility of successful interruption recovery.

[0093] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the following examples are provided for illustrative purposes:

[0094] As an example, see Figure 2 , which shows a schematic diagram of the process of automated testing provided in an embodiment of the present invention. The corresponding process may include:

[0095] 1. Real-time monitoring of page changes;

[0096] 2. Generate and save state snapshot data for page changes. The state snapshot data may include at least: page screenshots, DOM page structure data, and basic page data (URL / Cookies / Local Storage, etc.);

[0097] 3. Generate corresponding semantic labels based on state snapshot data;

[0098] 4. Test execution continues;

[0099] 5. During the test, check whether an interrupt exception occurs. If not, execute step 6. If so, execute step 7.

[0100] 6. Test execution continues;

[0101] 7. Analyze the abnormal state snapshot and obtain multiple valid snapshots in reverse chronological order. Then derive and analyze the optimal backtracking solution and execute 8.

[0102] 8. Execute backtracking to restore the snapshot. If the execution succeeds, proceed to 9. If the execution fails, return to 7 and repeat. If the execution fails multiple times, proceed to 10.

[0103] 9. Test execution continues;

[0104] 10. Output error log.

[0105] Specifically, the intelligent interruption recovery mechanism for the test process can first record all changes during the test process in real time, namely, data snapshot management (similar to historical record storage). This is achieved by taking snapshots of all page changes as the base node. Furthermore, since any changes to the page will also change the page's DOM element structure, changes in page operations can be recorded based on DOM element changes, achieving snapshot data content at the operation layer in the snapshot. This data is then stored based on the page's basic data (URL, Cookies, LocalStorage), and other page storage data. Furthermore, to enrich the snapshot data and improve the success rate of subsequent post-interruption recovery, the DOM tree snapshots and saved page screenshots can be used to identify abnormal elements in the screenshots (such as pop-ups and persistent loading icons). This can then generate semantic page function labels (e.g., "Loading icon abnormality during cooling startup on air conditioning control page") for input into the analysis model for retrospective deduction. This completes the historical storage of all changes during the test process.

[0106] During continuous testing, you can monitor error events thrown by the code during testing and capture the interrupted errors through the browser, generating error logs. You can also obtain the current exception snapshot data from the state snapshot library. You can also retrieve the three most recent valid snapshots without error events from the state snapshot database in reverse chronological order. The deployed analysis model inputs the exception snapshot data (including DOM node data, page screenshots, and functional semantic tags) for deduction and recommendation of the optimal backtracking node. For example, if the current exception snapshot is (login failure, loading icon error, and intercepted toast prompt indicating a network error), and the three time snapshots selected in reverse chronological order are (1. User agreement checked before login, 2. Password entered before login, 3. Account entered before login), you can deduce that the login failure was not caused by not checking the user agreement or entering an incorrect account and password. You can then directly backtrack to snapshot 1, where the password was entered and the user agreement was checked, and execute again. The wait time for the login request is automatically extended to allow backtracking and recovery.

[0107] If the backtracking execution succeeds, the problem is solved and subsequent tests can continue. If the execution still fails, return to the above process of analyzing the backtracking node and re-execute it. At the same time, adjust and relax the acquisition of valid snapshots, such as relaxing it to re-intelligently deduce the backtracking execution from the last five valid snapshots without error events. If the backtracking execution fails multiple times, it is judged that there is a serious interruption exception. Detailed logs of the backtracking execution and the interruption exception log are thrown for the tester to refer to and fix the exception.

[0108] Through the above process, during the automated testing process, snapshot data mapping is performed for each page change, so that when an abnormal event of test interruption occurs, the corresponding abnormal snapshot data and valid snapshot data can be extracted for backtracking, and the target test operation corresponding to the abnormal event can be determined. Then, the target test operation is automatically executed, which reduces the dependence on manual intervention and realizes adaptive interruption recovery. In addition, backtracking can be achieved through limited snapshot data, reducing the amount of data processing. By extracting the corresponding snapshot data, the accuracy of backtracking is improved, which is conducive to increasing the possibility of successful interruption recovery.

[0109] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0110] Reference Figure 3 , shows a structural block diagram of an interruption recovery device in a test link provided in an embodiment of the present invention, which may specifically include the following modules:

[0111] The snapshot recording module 301 is used to construct a state snapshot library corresponding to the page changes of the test object during the automated testing process;

[0112] A data extraction module 302 is configured to extract, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library;

[0113] The backtracking module 303 is configured to perform an exception backtracking based on the abnormal snapshot data and the first valid snapshot data, determine a first target test operation corresponding to the abnormal event, and execute the first target test operation.

[0114] In some feasible implementations, the data extraction module 302 is specifically configured to:

[0115] In response to detecting an abnormal event that triggers a test interruption, acquiring abnormal snapshot data corresponding to the abnormal event from the state snapshot library;

[0116] Perform process backtracking based on the abnormal snapshot data to determine the backtracking node for the abnormal event;

[0117] According to the backtracking nodes and in reverse time order, first valid snapshot data corresponding to the abnormal event is extracted from the state snapshot library.

[0118] In some feasible implementations, the abnormal snapshot data includes a first page screenshot, first DOM structure data corresponding to the first page screenshot, and a first semantic tag, and the data extraction module 302 is specifically configured to:

[0119] The first page screenshot, the first DOM structure data, and the first semantic tag are used to perform process backtracing to determine a backtracing node for the abnormal event.

[0120] In some feasible implementations, the first valid snapshot data includes a second page screenshot, second DOM structure data corresponding to the second page screenshot, and a second semantic tag, and the data extraction module is specifically configured to:

[0121] The first page screenshot, the first DOM structure data, the first semantic tag, the second page screenshot, the second DOM structure data, and the second semantic tag are used to perform exception backtracing to determine a first target test operation corresponding to the exception event.

[0122] In some feasible implementations, the snapshot recording module 301 is specifically configured to:

[0123] In response to page changes occurring in the test object during the automated testing process, obtaining a page screenshot corresponding to the page change and DOM structure data corresponding to the page screenshot;

[0124] Using the page screenshot and the DOM structure data to perform page recognition, and obtain a semantic tag corresponding to the page screenshot;

[0125] Based on the page screenshot, the DOM structure data and the semantic tags, a state snapshot library corresponding to the page changes is constructed.

[0126] In some feasible implementations, the snapshot recording module 301 is specifically configured to:

[0127] Obtaining basic page data corresponding to the page screenshot;

[0128] Based on the page screenshot, the DOM structure data, the semantic tags and the page basic data, a state snapshot library corresponding to the page change is constructed.

[0129] In some feasible implementations, the first valid snapshot data is snapshot data corresponding to n valid execution events before the abnormal event, and the apparatus further includes:

[0130] a retry module configured to extract, if the execution of the first target test operation fails, second valid snapshot data corresponding to m valid execution events before the abnormal event from the state snapshot library according to the backtracking nodes and in reverse time order;

[0131] an execution module, configured to perform an exception backtracking based on the second valid snapshot data and the abnormal snapshot data, determine a second target test operation corresponding to the abnormal event, and execute the second target test operation;

[0132] wherein, n is smaller than m;

[0133] The first target test operation is the same as or different from the second target test operation.

[0134] Some possible implementations also include:

[0135] The log output module is used to generate a backtracking execution log and an interruption exception log for the abnormal event if the number of failures of the backtracking execution target test operation reaches a preset threshold.

[0136] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0137] In addition, an embodiment of the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the computer program is executed by the processor, the various processes of the interruption recovery method embodiment in the above-mentioned test link are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0138] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the aforementioned embodiment of the test link interrupt recovery method, achieving the same technical effects. To avoid repetition, the details are omitted here. The computer-readable storage medium may be, for example, a read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.

[0139] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0140] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, apparatuses, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, EEPROM, Flash, and eMMC, etc.) containing computer-usable program code.

[0141] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0142] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0143] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0144] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0145] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0146] The above is a detailed introduction to a method for recovering an interruption in a test link and a device for recovering an interruption in a test link provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for recovering from an interruption in a test link, characterized in that: include: In response to page changes of the test object during the automated testing process, a state snapshot library corresponding to the page changes is constructed; In response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library; Performing an exception backtracking based on the abnormal snapshot data and the first valid snapshot data, determining a first target test operation corresponding to the abnormal event, and executing the first target test operation, wherein the abnormal snapshot data corresponds to the abnormal test operation that failed to be executed, and the first target test operation is a test operation that precedes the abnormal test operation in the automated test process; If the number of failures of backtracking the execution of the first target test operation reaches a preset threshold, generating a backtracking execution log and an interruption exception log for the abnormal event; The first valid snapshot data is snapshot data corresponding to n consecutive valid execution events before the abnormal event, and the method further includes: If the execution of the first target test operation fails, the number of extracted valid execution events is adjusted to m, and the backtracking node corresponding to the abnormal event is obtained. According to the backtracking node and in reverse time order, the second valid snapshot data corresponding to the m consecutive valid execution events before the abnormal event are extracted from the state snapshot library; Performing anomaly backtracking based on the second valid snapshot data and the abnormal snapshot data, determining a second target test operation corresponding to the abnormal event, and executing the second target test operation; wherein, n is smaller than m; The first target test operation is the same as or different from the second target test operation.

2. The method according to claim 1, characterized in that In response to detecting an abnormal event that triggers a test interruption, extracting abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library, including: In response to detecting an abnormal event that triggers a test interruption, acquiring abnormal snapshot data corresponding to the abnormal event from the state snapshot library; Perform process backtracking based on the abnormal snapshot data to determine the backtracking node for the abnormal event; According to the backtracking nodes and in reverse time order, first valid snapshot data corresponding to the abnormal event is extracted from the state snapshot library.

3. The method according to claim 2, characterized in that The abnormal snapshot data includes a first page screenshot, first DOM structure data corresponding to the first page screenshot, and a first semantic tag. The process backtracking according to the abnormal snapshot data to determine the backtracking node for the abnormal event includes: The first page screenshot, the first DOM structure data, and the first semantic tag are used to perform process backtracing to determine a backtracing node for the abnormal event.

4. The method according to claim 3, characterized in that The first valid snapshot data includes a second page screenshot, second DOM structure data corresponding to the second page screenshot, and a second semantic tag. The abnormality backtracking based on the abnormal snapshot data and the first valid snapshot data to determine a first target test operation corresponding to the abnormal event includes: The first page screenshot, the first DOM structure data, the first semantic tag, the second page screenshot, the second DOM structure data, and the second semantic tag are used to perform exception backtracing to determine a first target test operation corresponding to the exception event.

5. The method according to any one of claims 1 to 4, characterized in that In response to page changes of the test object during the automated testing process, building a state snapshot library corresponding to the page changes includes: In response to page changes occurring in the test object during the automated testing process, obtaining a page screenshot corresponding to the page change and DOM structure data corresponding to the page screenshot; Using the page screenshot and the DOM structure data to perform page recognition, and obtain a semantic tag corresponding to the page screenshot; Based on the page screenshot, the DOM structure data and the semantic tags, a state snapshot library corresponding to the page changes is constructed.

6. The method according to claim 5, characterized in that The step of constructing a state snapshot library corresponding to the page change based on the page screenshot, the DOM structure data, and the semantic tag includes: Obtaining basic page data corresponding to the page screenshot; Based on the page screenshot, the DOM structure data, the semantic tags and the page basic data, a state snapshot library corresponding to the page change is constructed.

7. A device for recovering from an interruption in a test link, characterized in that: include: A snapshot recording module is used to construct a state snapshot library corresponding to page changes of the test object during the automated testing process; a data extraction module, configured to extract, in response to detecting an abnormal event that triggers a test interruption, abnormal snapshot data corresponding to the abnormal event and first valid snapshot data corresponding to the abnormal snapshot data from the state snapshot library; a backtracking module, configured to perform an exception backtracking based on the abnormal snapshot data and the first valid snapshot data, determine a first target test operation corresponding to the abnormal event, and execute the first target test operation, wherein the abnormal snapshot data corresponds to the abnormal test operation that failed to be executed, and the first target test operation is a test operation located before the abnormal test operation in the automated test process; a log output module, configured to generate a backtracking execution log and an interruption exception log for the abnormal event if the number of failures in backtracking the execution of the first target test operation reaches a preset threshold; The first valid snapshot data is snapshot data corresponding to n consecutive valid execution events before the abnormal event, and the device further includes: a retry module configured to adjust the number of valid execution events to be extracted to m if the execution of the first target test operation fails, obtain a backtracking node corresponding to the abnormal event, and extract, from the state snapshot library, second valid snapshot data corresponding to m consecutive valid execution events preceding the abnormal event, according to the backtracking node and in reverse time order; an execution module, configured to perform an exception backtracking based on the second valid snapshot data and the abnormal snapshot data, determine a second target test operation corresponding to the abnormal event, and execute the second target test operation; wherein, n is smaller than m; The first target test operation is the same as or different from the second target test operation.

8. An electronic device, characterized in that: comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 6 when executing a program stored in the memory.

9. A computer-readable storage medium, characterized in that Instructions are stored thereon, and when the instructions are executed by one or more processors, the processors are caused to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Automatic test abnormal protection method, device and system

    CN107577591A

  • Recovery method and device of workflow task status, storage medium and computing equipment

    CN107678889A

  • Visual user operation backtracking method and device, computer equipment and storage medium

    CN113760825A