Automated test self-healing method and system
Patent Information
- Application Number
- CN202611162929.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-11-03
AI Technical Summary
Existing automated testing solutions are easily affected by visual noise driven by independent threads when identifying application deadlock states, leading to misjudgments and missed reports, and failing to capture deadlock exceptions in a timely manner.
By periodically acquiring the control tree of the target application, filtering dynamic attributes, calculating the static structure summary of the control tree, and combining it with the expected waiting time, it is determined whether the control tree has entered a structure frozen state, thereby identifying logical deadlocks, and terminating the application and restarting the test script after the determination.
It accurately identifies the main thread's apparent dead state, improves the accuracy of anomaly detection, avoids visual noise interference, and enables continuous execution and efficient recovery of automated tests.
Smart Images

Figure CN123030497A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automated testing technology, and in particular to automated testing self-healing methods and systems. Background Technology
[0002] Automated testing is a key technology for ensuring software product quality and is widely used in the quality verification process of various front-end applications and systems. As the interaction logic of modern front-end applications becomes increasingly complex, automated testing not only needs to verify the presentation of static UI elements but also needs to accurately perceive the actual state of the application during runtime and efficiently identify and handle abnormal pauses during the testing process.
[0003] Existing automated test anomaly monitoring solutions often use a visual pixel comparison method to determine the running status of application pages. This method periodically captures screen images of the application interface, calculates the pixel differences between consecutive frames, and determines that the page is still active if the pixel change rate exceeds a preset threshold; otherwise, it is determined that the page is frozen.
[0004] However, this solution suffers from a serious flaw in state misjudgment. When the application experiences a network deadlock or a front-end main thread logic error that causes the application to essentially freeze, if components such as loading animations or carousels on the page continue to loop using independent rendering threads, it will cause continuous changes in local pixels on the page. This visual noise driven by independent threads will interfere with the pixel comparison algorithm's judgment logic, causing the system to mistakenly judge the page as "still active," thus preventing the testing framework from capturing deadlock anomalies in a timely manner and resulting in serious missed detections. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide an automated testing self-healing method that can identify the apparent dead state of an application in automated testing and automatically restore the test environment.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: An automated testing self-healing method is applied to a test scheduling system. The method includes: obtaining the control tree of the current interface of the target application at predetermined time intervals; comparing whether the preset control trees obtained at different time points are the same; if they are the same, determining that the control tree has entered a structure freeze state; obtaining the expected waiting time of the test script executed by the target application; if the duration of the structure freeze state is greater than or equal to the expected waiting time, determining that the target application has entered a logical deadlock; terminating the target application that has entered a logical deadlock, restarting the test script, and resetting the target application.
[0007] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows: An automated testing self-healing system includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the following steps: At predetermined time intervals, obtain the control tree of the current interface of the target application; compare the preset control trees obtained at different time points to see if they are the same. If they are the same, determine that the control tree has entered a structure freeze state; obtain the expected waiting time of the test script executed by the target application; if the duration of the structure freeze state is greater than or equal to the expected waiting time, determine that the target application has entered a logical deadlock; terminate the target application that has entered a logical deadlock, restart the test script, and reset the target application.
[0008] The beneficial effects of this invention are as follows: This invention acquires the control tree of the current interface of the target application at predetermined time intervals, and compares the preset control trees acquired at different time points to determine whether the control tree has entered a structure-frozen state. The control tree represents the logical structure of the interface, and visual noise driven by an independent rendering thread will not cause changes in the control tree structure. By comparing the control tree, the interference of visual noise on the state determination is eliminated, which can accurately identify the main thread's dead state and improve the accuracy of anomaly identification. The expected waiting time of the test script is obtained, and the duration of the structure-frozen state is compared with the expected waiting time to determine the logical deadlock. This makes the deadlock determination adaptable to the waiting requirements of different test scenarios, avoids the misjudgment of normal waiting, and improves the accuracy of state determination. Compared with the existing visual pixel comparison-based scheme, when the application experiences a network deadlock or a front-end main thread logic error that causes a deadlock, the visual noise generated by the continuous playback of components such as loading animations or carousels using independent rendering threads can interfere with the pixel comparison algorithm, leading to missed detections. This invention terminates the target application, restarts the test script, and resets the target application upon determining that a logical deadlock has occurred. This achieves automatic recovery of the test environment, eliminates the need for manual intervention in handling deadlocks, ensures continuous execution of automated tests, and improves test efficiency. Attached Figure Description
[0009] Figure 1 A flowchart illustrating the steps of an automated self-healing testing method provided in this embodiment of the invention; Figure 2 This is a core flowchart of an automated testing self-healing method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an automated testing self-healing system provided in an embodiment of the present invention; Detailed Implementation Definitions:
[0010] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.
[0011] In existing technologies, automated testing is a key technology for ensuring software product quality and is widely used in the quality verification stages of various front-end applications and systems. As the interaction logic of modern front-end applications becomes increasingly complex, automated testing not only needs to verify the presentation of static UI elements but also needs to accurately perceive the true state of the application during runtime, efficiently identifying and handling abnormal pauses during the testing process. Therefore, it is necessary to solve the problem of "visual deception-type" false deadlocks caused by visual noise interference driven by independent threads, overcome the shortcomings of existing pixel comparison schemes that cause false negatives due to local pixel changes, and address the inability of UI control tree schemes to perceive the global state of the application. This will enable accurate identification of the true operating state of the system when the application's main thread deadlocks or encounters logical errors.
[0012] To at least address the aforementioned issues, this invention periodically collects and compares the control tree structure of the application interface to detect its logical freeze state. When this state persists beyond the expected waiting time of the test script, a logical deadlock is determined, thereby triggering termination and restart. In this way, pixel misjudgment caused by independent rendering threads can be eliminated, and the false freeze can be accurately identified and the test environment can be automatically restored.
[0013] The following describes in detail an automated test self-healing method of the present invention, applied to a test scheduling system, as shown in the appendix. Figure 1 This includes steps 101 to 105: Step 101: Obtain the control tree of the current interface of the target application at predetermined time intervals. Specifically, the control tree is the underlying UI control tree of the current interface of the target application, including the HTML DOM (Document Object Model) tree or the XML (eXtensible Markup Language) node tree. Target applications include web applications, native mobile applications, and desktop applications. For example, an automated testing framework runs on a test scheduling system. The XML control tree of the current mobile interface is retrieved using the command "adb uiautomator dump".
[0014] Step 102: Compare the preset control trees obtained at different time points to see if they are the same. If they are the same, the control tree is determined to have entered a structure-frozen state. Specifically, the structure-frozen state includes a state in which the UI logic structure remains completely consistent within a continuous first time threshold. That is, regardless of how the loading animation or carousel rotates on the page, as long as the page DOM structure does not actually jump or add data nodes, the filtered structural features remain unchanged. For example, if the daisy animation rotates continuously, but because the dynamic attribute is removed, the MD5 hash value remains consistent for 15 consecutive seconds, the App is determined to have entered a structure-frozen state.
[0015] Step 103: Obtain the expected wait time for the test script executed by the target application; specifically, the test script can be a test case script executed by an automated testing framework. The expected wait time includes the timeout parameter in the test script for waiting for an element to appear or for a condition to be met. For example, the Timeout parameter in the wait_for_element directive.
[0016] Step 104: If the duration of the structural freeze state is greater than or equal to the expected waiting time, the target application is determined to have entered a logical deadlock. Specifically, a logical deadlock includes a situation where the target application experiences a network deadlock or a front-end logic error, but the loading animation or carousel on the page continues to loop using an independent thread, and the duration of the structural freeze state is greater than or equal to the expected waiting time. For example, if the UI freezes for 15 seconds, which is longer than the script's expected 10 seconds, and the interface structure does not actually change, it is diagnosed as a logical deadlock with visually deceptive animations.
[0017] Step 105: Terminate the target application that entered the logical deadlock, restart the test script and reset the target application; For example, terminate the target application that has entered a logical deadlock, replay the test script from the initial state, or mark the test case corresponding to the test script as failed and continue to execute the next test case.
[0018] As described above, this invention acquires the control tree of the target application's current interface at predetermined time intervals and compares the preset control trees acquired at different time points to determine whether the control tree has entered a structure-frozen state. The control tree represents the logical structure of the interface, and visual noise driven by an independent rendering thread will not cause changes in the control tree structure. By comparing the control tree, the interference of visual noise on state determination is eliminated, enabling accurate identification of the main thread's apparent dead state and improving the accuracy of anomaly identification. The expected waiting time of the test script is obtained, and the duration of the structure-frozen state is compared with the expected waiting time to determine logical deadlock. This makes deadlock determination adaptable to the waiting requirements of different test scenarios, avoiding misjudgment of normal waiting and improving the accuracy of state determination. Compared with existing solutions based on visual pixel comparison, when the application experiences network deadlock or a front-end main thread logic error leading to apparent deadlock, visual noise generated by the continuous playback of components such as loading animations or carousels using independent rendering threads can interfere with the pixel comparison algorithm, resulting in missed detections. This invention terminates the target application, restarts the test script, and resets the target application upon determining that a logical deadlock has occurred. This achieves automatic recovery of the test environment, eliminates the need for manual intervention in handling deadlocks, ensures continuous execution of automated tests, and improves test efficiency.
[0019] In one embodiment of this application, after obtaining the control tree of the current interface of the target application at predetermined time intervals in step 101, steps 201 to 202 are included: Step 201: Filter the dynamic properties of the control tree to obtain the filtered target control tree; Specifically, dynamic properties are those in the UI control tree that cause visual clutter, including CSS (Cascading Style Sheets) animation state properties, carousel current index value properties, timestamp dynamic update properties, and rotation properties; the target control tree is the UI control tree after removing dynamic properties, retaining only the hierarchical structure, node types, and static text / ID (Identifier) identifiers. For example, parsing to <progressbar id="loading_spinner" rotation="120">Nodes with the dynamic attribute rotation="120" are automatically removed, leaving only those with this attribute. <progressbar id="loading_spinner">Structural features.
[0020] Step 202: Calculate the static structure summary of the target control tree; Specifically, the static structure digest includes the UI structure hash value of the current frame generated by performing a digest algorithm on the filtered core UI control tree content. For example, it is the hash value generated by performing the MD5 (Message-Digest Algorithm 5) algorithm on the filtered pure structure XML.
[0021] In step 102, the comparison is made to see if the preset control trees obtained at different time points are the same, including: Step 1021: Compare whether the preset static structure summaries obtained at different time points are the same; As described above, this invention achieves accurate judgment of the frozen state of the UI structure by filtering the dynamic attributes of the control tree and calculating the static structure summary. Combined with script intent for deadlock diagnosis, it solves the problem of missed detection caused by the false judgment that the page is "still active" due to continuous changes in loading animations or carousels in the prior art, and improves the recognition accuracy of "visual deception" false deadlocks in automated testing.
[0022] In one embodiment of this application, filtering dynamic attributes of the control tree to obtain the filtered target control tree includes steps 301 to 302: Step 301: Traverse each node of the control tree; for example, traverse the ProgressBar and Button nodes in the XML control tree.
[0023] Step 302: Based on a preset dynamic attribute rule library, identify and remove dynamic attributes from each node to obtain the target control tree. Specifically, the dynamic attribute rule library includes a preset database containing dynamic attribute matching rules, and the matching rules include regular expression matching of animation, carousel-index, timestamp, and rotation. For example, the rotation attribute is matched and removed based on regular expression matching.
[0024] As described above, this invention determines structural freeze by filtering the continuous hash value of the UI control tree after dynamic attributes, and integrates script intent for deadlock diagnosis. It can accurately identify "visual deception" false dead states caused by continuous playback of loading animations or carousels, avoiding the misjudgment that the page is still active due to continuous pixel changes in traditional solutions. This effectively eliminates false alarms. After determining a deadlock, it links the process management to perform a low-level reset, restores the test pipeline operation, and improves the self-healing accuracy and cluster execution efficiency of automated testing.
[0025] In one embodiment of this application, step 102 compares whether the preset number of control trees obtained at different time points are the same. If they are the same, it is determined that the control tree enters a structure-frozen state, including steps 401 to 402: Step 401: Compare whether the preset static structure digests obtained at different time points remain the same within a preset first time threshold; for example, compare whether the MD5 hash values obtained within 15 consecutive seconds are all 8A2E9B3F.
[0026] Step 402: If the same results are obtained within the first time threshold, the control tree is determined to enter the structure frozen state. The first time threshold is greater than or equal to two predetermined time intervals. For example, if the predetermined time interval is 1 second and the first time threshold is 15 seconds, and 15 consecutive static structure summaries are the same, the control tree is determined to enter the structure frozen state.
[0027] As described above, the present invention determines that the control tree has entered a structure-frozen state by comparing a preset number of static structure summaries that remain the same within a first time threshold. Thus, when there are visually deceptive animations on the page (such as continuously rotating loading animations), it can accurately identify that the UI logic structure has not undergone substantial changes, avoiding the problem of the prior art misjudging that the page is still active due to continuous pixel changes, and improving the accuracy of deadlock determination in automated testing.
[0028] In one embodiment of this application, step 103, obtaining the expected waiting time of the test script executed by the target application, includes steps 501 to 502: Step 501: Intercept the test framework application interface calls made by the test script executed by the target application; specifically, the test framework application interface is a key API (Application Programming Interface) call provided by the test framework for performing test operations. For example, intercept wait_for_element(timeout, locator) or expect_condition(timeout, condition).
[0029] Step 502: Parse the parameters of the test framework application interface to extract the parameter values representing the expected waiting time; for example, parse wait_for_element('id=pay_success', timeout=10s) to extract the expected waiting time parameter value as 10 seconds.
[0030] As described above, this invention achieves precise perception of script intent by intercepting the test framework API and parsing parameters to extract the expected waiting time. This method avoids the shortcomings of existing technologies that cannot identify script timeout semantics due to reliance on visual pixel comparison or static UI tree matching. Therefore, it provides an accurate timing benchmark for subsequent deadlock diagnosis by integrating the frozen state of the UI control tree, improving the accuracy of logical deadlock determination in automated testing.
[0031] In one embodiment of this application, steps 601 to 602 are also included: Step 601: Record the acquisition time of the first consecutive identical control tree among the multiple consecutive identical control trees as the start time of the structure freeze state; for example, if the control tree acquired in the 1st second is consecutively identical with the subsequent control trees, then the 1st second is recorded as the start time.
[0032] Step 602: The duration from the start time to the current time is taken as the duration of the structure freeze state; for example, if the start time is the 1st second and the current time is the 16th second, then the duration of the structure freeze state is 15 seconds.
[0033] As described above, this invention achieves precise quantification of the duration of the UI structure freeze state by recording the acquisition time of the first control tree in a series of identical control trees as the start time and calculating the duration from the start time to the current time as the duration of the structure freeze state. This provides an accurate time basis for subsequent logic deadlock determination based on script intent and avoids misjudgment caused by visually deceptive animations.
[0034] In one embodiment of this application, in step 104, if the duration of the structural freeze state is greater than or equal to the expected waiting time, the target application is determined to have entered a logical deadlock, including steps 701 to 702: Step 701: If the duration is greater than or equal to the expected waiting time, scan the control tree in the frozen state to check if there are any feature nodes that hinder the test progress. Specifically, feature nodes that hinder the test progress are nodes in the frozen UI control tree that indicate the loading animation is still being displayed or hidden error text nodes. For example, nodes with class="loading", or The node, or the hidden "Network Error" text node.
[0035] Step 702: If there are feature nodes that hinder the progress of the test, the target application is determined to have entered a logical deadlock; for example, if there are... If a node remains frozen for an extended period, it is considered to have entered a logical deadlock.
[0036] As described above, this invention can accurately identify logical deadlocks caused by continuous animation or loading by scanning the control tree in the frozen state and checking for feature nodes that hinder test progress. This avoids the problem of false alarms caused by visual pixel changes in traditional solutions, which may lead to the misjudgment that the page is still active. It improves the accuracy of deadlock determination and the reliability of environment self-healing in automated testing.
[0037] In one embodiment of this application, step 105, terminating the target application that has entered a logical deadlock, includes step 801: Step 801 involves invoking the forced termination command of the operating system where the target application resides to destroy the target application's process and release its resources. Specifically, the forced termination command is a low-level forced cleanup instruction issued by the operating system's process control module, bypassing the UI layer to directly destroy the process PID (Process Identifier). For example, sending the command "adb shell kill -9" to the Android underlying system... <pid>Force terminate the process.
[0038] As described above, this invention can directly bypass the UI layer response logic by calling the operating system's forced termination command to destroy processes and release resources. When an application cannot be closed normally due to visual deception-type freezes, it can achieve low-level process cleanup and resource reclamation, thereby effectively avoiding long-term blocking of test tasks caused by single-machine freezes and ensuring the overall execution efficiency and stability of the automated test cluster.
[0039] In one embodiment of this application, step 105, restarting the test script and resetting the target application, includes step 901: Step 901: Restart the target application and re-execute or replay the test script from the breakpoint; for example, execute the command "adbshell am start" to cold start the e-commerce app and replay the shopping cart checkout test case from the beginning.
[0040] As described above, this invention continuously compares the hash values of the UI control tree after filtering dynamic attributes, and performs fusion diagnosis in conjunction with the expected waiting time of the script. This enables it to accurately identify "visual deception" logic deadlocks with continuous animations, avoiding the false negative problem of traditional solutions that misjudge the page as still active due to continuous changes in pixels or attributes. Furthermore, it links with the underlying process cleanup to achieve rapid self-healing of the test environment, thereby ensuring the continuous operating efficiency of the automated test cluster.
[0041] The automated testing self-healing method and system described above are applicable to the application scenario of self-healing from "infinite loading payment status" in mobile e-commerce apps. The following is a detailed description of the implementation method.
[0042] The system consists of a cluster of 100 Android test devices, which are connected to a test scheduling server (test scheduling system) via a USB hub. The test scheduling server runs the Appium automated testing framework, and the test object is an e-commerce app.
[0043] In this embodiment of the invention, the test script performs automated regression testing of the process of "shopping cart checkout - clicking to pay - waiting for payment result".
[0044] When the test scheduling server sends the "click to pay" instruction to the e-commerce app, due to a temporary network fluctuation in the backend payment gateway of the e-commerce app, the e-commerce app times out receiving data and fails to properly handle the exception, resulting in the continuous display of the "processing" loading animation in the center of the interface.
[0045] Please refer to Figure 2 The test scheduling server starts a self-healing process that includes the following steps.
[0046] Step A: UI control tree extraction and dynamic attribute filtering. During automated test execution, the system calls the operating system or browser driver interface at a preset frequency (e.g., once per second) to obtain the underlying UI control tree (such as the HTML DOM tree or XML node tree) of the current interface. This corresponds to step 101 above.
[0047] Specifically, every second, the test scheduling server calls the uiautomator dump interface via adb command to obtain the underlying control tree of the current interface from the e-commerce app under test. The obtained underlying control tree is a UI control tree in XML format.
[0048] The test scheduling server traverses each node in the UI control tree and actively removes dynamic attribute nodes that may cause visual interference based on a preset dynamic attribute rule library (or regular expression).
[0049] This dynamic property rule library contains regular expressions for matching and eliminating properties, including but not limited to: CSS animation state properties, carousel current index value properties, and timestamp dynamic update properties; specifically, regular expressions match animation, carousel-index, timestamp, etc.; and match and eliminate the "rotation" property, "carousel-index" property, and "timestamp" property.
[0050] After filtering, only the following core structural features are retained: hierarchical structure, node type, and static text / ID identifier.
[0051] For example, when the test scheduling server resolves the node "\ <progressbar id="\"loading_spinner\"rotation=\"120\"\">The dynamic attribute "rotation="120" is automatically removed, leaving only "\ <progressbar id="\"loading_spinner\"\">Meanwhile, the test scheduling server retains the node hierarchy, node type, and static text or ID identifiers. This UI control tree also contains static nodes, such as "\ <button text="\"支付\"\">".
[0052] Regardless of how the loading animation on the page rotates, the underlying UI control tree structure (except for dynamic properties) does not change substantially. After filtering out dynamic properties, the hash value of the tree will not change even if the animation continues to play.
[0053] Step B: Hash Value and Freeze Determination. The test scheduling server executes a digest algorithm (such as MD5 / SHA-1) on the filtered pure structure XML / core UI control tree content to generate the UI structure hash value of the current frame. This corresponds to step 102 above.
[0054] The test scheduling server continuously compares hash value sequences within consecutive time windows.
[0055] Although the daisy animation on the e-commerce app interface continues to rotate, and the value of the "rotation" property in the original UI control tree changes every second, the aforementioned property has been removed, so the generated MD5 hash value remains unchanged.
[0056] If the hash value remains completely consistent within the first consecutive time threshold, the current UI logic structure is determined to enter the "structure frozen state".
[0057] The test scheduling server detected that the hash value remained completely consistent for 15 consecutive seconds, which determined that the App had entered a "structure freeze state".
[0058] It should be noted that if the animation is a GIF image or video, all the attributes (such as src, uri, width and height, scaling type, etc.) of the corresponding UI control tree node (such as ImageView, VideoView) will not change at all during playback. Even without any dynamic attribute filtering, the hash value of the entire tree will remain unchanged. The test scheduling server will also directly observe that the hash value remains unchanged, thus determining it as a "structure frozen state".
[0059] Step C: Script Intent Extraction and Deadlock Diagnosis. Upon determining that the system has entered a "structure frozen state," the test scheduling server extracts the contextual intent of the current automated test script (e.g., "Expect to wait 3 seconds to obtain list data"). This corresponds to step 103 above.
[0060] Specifically, the implementation involves embedding hooks or proxy listeners into the test execution engine to intercept key API calls from testing frameworks (such as Selenium, Appium, and Puppeteer) (e.g., wait_for_element(timeout, locator) and expect_condition(timeout, condition)). This listener extracts the script's contextual intent, parses the currently executing test framework API call instructions (such as instructions to wait for an element to appear), analyzes the call parameters, and directly obtains the expected wait time parameter and the target element characteristics (locator expression). Simultaneously, it records the current script line number and the corresponding test case step, forming a complete contextual intent structure.
[0061] For example, the listener intercepts the API call command "wait_for_element('id=pay_success',timeout=10s)". The listener parses this command and obtains the expected waiting time parameter as 10 seconds, and the target element characteristic as id="pay_success". The test scheduling server extracts the script and expects a payment success message to appear within 10 seconds.
[0062] The test scheduling server logically compares the states of specific nodes in the frozen UI control tree with the script context intent. Specific node states include nodes with the class="loading" attribute or those containing hidden "NetworkError" text. Simultaneously, the test scheduling server scans the frozen UI control tree to check for any feature nodes that hinder progress.
[0063] The specific execution process of the above logical comparison is as follows: extract the script intent to obtain the expected waiting time and target element, confirm the current frozen state, and check specific nodes in the frozen tree. For example, the test scheduling server finds that there is a node " <progressbar id="loading_spinner">The target element "pay_success" was not found, nor was any hidden error text (such as "Network Error") found. Furthermore, the test scheduling server compared the duration of the structure freeze state with the extracted expected waiting time; for example, if the freeze duration of 15 seconds was greater than the script's expected 10 seconds...
[0064] A deadlock is determined when the following conditions are met simultaneously: the duration of the structure freeze is greater than or equal to the script's expected waiting time, and there are feature nodes (such as loading animation nodes or hidden error text nodes) in the frozen UI control tree that hinder progress. This corresponds to step 104 above.
[0065] Therefore, if the expected waiting time of the script is exceeded and the UI structure is still frozen (i.e., the interface structure has not actually changed), the test scheduling server determines that the application has entered a logical deadlock with "visual deceptive animation".
[0066] Step D: Forcefully terminate the process and reset the environment. After diagnosing a logical deadlock, since the regular application level may no longer be able to respond to the shutdown command, the test scheduling server bypasses the Appium framework / UI layer and directly issues a low-level forced cleanup command (directly destroying the PID) to the Android operating system / operating system process control module. This corresponds to step 105 above.
[0067] Specifically, the test scheduling server was executed using the adb command "adb shell kill -9 \<PID\> "Forcefully terminate the e-commerce app's process, releasing the process handle and memory pool."
[0068] After confirming that the process's memory and handles have been released / cleaned up, the system reinitializes the test environment, and the test scheduling server executes the adb command "adb shell am start" to cold start the e-commerce app.
[0069] Subsequently, the test scheduling server instructs the scheduling system to record the exception log, trigger the test task's retry mechanism (such as replaying the script from the initial state, or marking the test case as failed and continuing to execute the next test case), and replay the test from the initial state of the "shopping cart checkout" test case to restore the test process.
[0070] The method provided in this application embodiment takes 18 seconds for the entire self-healing process, avoiding up to 30 minutes of invalid suspension / subsequent task queuing blockage on a single test machine, and ensuring the overall throughput of the test cluster.
[0071] Please refer to Figure 3 The present invention also provides an automated testing self-healing system 210, including a memory 211, a processor 212, and a computer program stored in the memory 211 and executable on the processor 212. When the processor 212 executes the computer program, it implements the various steps of an automated testing self-healing method as described above.
[0072] The beneficial effects of the system of the present invention are the same as those of the method described above, and will not be repeated here.
[0073] In summary, this invention provides a self-healing method for automated testing environments based on UI control tree state awareness and script intent fusion. This method periodically acquires the control tree of the target application's current interface and filters out dynamic attributes to obtain core structural features containing only hierarchical structure, node types, and static identifiers. By calculating the static structural summary of the filtered control tree over consecutive time points and determining whether it remains constant within a preset threshold, the frozen state of the UI structure is accurately identified, effectively overcoming the interference of visual dynamic elements such as rotating animations and carousels on state determination. Furthermore, this invention combines the expected waiting time of the test script with feature node analysis in the frozen state to accurately diagnose "visually deceptive" logical deadlocks, avoiding the missed detection problems caused by continuous pixel changes in traditional solutions. Once a deadlock is diagnosed, the system automatically calls the operating system's forced termination command to destroy the process and release resources, then restarts the application and resumes test execution, achieving a closed-loop process from state awareness and intent fusion to environment self-healing. This invention significantly improves the robustness and execution efficiency of automated testing in complex and abnormal scenarios, ensuring the continuous and stable operation of the test cluster.
[0074] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.< / progressbar> < / button> < / progressbar> < / progressbar> < / pid> < / progressbar> < / progressbar>
Claims
1. An automated testing self-healing method, characterized in that, The method, applied to a test scheduling system, includes: At predetermined time intervals, obtain the control tree of the current interface of the target application; Compare whether the preset number of control trees obtained at different time points are the same. If they are the same, it is determined that the control tree has entered the structure frozen state. Obtain the expected waiting time for the test script executed by the target application; If the duration of the frozen state of the structure is greater than or equal to the expected waiting time, the target application is determined to have entered a logical deadlock. Terminate the target application that has entered the logical deadlock, restart the test script, and reset the target application.
2. The method according to claim 1, characterized in that, After obtaining the control tree of the current interface of the target application at predetermined time intervals, the process includes: Filter the dynamic attributes of the control tree to obtain the filtered target control tree; Calculate the static structure summary of the target control tree; The comparison of whether the preset number of control trees obtained at different time points are the same includes: Compare whether the preset static structure summaries obtained at different time points are the same.
3. The method according to claim 2, characterized in that, The step of filtering dynamic attributes of the control tree to obtain the filtered target control tree includes: Traverse each node of the control tree; Based on a preset dynamic attribute rule library, dynamic attributes in each node are identified and removed to obtain the target control tree.
4. The method according to claim 2, characterized in that, The comparison of whether the preset number of control trees obtained at different time points are the same, and if they are the same, determines that the control tree enters a structure-frozen state, including: Compare whether the preset static structure summaries obtained at different time points remain the same within a preset first time threshold. If the control tree remains the same within the first time threshold, it is determined that the control tree has entered a structure frozen state, where the first time threshold is greater than or equal to the length of two predetermined time intervals.
5. The method according to claim 1, characterized in that, The expected waiting time for obtaining the test script executed by the target application includes: Intercept the test framework application interface called by the test script executed by the target application; The parameters of the test framework application interface are parsed to extract parameter values that characterize the expected waiting time.
6. The method according to claim 1, characterized in that, Also includes: The acquisition time corresponding to the first control tree among multiple consecutive identical control trees is recorded as the start time of the structure's frozen state; The duration of the frozen state of the structure will be the time from the start time to the current time.
7. The method according to claim 6, characterized in that, If the duration of the frozen state is greater than or equal to the expected waiting time, the target application is determined to have entered a logical deadlock, including: If the duration is greater than or equal to the expected waiting time, then scan the control tree in the frozen state of the structure to check whether there are feature nodes in the control tree that hinder the progress of the test. If the aforementioned feature node that hinders the progress of the test exists, the target application is determined to have entered a logical deadlock.
8. The method according to claim 1, characterized in that, The termination of the target application entering the logical deadlock includes: Invoke the forced termination command of the operating system where the target application is located to destroy the process of the target application and release its resources.
9. The method according to claim 1, characterized in that, Restarting the test script and resetting the target application includes: Restart the target application and re-execute or replay the test script from the breakpoint.
10. An automated testing self-healing system, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the automated testing self-healing method as described in any one of claims 1 to 9.
