Method and apparatus for repairing test script for user interface, cluster, medium, and product
By obtaining the DOM tree differences and failure logs of the user interface, we automatically repair UI test scripts, solving the problems of high maintenance costs and low efficiency in the existing technology, and improving the stability and repair quality of the test scripts.
Patent Information
- Application Number
- PCT/CN2024/074481
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-17
- Filing Date
- 2024-01-29
- Publication Date
- 2024-11-21
AI Technical Summary
The prior art is costly and inefficient when maintaining and repairing user interface automated test scripts, and relies on manual operations, making it difficult to quickly adapt to interface changes, resulting in poor test stability.
By obtaining the difference tree between the DOM tree in the user interface when failure and the baseline DOM tree, and generating repair scripts based on the failure error log, the test script repair process is automated to reduce labor and time costs.
It realizes automated repair of UI test scripts, reduces the maintenance load of test engineers, improves repair quality and efficiency, and adapts to interface changes.
Smart Images

Figure CN2024074481_21112024_PF_FP_ABST
Abstract
Description
Method, device, cluster, medium and product for repairing test scripts for user interface
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 17, 2023, with application number 202310558124.0, and invention name “Methods, devices, clusters, media and products for repairing test scripts for user interfaces”, the entire contents of which are incorporated into this application by reference. Technical Field
[0002] Embodiments of the present disclosure generally relate to the field of computer technology, and more particularly to a method, apparatus, computing device cluster, computer-readable storage medium, and computer program product for repairing a user interface (UI). Background Art
[0003] UI automation testing technology is an automated testing method that tests an application's user interface by simulating user interactions with the application. It ensures that the application's user interface functionality and stability meet expectations. UI automation testing has become a crucial and indispensable component of application development.
[0004] UI automation testing can test the accuracy of user interfaces (e.g., element placement, size, color, fonts, etc.) and response time. Furthermore, UI automation testing can also test the interactivity and user experience (e.g., usability, reliability, efficiency, etc.). These are critical factors for user interfaces and directly impact application quality and user satisfaction.
[0005] UI automation testing helps uncover potential errors and defects in user interfaces. By using automated UI testing tools, test engineers can quickly run different tests on the UI and quickly rerun test scripts after each code change. This improves testing efficiency while ensuring accuracy and consistency.
[0006] Summary of the Invention
[0007] According to some embodiments of the present disclosure, a method, apparatus, computing device cluster, computer-readable storage medium, and computer program product for repairing a test script for a user interface are provided.
[0008] In a first aspect of the present disclosure, a method for repairing a test script for a user interface is provided. The method includes, if it is determined that the test script has failed to run, obtaining a failed document object model DOM tree of the user interface when the test script failed to run. The method also includes determining a difference DOM tree between the failed DOM tree and the corresponding baseline DOM tree. The method also includes generating a repair test script for the user interface based on the difference DOM tree and the failure error log during the test script running. The method for repairing a test script for a user interface according to the first aspect of the present disclosure can automatically repair the UI test script, reduce the manpower cost and time cost of the test engineer in maintaining the UI test script to alleviate their repair workload, and improve the repair quality.
[0009] In some embodiments, failure error information can be extracted from the failure error log, wherein the failure error information indicates the reason why the test script failed to run, and the failure DOM node in the difference DOM tree that caused the test script to fail to run is determined. In addition, the failure error information can also be associated with the failure DOM node. In this way, data cleaning can be performed on the failure error log, so that unnecessary or useless data can be cleaned out, thereby improving the efficiency of failure analysis and the quality of error data, reducing the interference of noise data, and optimizing storage space, thereby increasing the accuracy of failure analysis. Determining the failure DOM node in the difference DOM tree that caused the test script to fail to run helps to determine the location where the error occurs when the UI test script fails to run.
[0010] In some embodiments, a failure error message can be used to determine when a test script fails to execute, and a difference DOM node in a difference DOM tree can be determined to correspond to the failure error message, where the difference DOM node indicates a difference between the failure DOM tree and the corresponding baseline DOM tree. In this way, the failure error message can be used to determine whether the difference DOM node in the difference DOM tree is the failure DOM node, without traversing all nodes in the tree, thereby improving time efficiency and reducing computational costs.
[0011] In some embodiments, if it is determined that the difference DOM node in the difference DOM tree corresponds to a failure error, the difference DOM node can be determined as a failure DOM node. If it is determined that the difference DOM node in the difference DOM tree does not correspond to the failure error, it can be determined whether a DOM node within a predetermined threshold range of the difference DOM node in the difference DOM tree corresponds to the failure error. In this way, if the difference DOM node in the difference DOM tree is not a DOM node, continuing the search in a smaller range can more quickly determine the failure DOM node, thereby helping to determine the location of the failure error.
[0012] In some embodiments, if a DOM node within a predetermined threshold range of the difference DOM nodes in the difference DOM tree is determined to correspond to a failure error, the DOM node can be determined as a failed DOM node. If a DOM node within the predetermined threshold range of the difference DOM nodes in the difference DOM tree is determined to not correspond to a failure error, a repair of the test script can be indicated as failed. If this is the case, if the analysis continues, the failed DOM node may still not be found, wasting time and computing resources. Therefore, the analysis can be stopped and the repair of the UI test script can be indicated as failed.
[0013] In some embodiments, the DOM type of a failed DOM node can be determined, and based on the determined DOM type, a determination can be made as to whether a corresponding solution for the test script exists in the behavior tree. The behavior tree includes multiple solutions for repairing the test script, each of which includes multiple repair solutions for repairing the test script. In this way, the DOM type of a failed DOM node can be used to search for a solution for that DOM type in a well-structured prior knowledge base.
[0014] In some embodiments, if it is determined that there is no corresponding handling solution in the behavior tree for the DOM type of the failed DOM node, the test script repair may be indicated as failed, and a handling solution corresponding to the DOM type of the DOM node may be added to the behavior tree. In this way, if there is no handling solution for this DOM type in the previously established prior knowledge base, such a handling solution will be added to handle the same or similar situations in the future.
[0015] In some embodiments, if a solution corresponding to the DOM type of a failed DOM node is determined in the behavior tree, the failure error information associated with the failed DOM node can be used to determine whether a fix for the test script exists in the behavior tree. To further identify a fix for the UI test script, a search is performed in the prior knowledge base based on the failure error information associated with the failed DOM node. This allows for an accurate determination of whether a fix for the UI test script exists in the prior knowledge base.
[0016] In some embodiments, if it is determined that no repair solution exists for a test script in the behavior tree, the test script repair may be indicated as failed, and a repair solution corresponding to the failed error message may be added to the behavior tree. In some embodiments, if it is determined that a repair solution exists for the test script in the behavior tree, the test script is repaired based on the repair solution to obtain a repaired test script. This allows the failure error to be accurately located and the corresponding repair solution to be better matched, thereby improving the quality of the repair.
[0017] In some embodiments, if the test script repair fails, the execution function associated with the test script repair can be checked. If the execution function is determined to be normal, the test script repair can be determined to have failed. If the execution function is determined to be abnormal, the test script repair can be re-executed using another execution machine. In this way, it can be determined whether the failure to repair the test script is caused by a problem with the execution hardware.
[0018] In some embodiments, if the test script is successfully repaired, the successful DOM tree when the test script is successfully executed can be obtained and the successful DOM tree can be updated to the database of baseline DOM trees. In addition, the success of the test script repair can be indicated. In this way, the successful DOM tree of the UI page when the repaired UI test script is successfully executed will be saved as the new baseline DOM tree for subsequent comparison.
[0019] In some embodiments, if the failed DOM tree is determined to be identical to the corresponding baseline DOM tree, a repair test script for the user interface is generated based on the failure error log. Thus, if no differences are found after comparing the failed DOM tree with the corresponding baseline DOM tree, a repair solution for the UI test script can be sought based on the failure error log.
[0020] According to a second aspect of the present disclosure, a device for repairing a test script for a user interface is provided. The device includes an acquisition module configured to, if it is determined that the test script has failed to run, obtain a failed Document Object Model (DOM) tree of the user interface at the time the test script failed to run. The device also includes a comparison module configured to determine a difference DOM tree between the failed DOM tree and a corresponding baseline DOM tree. The device also includes a prediction module configured to generate a repair test script for the user interface based on the difference DOM tree and a failure error log during the test script execution.
[0021] According to a third aspect of the present disclosure, a computing device is provided, comprising: a processor and a memory, wherein the memory stores instructions, which, when executed by the processor, enable the computing device to perform the method according to the first aspect of the present disclosure.
[0022] According to a fourth aspect of the present disclosure, a computing device cluster is provided. The computing device cluster includes at least one computing device, each computing device including a processor and a memory. The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the method described in the first aspect of the present disclosure. In some embodiments, the computing device cluster includes one computing device. In other embodiments, the computing device cluster includes multiple computing devices. In some embodiments, the computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0023] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions that, when executed by a computing device, cause the computing device to perform the method according to the first aspect of the present disclosure. In some embodiments, the computer-readable storage medium may be non-transient. The computer-readable storage medium includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., flash memory, hard disk (HDD), solid state drive (SSD), etc.).
[0024] According to a sixth aspect of the present disclosure, a computer program product is provided. The computer program product includes instructions that, when executed by a computing device, cause the computing device to perform the method according to the first aspect of the present disclosure. In some embodiments, the program product may include one or more software installation packages. When the method provided by the first aspect or its possible variations is required, the software installation packages can be downloaded or copied and executed on the computing device.
[0025] Please note that the invention summary is provided to introduce a series of concepts in a simplified form, which will be further described in the detailed description below. The invention summary is not intended to identify key features or essential features of the present disclosure, nor is it intended to limit the scope of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of the embodiments of the present disclosure in conjunction with the accompanying drawings, in which:
[0027] FIG1 is a diagram schematically illustrating an example environment in which methods and / or processes according to embodiments of the present disclosure may be implemented;
[0028] FIG2 is a flowchart schematically illustrating a method for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0029] FIG3 schematically illustrates an example process of automated test script repair according to an embodiment of the present disclosure;
[0030] FIG4A schematically illustrates an example comparison process between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0031] FIG4B is a diagram schematically illustrating examples of a failed DOM tree, a baseline DOM tree, and a difference DOM tree according to an embodiment of the present disclosure;
[0032] FIG5A schematically illustrates an example failure analysis process when there are differences between a failure DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0033] FIG5B schematically illustrates an example failure analysis process when there is no difference between a failure DOM tree and a corresponding baseline DOM according to an embodiment of the present disclosure;
[0034] FIG6A schematically illustrates an example process of a predictive repair solution when there is a difference between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0035] FIG6B schematically illustrates an example process of a predictive repair solution when there is no difference between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0036] FIG7A schematically illustrates an example process of a prediction repair solution when there is a difference between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0037] FIG7B schematically illustrates an example process of a prediction repair solution when there is no difference between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0038] FIG8A is a diagram schematically illustrating a behavior tree for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0039] FIG8B schematically illustrates an example process of seeking a repair solution for a test script when a failed DOM tree is different from a baseline DOM tree according to an embodiment of the present disclosure;
[0040] FIG8C schematically illustrates an example process of seeking a repair solution for a test script when a failed DOM tree is identical to a baseline DOM tree according to an embodiment of the present disclosure;
[0041] FIG8D is another diagram schematically illustrating a behavior tree for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0042] FIG8E schematically illustrates another example process of seeking a repair solution for a test script when a failed DOM tree is different from a baseline DOM tree according to an embodiment of the present disclosure;
[0043] FIG8F schematically illustrates another example process of seeking a repair solution for a test script when a failed DOM tree is identical to a baseline DOM tree according to an embodiment of the present disclosure.
[0044] FIG9A schematically illustrates an example process of enhancing a behavior tree when matching with the behavior tree fails according to the present disclosure;
[0045] FIG9B schematically illustrates an example process of enhancing a behavior tree when repairing a test script execution failure according to the present disclosure;
[0046] FIG10 shows a schematic block diagram of an apparatus for repairing a test script for a user interface according to some embodiments of the present disclosure;
[0047] FIG11 shows a schematic block diagram of an example device that can be used to implement an example implementation of the present disclosure;
[0048] FIG12 illustrates a schematic block diagram of an example device cluster that may be used to implement example implementations of the present disclosure; and
[0049] FIG13 shows a schematic block diagram of another example device that can be used to implement example implementations of the present disclosure.
[0050] Throughout the drawings, same or similar reference numbers generally refer to same or similar elements. DETAILED DESCRIPTION
[0051] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0052] In the description of the embodiments of the present disclosure, the term "including" and its variations should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. can refer to different or the same objects, unless explicitly indicated to be different.
[0053] As mentioned above, UI automation testing technology is an automated testing method that tests an application's user interface by simulating user interaction with the application. UI automation testing technology has become an indispensable part of application development, helping test engineers quickly and accurately identify potential errors and defects in the user interface and ensure that the application's user interface functionality and stability meet expected levels. UI automation testing technology can test the accuracy and response time of the user interface, as well as its interactivity and user experience.
[0054] However, one of the important problems with UI testing is the poor stability of test cases, which causes test engineers to spend a lot of time maintaining UI test scripts. This is because UI testing involves the interaction between elements in the application's user interface and users, and these elements are easy to change (such as layout changes, addition or removal of controls, adjustment of colors and fonts, etc.). These changes may destroy existing test cases and cause the UI test scripts to fail. In addition, the maintenance cost required for UI testing is usually huge because test cases need to be constantly updated to reflect the latest changes, including adjusting selectors, fixing assertions, updating steps, etc. Since UI testing usually needs to be performed on multiple operating systems and browsers, testers also need to ensure that UI test scripts run well on all platforms. This further increases time and labor costs.
[0055] As the number and frequency of UI changes increase, the workload of maintaining failed UI test scripts increases exponentially. Furthermore, current methods for fixing failed UI test scripts rely heavily on manual effort, typically performed periodically by test engineers based on their personal experience. This presents a significant challenge for test engineers.
[0056] In order to at least solve at least some of the above-mentioned and other potential problems, an embodiment of the present disclosure proposes a method for repairing a test script for a user interface. The method may include, if it is determined that the test script has failed to run, obtaining a failed document object model (DOM) tree of the user interface when the test script failed to run. The method may also include determining a difference DOM tree between the failed DOM tree and the corresponding baseline DOM tree. The method may also include generating a repair test script for the user interface based on the difference DOM tree and the failure error log during the test script execution. In this way, the UI test script can be automatically repaired, reducing the manpower cost and time cost of the test engineer in maintaining the UI test script to reduce his repair workload, and improving the repair quality.
[0057] The basic principles and several exemplary implementations of the present disclosure are described below with reference to Figures 1 to 13. It should be understood that these exemplary embodiments are provided only to enable those skilled in the art to better understand and implement the embodiments of the present disclosure, and are not intended to limit the scope of the present disclosure in any way.
[0058] FIG1 is a schematic diagram illustrating an example environment 100 in which methods and / or processes according to embodiments of the present disclosure may be implemented. As exemplarily shown in FIG1 , a test script 110 may be executed on a cloud platform 120 to test an application. If the test script 110 fails to execute 121 on the cloud platform 120, a test script repair system 122 according to embodiments of the present disclosure, deployed on the cloud platform 120, may repair the test script 110. If the test script repair system 122 is unable to repair the test script 110 (for example, but not limited to, if a repair solution for the test script 110 is not found), a repair failure indication 131 may be provided. After the test script repair system 122 repairs the test script 110, a repaired test script 123 may be output. If the repaired test script 123 fails to execute 124 on the cloud platform 120 again, a repair failure indication 131 may be provided. If the repaired test script 123 succeeds 125 on the cloud platform 120, a repair success indication 132 may be provided.
[0059] According to an embodiment of the present disclosure, the test script repair system 122 according to an embodiment of the present disclosure can capture information about the UI page when the UI test script fails to run, and can compare the failure information with the baseline information to obtain difference information. Based on the obtained difference information and the error information reported when the UI test script fails to run, the test script repair system 122 can predict a solution for the UI test script. If a solution for the UI test script cannot be predicted, it indicates that the repair of the UI test script has failed. If a solution for the UI test script can be predicted, the UI test script is repaired based on the solution.
[0060] According to an embodiment of the present disclosure, the test script 110 is a test script for the user interface. A UI test script is an automated test script for testing whether the user interface of an application can operate according to the expected function. A UI test script will typically simulate the various operations performed by a user on the user interface of the application (for example, by clicking a robot, etc.), and verify whether the response of the application meets expectations. For example, a UI test script can be written to verify whether a form can be successfully jumped to another UI page after being filled out and submitted on a UI page, or whether a pop-up window can be correctly displayed after clicking a button. In addition, a UI test script can also be written to verify whether the selected option is correct after selecting an option in a drop-down list, whether the application can correctly read and process the text after entering text in a text box, or simulate input events (such as clicking, dragging and dropping, etc.). It should be understood that the above examples are only schematically shown for ease of understanding, and the embodiments of the present disclosure are not limited to the above examples.
[0061] According to embodiments of the present disclosure, the user interface testing process can be performed on the cloud platform 120. The cloud platform 120 according to embodiments of the present disclosure can include cloud computing devices with computing capabilities, such as cloud hosts and cloud servers. Testing on the cloud platform 120 can easily configure multiple different test environments for the object under test and quickly switch between different test environments. For example, the compatibility of the object under test can be determined in different operating systems or under different browser versions.
[0062] Conducting testing on the cloud platform 120 can improve testing efficiency and reduce testing costs. The cloud platform 120 provides powerful computing capabilities, enabling accelerated testing through distributed and parallel testing. This means multiple test cases can be executed simultaneously without slowing down testing due to local resource limitations. Furthermore, conducting testing on the cloud platform 120 can reduce hardware resource acquisition and maintenance costs, as the cloud service provider can provide scalable computing and storage resources. This allows resources to be used as needed, thereby reducing testing costs.
[0063] In addition, the cloud-based testing process provides better collaboration and communication, and achieves higher reliability and stability. The testing system built through the cloud platform 120 can enhance collaboration and communication between team members because the test results can be shared with the entire team in real time. In this way, all members can see the progress and results of the test. Moreover, all members can easily access and share test data to solve problems faster and improve test quality. In addition, the testing system built through the cloud platform 120 can eliminate differences in local testing environments, thereby providing a consistent testing environment. This means that real user usage scenarios can be simulated more accurately, thereby improving the reliability and stability of the test. It should be understood that in addition to being arranged in the cloud as described above, UI testing can also be arranged locally, and the embodiments of the present disclosure are not limited to this.
[0064] If test script 110 fails to run 121 on cloud platform 120, a test script repair system 122 according to an embodiment of the present disclosure, deployed on cloud platform 120, repairs test script 110. According to an embodiment of the present disclosure, if test script repair system 122 is unable to repair test script 110, it may indicate a failure 131 in repairing test script 110. This may be due, for example, to a failure to find a solution for test script 110, or an inapplicable solution found for test script 110. This process will be described in further detail below.
[0065] According to an embodiment of the present disclosure, after the test script repair system 122 repairs the test script 110, the repaired test script 123 can be output. In order to verify whether the repair of the test script 110 is successful, the repaired test script 123 can be run. If the repaired test script 123 fails to run, for example, the response of the user interface is different from the expected (such as, the UI page does not jump, or does not jump to the target UI page, etc.), then the repair failure 131 of the test script 110 can be indicated. For example, a message or email can be sent to notify the test engineer that the repair failed. If the repaired test script 123 runs successfully, for example, the response of the user interface is the same as expected (such as, the correct window pops up after clicking the button, etc.), then the repair success 132 of the test script 110 can be indicated. For example, a message or email can be sent to notify the test engineer that the repair is successful. Below, the automated test script repair process according to an embodiment of the present disclosure will be described in further detail.
[0066] As shown in FIG1 , the execution and repair of the test script are performed in the cloud, which can save hardware resources, improve repair efficiency, etc. However, it should be understood that the execution and repair of the test script can be performed locally in addition to being performed in the cloud, or can be performed in a distributed manner in the cloud and locally, and the embodiments of the present disclosure are not limited to this. The above description in conjunction with FIG1 shows a schematic diagram of an example environment 100 in which the method and / or process according to the embodiments of the present disclosure can be implemented. The following description in conjunction with FIG2 shows a flowchart of a method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure.
[0067] Figure 2 is a flowchart illustrating a method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure. In order to reduce the manpower and time costs of test engineers in maintaining UI test scripts, alleviate their repair workload and improve the repair quality, a method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure is proposed. Hereinafter, the automated test script repair process according to an embodiment of the present disclosure will be described in further detail. As discussed above, the method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure can be executed in the cloud, can be executed locally, and can also be executed in a distributed manner in the cloud and locally.
[0068] At box 210, if it is determined that the test script 110 fails to run, the failure DOM tree of the user interface when the test script 110 fails to run is obtained. As described above, when testing the user interface of the application, if the response of the user interface is different from that expected (such as, the UI page does not jump, or does not jump to the target UI page, etc.), it can be determined that the test script 110 for the user interface has failed to run. According to an embodiment of the present disclosure, in response to determining that the test script 110 fails to run, the DOM tree of the UI page when the script fails to run can be captured. Hereinafter, the DOM tree of the UI page captured when the script fails to run may also be referred to as a failure DOM tree. The DOM tree is a representation of an HTML / XML document, which uses a tree structure to represent the hierarchical relationship between the various elements in the UI page. The HTML / XML document can be parsed into a DOM tree, and the parsed DOM tree can be accessed and operated through a scripting language, thereby realizing dynamic updating, interaction and control of the web page.
[0069] In some embodiments, a browser can download an HTML / XML document, and the browser's parser can read the first tag in the document and create a node corresponding to the tag. If the tag has attributes, the parser can add these attributes to the created node. The parser can continue to read the document until text content or another tag is encountered. If text content is encountered, the parser can create a text node and add it to the child node list of the current node. If another tag is encountered, the parser can repeat the above steps until the entire document is parsed into a DOM tree. In some embodiments, the DOM tree can be accessed and operated through JavaScript, TypeScript, or other scripting languages. It should be understood that the description of crawling, controlling, and accessing the DOM tree here is schematically shown for the purpose of ease of understanding, and the embodiments of the present disclosure are not limited to the above examples.
[0070] At block 220, a difference DOM tree is determined between the failed DOM tree and the corresponding baseline DOM tree. According to embodiments of the present disclosure, the failed DOM tree obtained at block 210 can be compared with a corresponding baseline DOM tree from a database of baseline DOM trees to determine the difference DOM tree between the failed DOM tree and the corresponding baseline DOM tree. It should be understood that the corresponding baseline DOM tree described herein can be the DOM tree of the UI page captured when the last or previous script successfully ran, or it can be a manually created and defined DOM tree, and embodiments of the present disclosure are not limited thereto. The difference DOM tree determination process according to embodiments of the present disclosure will be described in further detail below.
[0071] At box 230, based on the difference DOM tree and the failure error log during the execution of the test script 110, a repair test script 123 for the user interface is generated. During the execution of the UI test, a log recording the UI test process can be generated. The generated log may include information related to errors in the UI test process, such as element positioning failure, page load timeout, assertion failure, etc. In the following, the log including the above error information is also referred to as a failure error log. It should be understood that such a log includes not only error information, but also other information, such as the test case name and description, test execution time and environment, and test case execution path (such as page jump, input operation, click event, etc.).
[0072] In some embodiments, the various information in the failure error log can be recorded using a logging library (such as the logging library in Python, Log4j in Java, etc.). In other embodiments, this information can also be recorded using the logging function provided by the test framework or test tool (such as Selenium WebDriver, Appium, etc.). The description of generating the failure error log is provided here for illustrative purposes only, and the embodiments of the present disclosure are not limited to the above example.
[0073] Based on the difference DOM tree determined at 220 and the log recording the UI test process, the test script 110 can be repaired to generate a repaired test script 123. Hereinafter, the repaired test script 123 may also be referred to as the repaired test script 123, and the automated test script repair process according to an embodiment of the present disclosure will be further described in detail. The flowchart of the method 200 for repairing the test script 110 for the user interface according to an embodiment of the present disclosure is described above in conjunction with Figure 2. The flowchart of the method 200 for repairing the test script for the user interface according to an embodiment of the present disclosure is described below in conjunction with Figure 3.
[0074] FIG3 illustrates an example process 300 for automated test script repair according to an embodiment of the present disclosure. The example process 300 schematically illustrated in FIG3 can be executed by the test script repair system 122 shown in FIG1 , and FIG3 also schematically illustrates the configuration of the test script repair system 122. As shown in FIG3 , the test script repair system 122 according to an embodiment of the present disclosure may include a database 320 of baseline DOM trees, a comparison module 330, an analysis module 340, a prediction module 350, an enhancement module 360, and a repair module 370. In addition, FIG3 also illustrates execution modules 310 and 310′ for executing UI test scripts, and a feedback module 380 for indicating whether a repair of a UI test script is successful. It should be understood that the various components shown in FIG3 can be coupled to each other (e.g., via wires or a network), and that the architecture shown in FIG3 may include more or fewer components. It should also be noted that these components can be deployed in the cloud for execution, can be deployed locally, or can be distributed and deployed in the cloud and locally for execution.
[0075] According to an embodiment of the present disclosure, the execution module 310 can be configured to execute a test script 110 for the user interface. A UI test script is an automated test script for testing UI pages. The UI test script can simulate various operations performed by a user on an application or website, such as clicking a button, entering text, selecting an option, etc. By running the UI test script, errors and defects in the UI page can be automatically detected, and the correctness and consistency of the UI can be ensured. As described above, when testing the user interface of an application, if the response of the user interface is different from that expected (such as, the UI page does not jump, or does not jump to the target UI page, etc.), it can be determined that the test script 110 for the user interface has failed to run. If the response of the user interface is the same as expected (such as, the correct window pops up after clicking a button, etc.), it can be determined that the test script 110 for the user interface has run successfully. In other words, based on the execution result of the execution module 310, it can be determined whether the UI test script has run successfully. According to an embodiment of the present disclosure, the execution module 310 can be any execution machine capable of executing a UI test script, and the embodiments of the present disclosure are not limited to this.
[0076] According to an embodiment of the present disclosure, in response to a failure of a user interface test script 110, a failure DOM tree of the user interface at the time of the test script 110 failure can be obtained. In some embodiments, the failure DOM tree can be obtained by parsing the HTML / XML document of the user interface at the time of the test script 110 failure. Simultaneously, a corresponding baseline DOM tree can be obtained from a baseline DOM tree database 320. This baseline DOM tree can be a DOM tree of a UI page captured when the same or a different UI test script successfully ran the previous or previous time, or a manually created and defined DOM tree. The baseline DOM tree to be used for comparison can be determined based on actual needs, such as the actual test objectives or test scenarios. After receiving the failure DOM tree of the user interface at the time of the test script 110 failure and the corresponding baseline DOM tree, the comparison module 330 can be configured to compare the failure DOM tree with the corresponding baseline DOM tree. If there are differences between the failure DOM tree and the corresponding baseline DOM tree, a difference DOM tree between the failure DOM tree and the corresponding baseline DOM tree can be determined. The comparison process of the comparison module 330 will be described in further detail below.
[0077] According to an embodiment of the present disclosure, upon receiving the difference DOM tree between the failure DOM tree of the user interface and the corresponding baseline DOM tree when the test script 110 for the user interface fails from the comparison module 330, the analysis module 340 can obtain a failure error log during the execution of the test script 110. The failure error log includes information related to errors encountered during the execution of the test script 110, such as element location failure, page load timeout, assertion failure, etc. As described above, the log recording the UI testing process may include other information (such as the test case name and description, test execution time and environment, test case execution path, etc.) in addition to error information. Therefore, the analysis module 340 can be configured to extract the failure error information from the failure error log to remove other redundant information. In other words, the analysis module 340 can be configured to perform data cleaning on the failure error log to obtain failure error information associated with errors encountered during the execution of the test script 110. The analysis module 340 can also be configured to determine the failure DOM node in the difference DOM tree that caused the test script 110 to fail. The analysis module 340 may also be configured to associate the extracted failure error information with the determined failure error node.
[0078] As described above, comparison module 330 can be configured to compare the failure DOM tree with the corresponding baseline DOM tree. In some embodiments, if there are no differences between the failure DOM tree and the corresponding baseline DOM tree, analysis module 340 can be configured to obtain a failure error log during the execution of test script 110 and extract failure error information from the failure error log to obtain failure error information associated with errors reported during the execution of test script 110. The analysis process of analysis module 340 will be described in further detail below.
[0079] According to an embodiment of the present disclosure, after receiving the failed DOM node that caused the test script 110 for the user interface to fail in the differential DOM tree from the analysis module 340, and the failure error information extracted from the failure error log that records the execution process of the test script 110, the prediction module 350 can be configured to match a solution for the test script 110. In some embodiments, the prediction module 350 can be configured to determine whether a solution for the test script 110 exists from a knowledge base for repairing UI test scripts based on the associated failed DOM node and the failure error information. If no solution for the test script 110 is found from the knowledge base for repairing UI test scripts based on the associated failed DOM node and the failure error information, or if the found solution is inapplicable, the feedback module 380 can be configured to indicate that the repair of the test script 110 has failed. For example, the feedback module 380 can be configured to send a message or email to notify the test engineer of the failure to repair the test script 110. Furthermore, in response to a failure to repair test script 110, enhancement module 360 can enhance the knowledge base for repairing UI test scripts, for example, by adding a solution corresponding to the situation to the knowledge base, so that similar situations can be addressed in the future. If a solution for test script 110 is found from the knowledge base for repairing UI test scripts based on the associated failed DOM node and failure error information, repair module 370 can be configured to repair test script 110 based on the found solution, thereby obtaining a repaired test script 123. In some embodiments, if execution of repair module 370 fails, the execution function associated with the execution can be checked. If the execution function is determined to be normal, the repair of test script 110 can be determined to have failed. If the execution function is determined to be abnormal, the repair of test script 110 can be re-executed using another execution machine. This allows determination of whether the failure to repair test script 110 is caused by a problem with the execution hardware. According to embodiments of the present disclosure, repair module 370 can be any failed case repair execution machine capable of repairing failed case script projects and can be configured to repair incorrect syntax, logical errors, element positioning errors, and the like, without limitation in the embodiments of the present disclosure.
[0080] In some embodiments, if there are no differences between the failed DOM tree and the corresponding baseline DOM tree, the prediction module 350 can be configured to determine whether a solution for test script 110 exists from the knowledge base for repairing UI test scripts based on the failure error information. If no solution for test script 110 is found from the knowledge base for repairing UI test scripts based on the failure error information, or if the found solution is inapplicable, the feedback module 380 can be configured to indicate that repairing test script 110 has failed. Furthermore, in response to the failure to repair test script 110, the enhancement module 360 can enhance the knowledge base for repairing UI test scripts to address the same or similar situations in the future. If a solution for test script 110 is found from the knowledge base for repairing UI test scripts based on the failure error information, the repair module 370 can be configured to repair test script 110 based on the found solution to obtain a repaired test script 123. The prediction process of the prediction module 350 will be described in further detail below.
[0081] According to an embodiment of the present disclosure, the execution module 310' can be configured to execute a repair test script 123 for the user interface. If the repair test script 123 fails to execute, it can be determined that the repair of the test script 110 has failed. The feedback module 380 can be configured to indicate the failure of the repair of the test script 110. For example, the feedback module 380 can be configured to send a message or email to notify the test engineer that the repair of the test script 110 has failed. In addition, in response to the failure of the repair of the test script 110, the enhancement module 360 can enhance the knowledge base for repairing UI test scripts, for example, adding a solution corresponding to the situation to the knowledge base to facilitate the resolution of similar or similar situations in the future. If the repair test script 123 executes successfully, it can be determined that the repair of the test script 110 has been successful. The feedback module 380 can be configured to indicate the success of the repair of the test script 110. For example, the feedback module 380 can be configured to send a message or email to notify the test engineer that the repair of the test script 110 has been successful. In addition, in response to the successful repair of the test script 110, the DOM tree of the user interface when the repair test script 123 is successfully run (hereinafter, also referred to as the successful DOM tree) can be obtained, and the obtained DOM tree can be updated to the baseline DOM tree database 320 for subsequent UI test script repair.
[0082] Here, based on the execution result of the execution module 310' on the repair test script 123 for the user interface, it can be determined whether the response of the user interface is the same as expected, and thus it can be determined whether the repair test script 123 has run successfully. The architecture shown in Figure 3 includes two execution modules, namely execution modules 310 and 310'. It should be noted that the execution modules 310 and 310' can be the same execution module or different execution modules, and the embodiments of the present disclosure do not limit this. Below, the comparison process between the failed DOM tree and the corresponding baseline DOM tree according to the embodiments of the present disclosure is further described in detail in conjunction with Figures 4A and 4B.
[0083] FIG4A illustrates an example comparison process 400A between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure. This example comparison process 400A can be performed by the comparison module 330 shown in FIG3 , and FIG4B is a schematic diagram 400B illustrating an example of a failed DOM tree, a baseline DOM tree, and a difference DOM tree according to an embodiment of the present disclosure. As shown in FIG4A , according to an embodiment of the present disclosure, based on the execution result of the test script 110 for the user interface by the execution module 310, it can be determined whether the test script 110 has run successfully. After determining that the test script 110 has failed to run (such as, the UI page did not jump to, or did not jump to the target UI page, etc.), a failed DOM tree 410 of the user interface when the test script 110 failed to run can be obtained. The process of obtaining the DOM tree has been described above as an example and will not be repeated here. FIG4B schematically illustrates the failed DOM tree 410, i.e., the DOM tree of the user interface captured when the test script 110 failed to run.
[0084] As shown in FIG4A , according to an embodiment of the present disclosure, a corresponding baseline DOM tree 420 can be obtained from a baseline DOM tree database 320 . This corresponding baseline DOM tree can be the DOM tree of the UI page captured when the same UI test script or a different UI test script was successfully run last or previously, or a manually created and defined DOM tree, etc. The baseline DOM tree to be used for comparison can be determined based on actual needs. FIG4B schematically illustrates the corresponding baseline DOM tree 420.
[0085] As shown in FIG4A , according to an embodiment of the present disclosure, the comparison module 330 may be configured to compare the failed DOM tree 410 with the corresponding baseline DOM tree 420 to determine a difference DOM tree 430 between the failed DOM tree 410 and the baseline DOM tree 420. The comparison process of the comparison module 330 according to an embodiment of the present disclosure is further described in detail with reference to FIG4B . In FIG4B , the failed DOM tree 410 may include a root node (such as a node "div") and multiple child nodes (such as nodes "P", "UI", etc.), and one or more of the multiple child nodes may also serve as a parent node and further include one or more child nodes (for example, node "P" may include the text node "TextNode new"). Similarly, the baseline DOM tree 420 may include a root node (such as a node "div") and multiple child nodes (such as nodes "UI", "P", etc.), and one or more of the multiple child nodes may also serve as a parent node and further include one or more child nodes (for example, node "UI" may include the node "li").
[0086] According to an embodiment of the present disclosure, the failure DOM tree 410 can be compared with the corresponding baseline DOM tree 420 level by level (e.g., using a DIFF algorithm, etc.) to determine the differences between them. The difference DOM tree 430 schematically shown in Figure 4B illustrates such differences. The difference DOM tree 430 includes three difference DOM nodes, namely difference DOM nodes 431, 432, and 434, which indicate the differences between the failure DOM tree 410 and the baseline DOM tree 420. For example, the text node "TextNode New" in the baseline DOM tree 420 is changed to the text node "TextNode New" in the failure DOM tree. Therefore, the changed text node "TextNode New" is highlighted at 433 in the difference DOM tree 430. For example, compared with the baseline DOM tree 420, the node "li" is added to the failure DOM tree 410. Therefore, the added node "li" is highlighted at 434 in the difference DOM tree 430. Compared with the baseline DOM tree 420, the node "UI" in the failure DOM tree 410 has moved. Therefore, the moved node "UI" is highlighted at 431 in the difference DOM tree 430. For example, the node "selection" in the baseline DOM tree 420 is replaced with the node "div" in the failure DOM tree. Therefore, the replaced node "div" is highlighted at 432 in the difference DOM tree 430.
[0087] For ease of understanding and illustration, FIG4B schematically illustrates the node arrangement in the failed DOM tree 410, the corresponding baseline DOM tree 420, and the difference DOM tree 430. It should be understood that embodiments of the present disclosure are not limited to such node arrangements and may also include other different node arrangements. Embodiments of the present disclosure are also not limited to the aforementioned method of determining differences. For example, when determining that there are differences between parent nodes, the parent node and all child nodes included in the parent node may be determined as difference DOM nodes and highlighted in the difference DOM tree 430. Furthermore, DOM nodes in the failed DOM tree 410 that differ from those in the baseline DOM tree 420 are highlighted in the difference DOM tree 430 in FIG4B. It should be understood that DOM nodes in the baseline DOM tree 420 that differ from those in the failed DOM tree 410 may also be highlighted in the difference DOM tree 430. The failure analysis process according to embodiments of the present disclosure will be described in further detail below in conjunction with FIG5A and FIG5B.
[0088] FIG5A illustrates an example failure analysis process 500A when a difference exists between a failure DOM tree 410 and a corresponding baseline DOM tree 420 according to an embodiment of the present disclosure. This example failure analysis process 500A can be performed by the analysis module 340 shown in FIG3 . According to an embodiment of the present disclosure, after receiving a failure error log 501 during the execution of a test script 110, the analysis module 340 can be configured to extract failure error information 503 related to errors (such as element location failure, page load timeout, assertion failure, etc.) when the test script 110 fails to execute from the failure error log 501 to clear other redundant information in the log. In other words, the analysis module 340 can be configured to perform data cleaning on the failure error log 501, thereby cleaning out unnecessary or useless data, thereby improving the efficiency of failure analysis and the quality of error data, reducing the interference of noise data, and optimizing storage space, thereby increasing the accuracy of failure analysis.
[0089] According to an embodiment of the present disclosure, after receiving the difference DOM tree 430 between the failure DOM tree 410 of the user interface and the corresponding baseline DOM tree 420 when the test script 110 for the user interface fails to run, the analysis module 340 can be configured to determine the failure DOM node 502 in the difference DOM tree 430 that caused the test script 110 to fail to run. The difference between the failure DOM tree 410 and the baseline DOM tree 420 can be indicated by the difference DOM nodes in the difference DOM tree 430 between them. However, these difference DOM nodes are not all nodes that caused the test script 110 to fail to run (hereinafter, also referred to as failure DOM nodes). Therefore, locating the failure DOM node is very important for the UI test script repair process, which helps to determine the location where the error occurs when the UI test script fails to run.
[0090] In some embodiments, the analysis module 340 can be configured to determine the type of error (such as element location failure) reported when the test script 110 for the user interface fails to run based on the failure error information 503. The analysis module 340 can be configured to determine, based on the type of failure error, whether the failure error corresponds to a difference DOM node in the difference DOM tree 430. The process of determining the failure DOM node 502 is further explained in detail with reference to the example in FIG4B. For example, if the failure error information 503 indicates that the type of error reported when the test script 110 fails to run is an element location failure, the analysis module 340 can be configured to determine whether the difference DOM node in the difference DOM tree 430 corresponds to the element location failure. In the difference DOM tree 430 shown in FIG4B, the difference DOM node 433 indicates that the text node in the failure DOM tree 410 is "new", while the text node in the corresponding baseline DOM tree 420 is "newly added" (not shown). Therefore, the analysis module 340 can determine the difference DOM node 433 in the difference DOM tree 430 as the failure DOM node 502. That is, if it is determined that the difference DOM node in the difference DOM tree 430 corresponds to the type of failure error, the analysis module 340 may determine the difference DOM node as the failure DOM node 502 .
[0091] According to an embodiment of the present disclosure, if it is determined that the failure error does not correspond to a difference DOM node in difference DOM tree 430, analysis module 340 may be configured to determine whether a DOM node within a predetermined threshold range of the difference DOM node in difference DOM tree 430 corresponds to the type of failure error, such as a parent DOM node and a child DOM node in a level above or below the difference DOM node. If it is determined that a DOM node within the predetermined threshold range of the difference DOM node in difference DOM tree 430 corresponds to the type of failure error, analysis module 340 may determine the DOM node within the predetermined threshold range of the difference DOM node in difference DOM tree 430 as a failure DOM node 502. If there is still no correspondence, the search may be expanded until a correspondence is found, or analysis may be stopped and the repair of script 110 may be indicated as a failure. It should be understood that the example of DOM nodes within the predetermined threshold range of the difference DOM node in difference DOM tree 430 described herein is merely illustrative, and that DOM nodes within the predetermined threshold range of the difference DOM node may also extend up to parent DOM nodes within several levels, or down to child nodes within several levels. The embodiments of the present disclosure are not limited to the above example. It should be understood that the above process may be based on other identifiers of the failure error, such as keywords of the failure error (eg, element failure), in addition to the type of the failure error, and the embodiments of the present disclosure are not limited to this.
[0092] 5B illustrates an example failure analysis process 500B when there are no differences between a failure DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure. As described above, the comparison module 330 can be configured to compare the failure DOM tree 410 with the corresponding baseline DOM tree 420 to determine a difference DOM tree 430 between the failure DOM tree 410 and the baseline DOM tree 420. When it is determined that there are no differences between the failure DOM tree 410 and the corresponding baseline DOM tree 420 (i.e., the DOM tree 410 and the corresponding baseline DOM tree 420 are identical), the analysis module 340 can be configured to extract failure error information 503 related to the error when the test script 110 failed to run from the failure error log 501 to clear other redundant information in the log. In other words, the analysis module 340 can be configured to perform data cleaning on the failure error log 501 to remove unnecessary or useless data. It should be noted that if it is determined that there is no difference between the failed DOM tree 410 and the corresponding baseline DOM tree 420, in addition to being the same as the corresponding baseline DOM tree 420, it may also be due to other reasons (such as hardware reasons or network reasons) that fail to identify the difference between the DOM tree 410 and the corresponding baseline DOM tree 420. In this case, the analysis module 340 is configured to stop the analysis and indicate that the repair of the script 110 has failed. In conventional testing, when it is impossible to distinguish the difference between the current failure situation and the baseline control, the test engineer will manually perform the repair. However, through the above-mentioned failure analysis process 500, the extracted failure error information 503 can be obtained, and the UI test script can be repaired based on prior repair knowledge, thereby improving the repair quality. This process will be described in further detail below.
[0093] Figure 6A illustrates an example process 600A for predicting a repair solution when a difference exists between a failed DOM tree 410 and a corresponding baseline DOM tree 420, according to an embodiment of the present disclosure. According to an embodiment of the present disclosure, after receiving a failed DOM node 502 that caused a test script 110 for a user interface to fail in the difference DOM tree 430 from the analysis module 340, and failure error information 503 extracted from a failure error log recording the execution of the test script 110, the prediction module 350 may be configured to match a repair solution 601 for the test script 110. The prediction module 350 may be configured to determine whether a repair solution 601 exists for the test script 110 from a knowledge base for repairing UI test scripts based on the associated failed DOM node 502 and failure error information 503. In some embodiments, such a knowledge base may include a behavior tree 610 for repairing UI test scripts. The behavior tree 610 may be stored in a database and include multiple processing solutions for repairing the test script 110, each of which may include multiple repair solutions for repairing the test script 110. A behavior tree is a graphical tool for describing complex system behavior. It breaks down a system's behavior into a set of simpler actions, then combines these actions into a hierarchical structure to better understand and manage system behavior. In UI testing, using a behavior tree as a priori knowledge base allows for a better understanding of the application's various behaviors and establishes a knowledge framework that is easy to maintain and extend.
[0094] According to an embodiment of the present disclosure, prediction module 350 may be configured to search for a repair solution 601 for test script 110 from a behavior tree 610 for repairing a UI test script based on the associated failed DOM node 502 and failure error message 503. If prediction module 350 fails to find a repair solution for test script 110 from behavior tree 610 based on the associated failed DOM node 502 and failure error message 503, or if the found repair solution is inapplicable, the failure to repair test script 110 may be indicated. For example, a message or email may be sent to notify the test engineer of the failure to repair test script 110. Furthermore, in response to the failure to repair test script 110, enhancement module 360 may enhance behavior tree 610, for example, by adding a repair solution corresponding to the situation to behavior tree 610, so that the same or similar situation can be repaired in the future. If the prediction module 350 finds a repair solution 601 for the test script 110 from the behavior tree 610 based on the associated failed DOM node 502 and the failure error information 503 , the test script 110 may be repaired based on the found repair solution 601 to obtain a repaired test script 123 .
[0095] FIG6B illustrates an example process 600B for predicting a repair solution when there are no differences between the failed DOM tree 410 and the corresponding baseline DOM tree 420, according to an embodiment of the present disclosure. According to an embodiment of the present disclosure, if there are no differences between the failed DOM tree 410 and the corresponding baseline DOM tree 420, the prediction module 350 may be configured to determine whether a repair solution 601 exists for the test script 110 from the behavior tree 610 for repairing the UI test script based on the failure error information 503. If no repair solution for the test script 110 is found from the behavior tree 610 for repairing the UI test script based on the failure error information 503, or if the repair solution found is inapplicable, then repair of the test script 110 may be indicated as a failure. Furthermore, in response to a failure to repair the test script 110, the enhancement module 360 may enhance the behavior tree 610, for example, by adding a repair solution corresponding to the situation to the behavior tree 610, so that repairs can be performed when the same or similar situation arises in the future. If the prediction module 350 finds a repair solution 601 for the test script 110 from the behavior tree 610 based on the failure error information 503 , the test script 110 may be repaired based on the found repair solution 601 to obtain a repaired test script 123 .
[0096] FIG7A illustrates an example process 700A for predicting a repair solution when a difference exists between a failed DOM tree 410 and a corresponding baseline DOM tree 420, according to an embodiment of the present disclosure. According to an embodiment of the present disclosure, after receiving a failed DOM node 502 from a difference DOM tree 430 that caused a test script 110 for a user interface to fail, at block 710 , the DOM type of the failed DOM node 502 may be determined. At block 720 , a determination may be made from the behavior tree 610 for repairing the UI test script to determine whether a corresponding handling solution exists for the DOM type of the failed DOM node 502. If the determination is "no" at block 720 , the process may proceed to block 730 to enhance the behavior tree 610, for example, by adding a handling solution corresponding to the DOM type of the failed DOM node 502 to the behavior tree 610. If the determination is "yes" at block 720 , the process may proceed to block 740 to determine whether a repair solution exists for the test script 110, based on the failure error information 503 associated with the error message generated when the test script 110 failed to run. At block 750 , a determination is made as to whether a repair solution corresponding to the failure error message 503 exists in the behavior tree 610. If the answer is “No” at block 750 , the process proceeds to block 730 to enhance the behavior tree 610, such as adding a repair solution corresponding to the failure error message 503 to the behavior tree 610. If the answer is “Yes” at block 750 , the repair solution corresponding to the failure error message 503 may be retrieved from the behavior tree 610.
[0097] FIG7B illustrates an example process 700B for predicting a repair solution when there are no differences between a failure DOM tree 410 and a corresponding baseline DOM tree 420, according to an embodiment of the present disclosure. According to an embodiment of the present disclosure, after receiving failure error information 503 related to an error message generated when a test script 110 fails to execute, at block 740 , a determination is made from the behavior tree 610 whether a repair solution exists for the test script 110 based on the failure error information 503. At block 750 , a determination is made as to whether a repair solution corresponding to the failure error information 503 exists in the behavior tree 610. If the determination at block 750 is "no," the process proceeds to block 730 to enhance the behavior tree 610, for example, by adding a repair solution corresponding to the failure error information 503 to the behavior tree 610. If the determination at block 750 is "yes," the repair solution corresponding to the failure error information 503 is retrieved from the behavior tree 610.
[0098] Figure 8A is a schematic diagram 800A illustrating a behavior tree 610 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure. At selection node 801, a selection can be made as to whether the failed DOM tree 410 is the same as the corresponding baseline DOM tree 420. In response to determining that the failed DOM tree 410 is different from the baseline DOM tree 420, a selection can be made in parallel as to which DOM type the failed DOM node 502 belongs. In Figure 8A, DOM type 1, DOM type 2, ..., DOM type n are schematically shown, and each DOM type corresponds to a processing solution. By way of example, in response to determining that the DOM type of the failed DOM node 502 is DOM type 1, a processing solution for the test script 110, namely, processing solution 1, can be determined. In addition, in response to determining that the failed DOM tree 410 is the same as the baseline DOM tree 420, a processing solution for the test script 110, namely, processing solution *, can be determined. The dotted boxes in FIG. 8A illustrate explanations of the logic nodes appearing in the figure. The behavior tree 610 for repairing the test script 110 for the user interface will be described in further detail below in conjunction with FIG. 8B and FIG. 8C .
[0099] FIG8B illustrates an example process 800B for seeking a repair solution for a test script 110 when the failure DOM tree 410 differs from the baseline DOM tree 420 according to an embodiment of the present disclosure. Block 820 shown in FIG8B further illustrates the processing solution 1, processing solution 2, ..., processing solution N shown in FIG8A. By way of example, in response to determining that the DOM type of the failure DOM node 502 is DOM type 1, the failure DOM node 502 can be found, and the failure error information 503 associated with the failure DOM node 502 can be selected. FIG8B schematically illustrates failure error information 1, failure error information 2, ..., failure error information n. For example, in response to determining that the failure error information 503 associated with the failure DOM node 502 is critical information 1, a repair solution for the test script 110, namely, repair solution 1, can be determined, and repair solution 1 can be executed on the test script 110. The dashed boxes in FIG8B illustrate an explanation of the logical nodes shown in the diagram.
[0100] FIG8C illustrates an example process 800C for seeking a fix for a test script 110 when a failure DOM tree 410 is identical to a baseline DOM tree 420, according to an embodiment of the present disclosure. Block 830 shown in FIG8C further illustrates the processing solution * shown in FIG8A. By way of example, in response to determining that the failure DOM tree 410 is identical to the baseline DOM tree 420, a failure DOM node 502 may be found, and the failure error message 503 associated with the failure DOM node 502 may be selected. FIG8C schematically illustrates failure error message 1*, failure error message 2*, ..., failure error message n*. For example, in response to determining that the failure error message 503 associated with the failure DOM node 502 is critical message 1*, a fix for the test script 110, namely, fix solution 1*, may be determined, and fix solution 1* may be executed on the test script 110. The dashed boxes in FIG8C illustrate an explanation of the logical nodes shown in the diagram.
[0101] Figure 8D is another schematic diagram 800D illustrating a behavior tree 610 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure. At selection node 804, a selection can be made as to whether the failure DOM tree 410 is identical to the corresponding baseline DOM tree 420. In response to determining that the failure DOM tree 410 is different from the baseline DOM tree 420, a selection can be made in parallel as to which type of failure error information the failure error message 503 belongs. In Figure 8D, failure error information type 1, failure error information type 2, ..., failure error information type n are schematically shown, and each failure error information type corresponds to a processing solution. By way of example, in response to determining that the failure error information 503 belongs to failure error information type 1, a processing solution for the test script 110, namely, processing solution 1, can be determined. Furthermore, in response to determining that the failure DOM tree 410 is identical to the baseline DOM tree 420, a processing solution for the test script 110, namely, processing solution *, can be determined. The dotted box in FIG8D shows an explanation of the logic nodes appearing in the figure. The behavior tree 610 for repairing the test script 110 for the user interface will be described in further detail below in conjunction with FIG8E and FIG8F .
[0102] Figure 8E illustrates another example process 800E for seeking a fix for a test script 110 when the failure DOM tree 410 differs from the baseline DOM tree 420 according to an embodiment of the present disclosure. Block 850 shown in Figure 8E further illustrates the processing solutions 1, 2, ..., and N shown in Figure 8D. In the example of Figure 8E, each type of failure error message corresponds to a fix. By way of example, in response to determining that the failure error message 503 belongs to failure error message type 1, the failure DOM node 502 associated with the failure error message 503 can be found, and the DOM type of the failure DOM node 502 can be selected. For example, in response to determining that the DOM type of the failure DOM node 502 is DOM type 1, a fix for the test script 110, namely, fix 1, can be determined, and fix 1 can be executed on the test script 110. The dashed boxes in Figure 8E illustrate an explanation of the logical nodes shown in the diagram.
[0103] Figure 8F illustrates another example process 800F for seeking a fix for a test script 110 when a failure DOM tree 410 is identical to a baseline DOM tree 420, according to an embodiment of the present disclosure. Block 860 shown in Figure 8F further illustrates the processing solution* shown in Figure 8D. In the example of Figure 8F, each type of failure error message corresponds to a fix. By way of example, in response to determining that the failure DOM tree 410 is identical to the baseline DOM tree 420, a selection can be made as to which type of failure error message the failure error message 503 belongs. Figure 8F schematically illustrates failure error message type 1, failure error message type 2, ..., and failure error message type n. For example, in response to determining that the failure error message 503 belongs to failure error message type 1, the failure DOM node 502 associated with the failure error message 503 can be found, and fix solution 1* can be executed on the test script 110. The dashed boxes in Figure 8F illustrate an explanation of the logical nodes shown in the diagram.
[0104] Figure 9A illustrates an example process 900A for enhancing a behavior tree 610 when a match with the behavior tree 610 fails, according to the present disclosure. According to an embodiment of the present disclosure, in response to a match failure with the behavior tree 610, i.e., failure to find a fix for the UI test script in the behavior tree 610, a target DOM node may be determined at block 910. The target DOM node may be the failed DOM node 502, a difference DOM node in the difference DOM tree 430, a DOM node within a predetermined threshold range of difference DOM nodes in the difference DOM tree 430, or the like. At block 920, a determination may be made as to whether the target DOM node determined at block 910 should be enhanced. This determination at block 920 may be performed by the test framework in response to a predetermined trigger condition, or by a test engineer or tool developer. At block 930, a determination is made as to whether the enhancement is possible. If the answer at block 930 is "No," the process proceeds to block 940 to record the unrepairable situation and avoid this path when designing test cases next time. If “yes” at block 930 , proceed to block 950 to enhance the behavior tree 610 .
[0105] Figure 9B illustrates an example process 900B for enhancing a behavior tree 610 when a repair test script 123 fails according to the present disclosure. At block 920, a determination is made as to whether the target DOM determined at block 910 should be enhanced. This determination can be made by the test framework in response to a predetermined trigger condition, or by a test engineer or tool development engineer. At block 930, a determination is made as to whether the enhancement is possible. If the answer at block 930 is "No," the process proceeds to block 940, where the unrepairable condition is recorded and the path is avoided when designing the next test case. If the answer at block 930 is "Yes," the process proceeds to block 950, where the behavior tree 610 is enhanced.
[0106] Figure 10 shows a schematic block diagram of an apparatus 1000 for repairing a user interface according to some embodiments of the present disclosure. As shown in Figure 10, the apparatus 1000 includes an acquisition module 1010, a comparison module 1020, and a prediction module 1030. It should be understood that the specific actions and functions of the acquisition module 1010, the comparison module 1020, and the prediction module 1030 of the apparatus 1000 may be the same or similar to those specifically described in the above embodiments, and may also be adjusted and changed according to specific circumstances. The apparatus 1000 may be distributedly deployed in multiple nodes, and the acquisition module 1010, the comparison module 1020, and the prediction module 1030 may also be distributed in one or more nodes individually or in combination.
[0107] According to an embodiment of the present disclosure, if it is determined that the test script execution failed, the acquisition module 1010 is configured to acquire the failed Document Object Model (DOM) tree of the user interface at the time of the test script execution failure. The comparison module 1020 is configured to determine a difference DOM tree between the failed DOM tree and the corresponding baseline DOM tree. The prediction module 1030 is configured to generate a repair test script for the user interface based on the difference DOM tree and the failure error log during the test script execution.
[0108] An embodiment of the present disclosure further provides a computing device 1100, and a node of an embodiment of the present disclosure may include at least one computing device 1100. As shown in FIG11 , the computing device 1100 includes: a bus 1102, a processor 1104, a memory 1106, and a communication interface 1108. The processor 1104, the memory 1106, and the communication interface 1108 communicate with each other via the bus 1102. The computing device 1100 may be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 1100. The bus 1102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, FIG11 is represented by only one line, but this does not mean that there is only one bus or one type of bus. The bus 1104 may include a path for transmitting information between the various components of the computing device 1100 (e.g., the memory 1106, the processor 1104, and the communication interface 1108). The processor 1104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP). The memory 1106 may include volatile memory, such as random access memory (RAM). The processor 1104 may also include non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid state drive (SSD). Memory 1106 stores executable program code, and processor 1104 executes this executable program code to implement the methods of the interactive control module acquisition module 1010, cloud rendering module comparison module 1020, and material attachment module prediction module 1030 described in the aforementioned embodiments of the present disclosure. In other words, memory 1106 may store instructions for the methods and functions of any of the aforementioned embodiments. Communication interface 1108 utilizes a transceiver module, such as, but not limited to, a network interface card or transceiver, to enable communication between computing device 1100 and other devices or communication networks.
[0109] An embodiment of the present disclosure further provides a computing device cluster 1200, on which the test script repair system 122 according to the embodiment of the present disclosure is deployed, and the computing device cluster 1200 includes at least one computing device 1100. In some embodiments, the computing device cluster 1200 may include one computing device 1100 to implement all or part of the test script repair system 122 of the embodiment of the present disclosure. In some embodiments, the computing device cluster 1200 may include multiple computing devices 1100, and the multiple computing devices may implement all or part of the test script repair system 122 of the embodiment of the present disclosure synchronously or asynchronously, serially or in parallel, independently or in a distributed manner. The computing device 1100 in the computing device cluster 1200 may be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0110] As shown in FIG12 , the computing device cluster 1200 includes at least one computing device 1100. The memory 1106 of one or more computing devices 1100 in the computing device cluster 1200 may store the same instructions for executing the methods and functions of any of the aforementioned embodiments. In some possible implementations, the memory 1106 of one or more computing devices 1100 in the computing device cluster 1200 may also store partial instructions for executing the methods and functions of any of the aforementioned embodiments related to the present disclosure. In other words, a combination of one or more computing devices 1100 can collectively execute instructions for the methods and functions of the present disclosure. It should be noted that the memory 1106 of different computing devices 1100 in the computing device cluster may store different instructions, each for executing a portion of the functions of the apparatus 1100. That is, the instructions stored in the memory 1106 of different computing devices 1100 may implement the functions of one or more modules or submodules of the acquisition module 1010, the comparison module 1010, and the prediction module 1130. In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network. Wherein, the network may be a wide area network or a local area network, etc. FIG13 shows a possible implementation method 1300. As shown in FIG13 , two computing devices 1100A and 1100B are connected via a network 1310. The connection method between the computing device clusters shown in FIG13 may be that considering that the method of the present application requires the storage of a large amount of user data and the performance of intensive real-time or near real-time calculations, it is considered to hand over part of the functions to the computing device 1100B for execution. It should be understood that the functions of the computing device 1100A shown in FIG13 may also be performed by multiple computing devices 1100. Similarly, the functions of the computing device 1100B may also be performed by multiple computing devices 1100. The embodiments of the present disclosure also provide a computer program product comprising instructions, which, when running on a computer, enables the computer to execute the methods and functions of any of the above-mentioned embodiments.
[0111] An embodiment of the present disclosure further provides a computer-readable storage medium having computer instructions stored thereon. When a processor executes the instructions, the processor executes the method and function of any of the above embodiments.
[0112] In general, various embodiments of the present disclosure may be implemented in hardware or dedicated circuitry, software, logic, or any combination thereof. Some aspects may be implemented in hardware, while other aspects may be implemented in firmware or software, which may be executed by a controller, microprocessor, or other computing device. Although various aspects of the embodiments of the present disclosure are shown and described as block diagrams, flow charts, or using some other pictorial representation, it should be understood that the blocks, devices, systems, techniques, or methods described herein may be implemented as, by way of non-limiting example, hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or a controller or other computing device, or some combination thereof.
[0113] The present disclosure also provides at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes computer-executable instructions, such as instructions included in program modules, which are executed in a device on a real or virtual processor of a target to perform the process / method as described above with reference to the accompanying drawings. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functionality of program modules can be combined or divided between program modules as needed. The machine-executable instructions for the program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.
[0114] The computer program code for implementing the disclosed method can be written in one or more programming languages. These computer program codes can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device so that the program code, when executed by the computer or other programmable data processing device, causes the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on a computer, partially on a computer, as an independent software package, partially on a computer and partially on a remote computer or entirely on a remote computer or server.
[0115] In the context of the present disclosure, computer program code or related data may be carried by any suitable carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, and the like. Examples of signals may include electrical, optical, radio, acoustic, or other forms of propagated signals, such as carrier waves, infrared signals, and the like.
[0116] A computer-readable medium may be any tangible medium containing or storing a program for or relating to an instruction execution system, apparatus, or device, or a data storage device such as a data center containing one or more available media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination thereof. More detailed examples of computer-readable storage media include an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0117] In addition, although the operations of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can change the order of execution. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of a device described above can be further divided into being embodied by multiple devices.
[0118] While various implementations of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and non-limiting to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is selected to facilitate explanation of the principles, practical applications, or improvements to existing technologies, or to enable others skilled in the art to understand the various implementations disclosed herein.
[0119] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0120] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. can refer to different or the same objects. The term "and / or" means at least one of the two items it is associated with. For example, "A and / or B" means A, B, or A and B. Other explicit and implicit definitions may also be included below.
[0121] It should be understood that in the technical solutions provided by the embodiments of the present application, some repetitions may not be repeated in the introduction of the following specific embodiments, but these specific embodiments should be regarded as having been referenced to each other and can be combined with each other.
[0122] As mentioned above, the power consumption of electronic devices containing multiple chips is a growing concern. While power consumption has been reduced by shrinking device size, this is still not ideal. As chip performance and functionality increase, solutions to further reduce power consumption are still needed.
Claims
1. A method for repairing a test script for a user interface, comprising: If the test script fails to run, obtaining a failure document object model DOM tree of the user interface when the test script fails to run; Determine a difference DOM tree between the failed DOM tree and a corresponding baseline DOM tree; as well as A repair test script for the user interface is generated based on the difference DOM tree and the failure error log during the execution of the test script.
2. The method according to claim 1, further comprising: Extracting the failure error information from the failure error log, wherein the failure error information indicates the reason why the test script failed to run; as well as Determine a failed DOM node in the difference DOM tree that causes the test script to fail to run; as well as The failure error information is associated with the failed DOM node.
3. The method according to claim 2, wherein determining the failed DOM node comprises: Based on the failure error information, determine the failure error when the test script fails to run; as well as Determine whether a difference DOM node in the difference DOM tree corresponds to the failure error, wherein the difference DOM node indicates a difference between the failure DOM tree and the corresponding baseline DOM tree.
4. The method according to claim 3, wherein determining the failed DOM node further comprises: If it is determined that the difference DOM node in the difference DOM tree corresponds to the failure error, determine the difference DOM node as a failure DOM node; as well as If it is determined that the difference DOM node in the difference DOM tree does not correspond to the failure error, it is determined whether a DOM node within a predetermined threshold range of the difference DOM node in the difference DOM tree corresponds to the failure error.
5. The method according to claim 4, wherein determining the failed DOM node further comprises: If it is determined that the DOM node within the predetermined threshold range of the difference DOM node in the difference DOM tree corresponds to the failure error, determining the DOM node as a failed DOM node; as well as If it is determined that the DOM nodes within the predetermined threshold range of the difference DOM nodes in the difference DOM tree do not correspond to the failure error, it is indicated that repair of the test script has failed.
6. The method according to claim 2, generating a repair test script for the user interface comprises: Determine the DOM type of the failed DOM node; as well as Based on the determined DOM type, determine whether there is a processing solution for the test script corresponding to the DOM type of the failed DOM node in the behavior tree, wherein the behavior tree includes multiple processing solutions for repairing the test script, and each of the multiple processing solutions includes multiple repair solutions for repairing the test script.
7. The method according to claim 6, further comprising: If it is determined that the processing solution corresponding to the DOM type of the failed DOM node does not exist in the behavior tree, indicating that repairing the test script fails; as well as The processing scheme corresponding to the DOM type of the DOM node is added to the behavior tree.
8. The method according to claim 6, further comprising: If it is determined that the processing solution corresponding to the DOM type of the failed DOM node exists in the behavior tree, it is determined whether there is a repair solution for the test script in the behavior tree based on the failure error information associated with the failed DOM node.
9. The method according to claim 8, further comprising: If it is determined that the repair solution for the test script does not exist in the behavior tree, indicating that the repair of the test script fails; as well as Add the repair solution corresponding to the failure error information to the behavior tree.
10. The method according to claim 8, further comprising: If it is determined that the repair solution for the test script exists in the behavior tree, the test script is repaired based on the repair solution to obtain the repaired test script.
11. The method according to claim 10, further comprising: If executing the repair to the test script fails, checking an execution function associated with executing the repair to the test script; If it is determined that the execution function is normal, determining that the repair of the test script fails; as well as If it is determined that the execution function is abnormal, another execution machine is used to re-execute the repair of the test script.
12. The method according to claim 10, further comprising: If the test script is repaired successfully, obtain the successful DOM tree when the test script runs successfully; Updating the successful DOM tree into the database of the baseline DOM tree; as well as Indicates that the repair of the test script was successful.
13. The method of claim 1 , wherein the difference DOM tree is determined by comparing the failed DOM tree with the corresponding baseline DOM tree, the method further comprising: If it is determined that the failed DOM tree is the same as the corresponding baseline DOM tree, a repair test script for the user interface is generated based on the failure error log.
14. A device for repairing a test script for a user interface, comprising: An acquisition module, configured to acquire a failure document object model DOM tree of the user interface when the test script fails to run, if it is determined that the test script fails to run; a comparison module configured to determine a difference DOM tree between the failed DOM tree and a corresponding baseline DOM tree; as well as The prediction module is configured to generate a repair test script for the user interface based on the difference DOM tree and the failure error log during the running of the test script.
15. A computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory, the processor of the at least one computing device being configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed by a computing device, cause the computing device to perform the method according to any one of claims 1 to 13.
17. A computer program product, characterized in that The computer program product comprises instructions which, when executed by a computing device, cause the computing device to perform a method according to any one of claims 1 to 13 .
Citation Information
Patent Citations
Webpage test method and device
CN104239206A
Method and system for repairing web automatic testing scripts
CN107451065A
User interface testing method and device
CN112148579A
Web interface compatibility testing method and device
CN113220587A
Error correction method and device for page test script
CN115687075A
