Method, device, cluster, medium and product for repairing test script for user interface
By obtaining the difference between the DOM tree and the baseline DOM tree when the UI test script fails to run, and combining the failure error log to automatically generate repair scripts, the problem of poor stability of UI test scripts is solved, efficient automatic repair is achieved, and labor and time costs are reduced.
Patent Information
- Application Number
- CN202310558124.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-17
- Publication Date
- 2024-11-26
AI Technical Summary
The poor stability of UI test scripts leads to testing engineers spending a lot of time to maintain, high labor and time costs, and existing repair methods rely on manual experience and are inefficient.
By obtaining the difference between the DOM tree in the user interface when failure and the baseline DOM tree, and generating repair test scripts based on the failure error log, automating repair UI test scripts, reducing labor and time costs, and improving repair quality.
Automated repair of UI test scripts reduces the maintenance load of test engineers, improves repair efficiency and quality, reduces noise data interference, optimizes storage space, and improves analysis accuracy.
Smart Images

Figure CN119025397A_ABST
Abstract
Description
Technical Field
[0001] 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
[0002] UI automation testing technology refers to an automated testing method that tests the user interface of an application by simulating the process of user interaction with the application. UI automation testing technology can ensure that the functionality and stability of the application in terms of the user interface meet the expected level. In the development of applications, UI automation testing technology has become a very important and indispensable component.
[0003] UI automation testing technology can test the accuracy of the user interface (such as the location, size, color, font, etc. of elements) and the response time. In addition, UI automation testing technology can also test the interactivity and user experience of the user interface (such as ease of use, reliability, efficiency, etc.). These are very critical factors for the user interface and directly affect the quality of the application and user satisfaction with the application.
[0004] UI automation testing technology helps to discover potential errors and defects in the user interface. By using automated testing tools for the user interface, test engineers can quickly perform different tests on the user interface and quickly rerun the test scripts after each code change. This can improve the efficiency of testing while also ensuring the accuracy and consistency of testing. Summary of the invention
[0005] 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.
[0006] 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 fails to run, obtaining a failed document object model DOM tree of the user interface when the test script fails 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. According to the method for repairing a test script for a user interface in the first aspect of the present disclosure, 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 its repair workload, and improving the repair quality.
[0007] 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 up, so that the failure analysis efficiency and error data quality are improved, the interference of noise data is reduced, and the storage space is optimized at the same time, thereby increasing the accuracy of failure analysis. Determining the failure DOM node that caused the test script to fail to run in the difference DOM tree helps to determine the location where the error occurs when the UI test script fails to run.
[0008] In some embodiments, a failure error when a test script fails to run can be determined based on the failure error information, and it can be determined whether a difference DOM node in a difference DOM tree corresponds to the failure error, wherein the difference DOM node indicates the difference between the failure DOM tree and the corresponding baseline DOM tree. In this way, it can be determined whether a difference DOM node in a difference DOM tree is a failure DOM node with the help of the failure error information, without traversing all nodes in the tree, thereby improving time efficiency and reducing computational costs.
[0009] In some embodiments, if it is determined that the difference DOM node in the difference DOM tree corresponds to the failure error, the difference DOM node can be determined as the failure DOM node, and 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 the DOM nodes within a predetermined threshold range of the difference DOM node in the difference DOM tree correspond to the failure error. In this way, when the difference DOM node in the difference DOM tree is not a DOM node, continuing to search in a small range can determine the failure DOM node more quickly, thereby helping to determine the location where the failure error occurs.
[0010] In some embodiments, if it is determined that a DOM node within a predetermined threshold range of the difference DOM nodes in the difference DOM tree corresponds to a failure error, the DOM node can be determined as a failed DOM node, and if it is determined that a DOM node within a predetermined threshold range of the difference DOM nodes in the difference DOM tree does not correspond to a failure error, a failure to repair the test script can be indicated. In this way, if it continues, the failed DOM node may still not be found, which will waste time and computing resources. Therefore, the analysis can be stopped and the repair failure of the UI test script can be indicated.
[0011] In some embodiments, the DOM type of the failed DOM node can be determined, and based on the determined DOM type, it can be determined 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. In this way, through the DOM type of the failed DOM node, a processing solution for this DOM type can be sought in a priori knowledge base with a clear hierarchical structure.
[0012] In some embodiments, if it is determined that there is no processing solution corresponding to the DOM type of the failed DOM node in the behavior tree, it can be indicated that the repair of the test script has failed, and a processing solution corresponding to the DOM type of the DOM node can be added to the behavior tree. In this way, if there is no processing solution for this DOM type in the previously established prior knowledge base, such a processing solution will be added to handle the same or similar situations in the future.
[0013] In some embodiments, if it is determined that there is a processing solution corresponding to the DOM type of the failed DOM node in the behavior tree, it can be 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. In order to further find a repair solution 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. In this way, it can be accurately determined whether there is a repair solution for the UI test script in the prior knowledge base.
[0014] In some embodiments, if it is determined that there is no repair solution for the test script in the behavior tree, it can be indicated that the repair of the test script has failed, and a repair solution corresponding to the failed error information is added to the behavior tree. In some embodiments, if it is determined that there is a repair solution for the test script in the behavior tree, the test script is repaired based on the repair solution to obtain a repaired test script. In this way, the location of the failed error can be accurately located, and the corresponding repair solution can be better matched, thereby improving the repair quality.
[0015] In some embodiments, if the execution of the repair of the test script fails, the execution function associated with the execution of the repair of the test script may be checked. If it is determined that the execution function is normal, it may be determined that the repair of the test script has failed, and if it is determined that the execution function is abnormal, the repair of the test script is re-executed using another execution machine. In this way, it may be determined whether the failure to repair the test script is caused by a problem with the execution hardware.
[0016] In some embodiments, if the repair of the test script is successful, the successful DOM tree when the test script runs successfully can be obtained, and the successful DOM tree can be updated to the database of the baseline DOM tree. In addition, the repair of the test script can be indicated to be successful. In this way, the successful DOM tree of the UI page when the repaired UI test script runs successfully will be saved as a new baseline DOM tree for subsequent comparison.
[0017] In some embodiments, 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. In this way, if no difference is 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.
[0018] 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 acquire a failed 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. The device also includes a comparison module configured to determine a difference DOM tree between the failed DOM tree and the 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 the failure error log during the test script running.
[0019] 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, and when the instructions are executed by the processor, the computing device executes the method according to the first aspect of the present disclosure.
[0020] 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 executes 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, a laptop, or a smart phone.
[0021] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions, and when the instructions are executed by a computing device, the computing device executes 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 (Hard Disk Drive, HDD), solid state disk (Solid State Drive, SSD), etc.).
[0022] According to a sixth aspect of the present disclosure, a computer program product is provided. The computer program product includes instructions, and when the instructions are executed by a computing device, the computing device performs 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, and when it is necessary to use the method provided by the first aspect or its possible variations, the software installation packages can be downloaded or copied and executed on the computing device.
[0023] 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
[0024] The above and other purposes, features and advantages of the present disclosure will become more clearly understood by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings, in which:
[0025] Figure 1 is a diagram schematically illustrating an example environment in which methods and / or processes according to embodiments of the present disclosure may be implemented;
[0026] Figure 2 is a flowchart schematically illustrating a method for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0027] Figure 3 Schematically illustrates an example process of automated test script repair according to an embodiment of the present disclosure;
[0028] Figure 4A 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;
[0029] Figure 4Bis 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;
[0030] Figure 5A schematically illustrates an example failure analysis process when there is a difference between a failure DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure;
[0031] Figure 5B 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;
[0032] Fig. 6A 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;
[0033] Figure 6B 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;
[0034] Fig. 7A 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;
[0035] Figure 7B 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;
[0036] Fig. 8A is a schematic diagram schematically illustrating a behavior tree for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0037] Figure 8B is a schematic diagram illustrating 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;
[0038] Figure 8C is a schematic diagram illustrating an example process of seeking a repair solution for a test script when a failed DOM tree is the same as a baseline DOM tree according to an embodiment of the present disclosure;
[0039] Fig.8D is another schematic diagram schematically illustrating a behavior tree for repairing a test script for a user interface according to an embodiment of the present disclosure;
[0040] Fig. 8Eis another example process schematically illustrating 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;
[0041] Figure 8F FIG. 4 schematically illustrates another example process of seeking a repair solution for a test script when a failed DOM tree is the same as a baseline DOM tree according to an embodiment of the present disclosure.
[0042] Fig. 9A is a schematic diagram illustrating an example process of enhancing a behavior tree when matching with a behavior tree fails according to the present disclosure;
[0043] Fig. 9B is a schematic diagram illustrating an example process of enhancing a behavior tree when repairing a test script execution failure according to the present disclosure;
[0044] Fig.10 A schematic block diagram of an apparatus for repairing a test script for a user interface according to some embodiments of the present disclosure is shown;
[0045] Fig.11 A schematic block diagram showing an example device that can be used to implement an example implementation of the present disclosure;
[0046] Fig.12 A schematic block diagram illustrating an example device cluster that may be used to implement an example implementation of the present disclosure; and
[0047] Fig.13 A schematic block diagram of another example device that can be used to implement the example implementations of the present disclosure is shown.
[0048] Throughout the drawings, same or similar reference numbers generally refer to same or similar elements. DETAILED DESCRIPTION
[0049] 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 set forth 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 only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0050] 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. may refer to different or the same objects, unless explicitly indicated to be different.
[0051] As mentioned above, UI automation testing technology refers to an automated testing method that tests the user interface of an application by simulating the interaction process between the user and the application. UI automation testing technology has become an indispensable part of application development, which can help test engineers quickly and accurately find potential errors and defects in the user interface, and ensure that the application's functionality and stability in the user interface meet the expected level. UI automation testing technology can test the accuracy and response time of the user interface, as well as the interactivity and user experience of the user interface.
[0052] However, one of the important problems of 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 script 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 will further increase time and labor costs.
[0053] As the number and frequency of changes to UI pages increase, the workload of maintaining failed UI test scripts increases exponentially. In addition, the current method of repairing failed UI test scripts relies heavily on manual work, which is basically performed regularly by test engineers based on their personal experience. This is a severe challenge for test engineers.
[0054] In order to solve at least some of the above 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 obtaining a failed 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. 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 running. In this way, the UI test script can be automatically repaired, reducing the manpower cost and time cost of the test engineer to maintain the UI test script to reduce its repair workload, and improving the repair quality.
[0055] Reference below 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.
[0056] Figure 1 1 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. Figure 1 As exemplarily shown in FIG. 1 , the test script 110 can be run on the cloud platform 120 to test the application. If the test script 110 fails to run 121 on the cloud platform 120, the test script repair system 122 according to the embodiment of the present disclosure deployed in the cloud platform 120 can repair the test script 110. If the test script repair system 122 cannot repair the test script 110 (for example, but not limited to, the situation where a repair solution for the test script 110 cannot be found, etc.), a repair failure 131 may be indicated. 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 run again on the cloud platform 120 124, a repair failure 131 may be indicated. If the repaired test script 123 runs successfully 125 on the cloud platform 120, a repair success 132 may be indicated.
[0057] According to an embodiment of the present disclosure, the test script repair system 122 according to an embodiment of the present disclosure can capture the information of 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 when the UI test script fails to run, the test script repair system 122 can predict the solution for the UI test script. If the solution for the UI test script cannot be predicted, it indicates that the repair of the UI test script has failed, and if the solution for the UI test script can be predicted, the UI test script is repaired based on the solution.
[0058] 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 run according to the expected function. A UI test script will usually simulate various operations performed by a user on the user interface of an application (e.g., by clicking on 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 in and submitted on a UI page, or to verify 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 clicks, drag and drop, etc.). It should be understood that the above examples are schematically shown only for the purpose of ease of understanding, and the embodiments of the present disclosure are not limited to the above examples.
[0059] According to an embodiment of the present disclosure, the test process of the user interface can be performed on the cloud platform 120. According to an embodiment of the present disclosure, the cloud platform 120 may include a cloud computing device with computing capabilities, such as a cloud host, a cloud server, etc. Testing on the cloud platform 120 can easily configure multiple different test environments for the object under test, and can 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.
[0060] By performing the testing process on the cloud platform 120, the testing efficiency can be improved and the testing cost can be reduced. The cloud platform 120 can provide powerful computing power, which enables the testing process to be accelerated through distributed testing and parallel testing. This means that multiple test cases can be executed at the same time without slowing down the testing progress due to local resource limitations. At the same time, by performing the testing process on the cloud platform 120, the acquisition and maintenance costs of hardware resources can be saved, because the cloud service provider can provide scalable computing and storage resources, which enables the required resources to be used as needed, thereby reducing the testing cost.
[0061] In addition, the cloud-based testing process provides better collaboration and communication, and achieves higher reliability and stability. The testing system built by the cloud platform 120 can strengthen the 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 by the cloud platform 120 can eliminate the differences in the local testing environment, 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, the UI test can also be arranged locally, and the embodiments of the present disclosure are not limited to this.
[0062] If the test script 110 fails to run 121 on the cloud platform 120, the test script repair system 122 according to an embodiment of the present disclosure deployed in the cloud platform 120 repairs the test script 110. According to an embodiment of the present disclosure, if the test script repair system 122 cannot repair the test script 110, it may indicate that the repair of the test script 110 has failed 131. This is, for example, due to failure to find a solution for the test script 110, or the solution found for the test script 110 is not applicable, etc. In the following, this process will be described in further detail.
[0063] 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.), it can indicate that the repair of the test script 110 has failed 131. For example, a message or an 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, after clicking a button, a correct window pops up, etc.), it can indicate that the repair of the test script 110 is successful 132. For example, a message or an email can be sent to notify the test engineer that the repair is successful. Hereinafter, the automated test script repair process according to an embodiment of the present disclosure will be further described in detail.
[0064] like Figure 1 As shown in , the execution and repair of the test script are performed in the cloud, so that hardware resources can be saved, the repair efficiency can be improved, 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, and can also be performed in a distributed manner in the cloud and locally, and the embodiments of the present disclosure are not limited to this. Figure 1 A schematic diagram of an example environment 100 in which methods and / or processes according to embodiments of the present disclosure may be implemented is described below. Figure 2 A flowchart of a method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure is described.
[0065] 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 cost and time cost of test engineers maintaining UI test scripts, reduce 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. In the following, the automated test script repair process according to an embodiment of the present disclosure will be further described in 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 respectively.
[0066] 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. In the following, 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 form of expression 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.
[0067] 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 by JavaScript, TypeScript or other scripting languages. It should be understood that the description of the capture, control and access of the DOM tree is schematically shown for the purpose of ease of understanding, and the embodiments of the present disclosure are not limited to the above examples.
[0068] At box 220, a difference DOM tree between the failed DOM tree and the corresponding baseline DOM tree is determined. According to an embodiment of the present disclosure, the failed DOM tree obtained at box 210 can be compared with the corresponding baseline DOM tree from the 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 a DOM tree of a UI page captured when the last or previous script ran successfully, or it can be a manually created and defined DOM tree, and the embodiment of the present disclosure is not limited to this. In the following, the difference DOM tree determination process according to an embodiment of the present disclosure will be further described in detail.
[0069] At box 230, based on the difference DOM tree and the failure error log during the running 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, and the generated log can include information related to the error in the UI test process, such as element positioning failure, page loading 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 test case name and description, test execution time and environment, and test case execution path (such as page jump, input operation, click event, etc.).
[0070] In some embodiments, various information in the failure error log can be recorded through a logging library (such as a logging library in Python, Log4j in Java, etc.). In other embodiments, this information can also be recorded through a logging function provided by a test framework or test tool (such as Selenium WebDriver, Appium, etc.). The description of generating a failure error log is schematically shown here for the purpose of facilitating understanding, and the embodiments of the present disclosure are not limited to the above examples.
[0071] Based on the difference DOM tree determined at 220 and the log recording the UI test process, the test script 110 may be repaired to generate a repaired test script 123. Hereinafter, the repaired test script 123 may also be referred to as a 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. Figure 2 A flowchart of a method 200 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure is described. Figure 3 A flowchart of a method 200 for repairing a test script for a user interface according to an embodiment of the present disclosure is described.
[0072] Figure 3 An example process 300 of automated test script repair according to an embodiment of the present disclosure is illustrated. Figure 3 The example process 300 schematically shown in FIG. Figure 1 The test script shown in the repair system 122 is executed, and Figure 3 The configuration of the test script repair system 122 is also schematically shown in FIG. Figure 3 As shown in , the test script repair system 122 according to an embodiment of the present disclosure may include a database 320 of a baseline DOM tree, a comparison module 330, an analysis module 340, a prediction module 350, an enhancement module 360, and a repair module 370. In addition, Figure 3 Also shown are execution modules 310 and 310' for executing the UI test script, and a feedback module 380 for indicating whether the repair of the UI test script is successful. It should be understood that Figure 3 The various components shown in the figure may be coupled to each other (eg, via wires or networks), and Figure 3 The architecture shown in the figure may also include more or fewer components. It should also be noted that these components may be deployed in the cloud for execution, may be deployed locally, or may be distributed and respectively deployed in the cloud and locally for execution.
[0073] According to an embodiment of the present disclosure, the execution module 310 may be configured to execute a test script 110 for a user interface. A UI test script is an automated test script for testing a UI page. The UI test script may simulate various operations performed by a user on an application or website, such as clicking a button, inputting text, selecting an option, etc. By running the UI test script, errors and defects in the UI page may be automatically detected, and the correctness and consistency of the UI may 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 may be determined that the test script 110 for the user interface fails to run. If the response of the user interface is the same as expected (such as, a correct window pops up after clicking a button, etc.), it may be determined that the test script 110 for the user interface runs successfully. In other words, based on the execution result of the execution module 310, it may be determined whether the UI test script runs successfully. The execution module 310 according to an embodiment of the present disclosure may be any execution machine capable of executing a UI test script, and the embodiment of the present disclosure does not limit this.
[0074] According to an embodiment of the present disclosure, in response to the failure of the test script 110 of the user interface to run, the failure DOM tree of the user interface when the test script 110 fails to run can be obtained. In some embodiments, the failure DOM tree can be obtained by parsing the HTML / XML document of the user interface when the test script 110 fails to run. At the same time, the corresponding baseline DOM tree can be obtained from the database 320 of the baseline DOM tree, and the 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 runs successfully last time or previously, or it can be a manually created and defined DOM tree, etc. The baseline DOM tree to be used for comparison can be determined according to actual needs, for example, it can be determined according to the actual test purpose or test scenario, etc. After receiving the failure DOM tree of the user interface when the test script 110 fails to run 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 is a difference between the failure DOM tree and the corresponding baseline DOM tree, the difference DOM tree between the failure DOM tree and the corresponding baseline DOM tree can be determined. In the following, the comparison process of the comparison module 330 will be further described in detail.
[0075] According to an embodiment of the present disclosure, while 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 to run from the comparison module 330, the analysis module 340 can obtain the failure error log during the running of the test script 110, and the failure error log includes information related to the error in the running process of the test script 110, such as element positioning failure, page loading timeout, assertion failure, etc. As described above, the log recording the UI test process includes other information (such as test case name and description, test execution time and environment, test case execution path, etc.) in addition to the 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 the failure error information associated with the error in the running process 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 causes the test script 110 to fail to run. The analysis module 340 may also be configured to associate the extracted failure error information with the determined failure error node.
[0076] As described above, the comparison module 330 may be configured to compare the failure DOM tree with the corresponding baseline DOM tree. In some embodiments, if there is no difference between the failure DOM tree and the corresponding baseline DOM tree, the analysis module 340 may be configured to obtain a failure error log during the execution of the test script 110, and may extract failure error information from the failure error log to obtain failure error information associated with an error during the execution of the test script 110. In the following, the analysis process of the analysis module 340 will be described in further detail.
[0077] According to an embodiment of the present disclosure, after receiving the failed DOM node causing the test script 110 for the user interface to fail to run in the difference DOM tree from the analysis module 340, and the failure error information extracted from the failure error log recording the running process of the test script 110, the prediction module 350 may be configured to match a solution for the test script 110. In some embodiments, the prediction module 350 may be configured to determine whether there is a solution for the test script 110 from the knowledge base for repairing UI test scripts based on the failed DOM node and the failure error information associated with each other. If a solution for the test script 110 is not found from the knowledge base for repairing UI test scripts based on the failed DOM node and the failure error information associated with each other, or the found solution is not applicable, the feedback module 380 may be configured to indicate the failure to repair the test script 110, for example, the feedback module 380 may be configured to send a message or an email to notify the test engineer of the failure to repair the test script 110. In addition, in response to the failure to repair the test script 110, the enhancement module 360 can enhance the knowledge base for repairing the UI test script, for example, adding a solution corresponding to the situation in the knowledge base so as to solve the same or similar situation later. If a solution for the test script 110 is found from the knowledge base for repairing the UI test script based on the failed DOM nodes and the failed error information associated with each other, the repair module 370 can be configured to perform the repair of the test script 110 based on the found solution to obtain the repaired test script 123. In some embodiments, if the execution of the repair module 370 fails, the execution function associated with the execution can be checked. If it is determined that the execution function is normal, it can be determined that the repair of the test script 110 has failed. If it is determined that the execution function is abnormal, another execution machine is used to re-execute the repair of the test script 110. It can thus be determined whether the repair failure of the test script 110 is caused by a problem with the execution hardware. The repair module 370 according to an embodiment of the present disclosure can be any failed case repair execution machine that can repair a failed case script project, and can be configured to repair incorrect syntax, logical errors, element positioning errors, etc., and the embodiments of the present disclosure are not limited to this.
[0078] In some embodiments, if there is no difference between the failed DOM tree and the corresponding baseline DOM tree, the prediction module 350 can be configured to determine whether there is a solution for the test script 110 from the knowledge base for repairing the UI test script based on the failure error information. If no solution for the test script 110 is found from the knowledge base for repairing the UI test script based on the failure error information, or the found solution is not applicable, the feedback module 380 can be configured to indicate that the repair of the test script 110 has failed. In addition, in response to the failure to repair the test script 110, the enhancement module 360 can enhance the knowledge base for repairing the UI test script so as to solve the same or similar situation later. If a solution for the test script 110 is found from the knowledge base for repairing the UI test script based on the failure error information, the repair module 370 can be configured to repair the test script 110 based on the found solution to obtain a repaired test script 123. In the following, the prediction process of the prediction module 350 will be described in further detail.
[0079] According to an embodiment of the present disclosure, the execution module 310' may be configured to execute a repair test script 123 for a user interface. If the repair test script 123 fails to run, it may be determined that the repair of the test script 110 has failed. The feedback module 380 may be configured to indicate that the repair of the test script 110 has failed, for example, the feedback module 380 may be configured to send a message or an email to notify the test engineer of the failure to repair the test script 110. In addition, in response to the failure to repair the test script 110, the enhancement module 360 may enhance the knowledge base for repairing the UI test script, for example, by adding a solution corresponding to the situation in the knowledge base so as to solve the same or similar situation later. If the repair test script 123 runs successfully, it may be determined that the repair of the test script 110 has been successful. The feedback module 380 may be configured to indicate that the repair of the test script 110 has been successful, for example, the feedback module 380 may be configured to send a message or an email to notify the test engineer of the success of the repair of the test script 110. 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 runs successfully (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.
[0080] 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, thereby determining whether the repair test script 123 is successfully executed. Figure 3The architecture shown in FIG. 1 includes two execution modules, namely, execution modules 310 and 310′. It should be noted that the execution modules 310 and 310′ may be the same execution module or different execution modules, and the embodiments of the present disclosure do not limit this. Figure 4A and Figure 4B The comparison process between the failed DOM tree and the corresponding baseline DOM tree according to an embodiment of the present disclosure is further described in detail.
[0081] Figure 4A An example comparison process 400A between a failed DOM tree and a corresponding baseline DOM tree according to an embodiment of the present disclosure is illustrated. The example comparison process 400A may be performed by Figure 3 The comparison module 330 shown in FIG. 1 is executed, and Figure 4B 400B is a diagram 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. Figure 4A As shown in , 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 runs successfully. After determining that the test script 110 fails to run (such as, the UI page does not jump, or does not jump to the target UI page, etc.), the failure DOM tree 410 of the user interface when the test script 110 fails to run can be obtained. The process of obtaining the DOM tree has been exemplarily described above, and it will not be repeated here. Figure 4B A failure DOM tree 410 is schematically shown, that is, a DOM tree of the user interface captured when the test script 110 fails to run.
[0082] like Figure 4A As shown in , according to an embodiment of the present disclosure, a corresponding baseline DOM tree 420 can be obtained from a database 320 of baseline DOM trees, and the corresponding baseline DOM tree can be a DOM tree of a UI page captured when the same UI test script or a different UI test script was successfully run last time or previously, or a DOM tree created and defined manually, etc. The baseline DOM tree to be used for comparison can be determined according to actual needs. Figure 4B The corresponding baseline DOM tree 420 is schematically shown.
[0083] like Figure 4A As shown in , 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. Figure 4B The comparison process of the comparison module 330 according to the embodiment of the present disclosure is further described in detail. Figure 4BIn the example, 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 be used as a parent node to further include one or more child nodes (for example, the 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 be used as a parent node to further include one or more child nodes (for example, the node "UI" may include the node "li").
[0084] According to an embodiment of the present disclosure, the failed DOM tree 410 may be compared with the corresponding baseline DOM tree 420 level by level (eg, by a DIFF algorithm, etc.) to determine the difference between them. Figure 4B The difference DOM tree 430 schematically shown in FIG. 4 shows such a difference. The difference DOM tree 430 includes three difference DOM nodes, namely, difference DOM nodes 431, 432 and 434, which indicate the differences between the failed DOM tree 410 and the baseline DOM tree 420. For example, the text node "TextNode newly added" in the baseline DOM tree 420 is changed to the text node "TextNode newly created" in the failed DOM tree, and therefore, the changed text node "TextNode newly created" is highlighted at 433 in the difference DOM tree 430. For example, compared with the baseline DOM tree 420, the node "li" is added in the failed 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 failed 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 by the node "div" in the failed DOM tree. Therefore, the replaced node “div” is highlighted at 432 in the difference DOM tree 430 .
[0085] For the purpose of ease of understanding and convenience of explanation, Figure 4BSchematically 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 the embodiments of the present disclosure are not limited to such node arrangements, and may also include other different node arrangements. The embodiments of the present disclosure are also not limited to the above-mentioned method of determining differences. For example, when it is determined 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. In addition, Figure 4B The DOM nodes in the failed DOM tree 410 that are different from the DOM nodes in the baseline DOM tree 420 are highlighted in the difference DOM tree 430. It should be understood that the DOM nodes in the baseline DOM tree 420 that are different from the DOM nodes in the failed DOM tree 410 can also be highlighted in the difference DOM tree 430. Figure 5A and Figure 5B The failure analysis process according to the embodiment of the present disclosure is further described in detail.
[0086] Figure 5A 4. An example failure analysis process 500A is illustrated when there is a difference between the failure DOM tree 410 and the corresponding baseline DOM tree 420 according to an embodiment of the present disclosure. The example failure analysis process 500A may be performed by Figure 3 . According to an embodiment of the present disclosure, after receiving the failure error log 501 during the running of the test script 110, the analysis module 340 can be configured to extract the failure error information 503 related to the error when the test script 110 fails to run (such as, element positioning failure, page loading timeout, assertion failure, etc.) 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, so that unnecessary or useless data can be cleaned up, so as to improve the failure analysis efficiency and error data quality, reduce the interference of noise data, and optimize storage space, thereby increasing the accuracy of failure analysis.
[0087] 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 cause 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.
[0088] In some embodiments, the analysis module 340 may 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 may be configured to determine whether the failure error corresponds to a difference DOM node in the difference DOM tree 430 based on the type of the failure error. Figure 4B The example in further explains in detail the process of determining the failed DOM node 502. 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. Figure 4B In the difference DOM tree 430 shown in , the difference DOM node 433 indicates that the text node in the failed DOM tree 410 is "newly created", 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 failed 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 the failed error, the analysis module 340 can determine the difference DOM node as the failed DOM node 502.
[0089] According to an embodiment of the present disclosure, if it is determined that the failure error does not correspond to the difference DOM node in the difference DOM tree 430, the analysis module 340 can be configured to determine whether the DOM nodes within the predetermined threshold range of the difference DOM node in the difference DOM tree 430 correspond to the type of the failure error, such as the parent DOM node and the child DOM node in the next level above the difference DOM node. If it is determined that the DOM nodes within the predetermined threshold range of the difference DOM node in the difference DOM tree 430 correspond to the type of the failure error, the analysis module 340 can determine the DOM nodes within the predetermined threshold range of the difference DOM node in the difference DOM tree 430 as the failed DOM node 502. If it still does not correspond, the range can be expanded to continue searching until it corresponds, or the analysis can be stopped and the repair of the script 110 can be indicated. It should be understood that the example of the DOM nodes within the predetermined threshold range of the difference DOM node in the difference DOM tree 430 described herein is only illustrative, and the DOM nodes within the predetermined threshold range of the difference DOM node can also be upward to the parent DOM node in several levels, and can also be downward to the child node in several levels. The embodiment of the present disclosure is 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 (such as element failure), in addition to the type of the failure error, and the embodiments of the present disclosure are not limited to this.
[0090] Figure 5BAn example failure analysis process 500B is illustrated when there is no difference between the failure DOM tree and the corresponding baseline DOM 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 the difference DOM tree 430 between the failure DOM tree 410 and the baseline DOM tree 420. When it is determined that there is no difference between the failure DOM tree 410 and the corresponding baseline DOM tree 420 (i.e., the DOM tree 410 is the same as the corresponding baseline DOM tree 420), the analysis module 340 can be configured to extract the failure error information 503 related to the error when the test script 110 fails 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 clean up 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 the fact that the DOM tree 410 and the corresponding baseline DOM tree 420 are the same, it may also be due to other reasons (such as hardware reasons or network reasons, etc.) that the difference between the DOM tree 410 and the corresponding baseline DOM tree 420 cannot be identified. 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 tests, when the difference between the current failure situation and the baseline control cannot be determined, 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 the prior repair knowledge, thereby improving the repair quality. In the following, this process will be further described in detail.
[0091] Fig. 6AAn example process 600A of predicting a repair solution when there is a difference between a failed DOM tree 410 and a corresponding baseline DOM tree 420 according to an embodiment of the present disclosure is illustrated. According to an embodiment of the present disclosure, after receiving a failed DOM node 502 causing a test script 110 for a user interface to fail to run in a difference DOM tree 430 from an analysis module 340, and a failure error message 503 extracted from a failure error log recording the running process 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 there is a repair solution 601 for the test script 110 from a knowledge base for repairing UI test scripts based on the failed DOM node 502 and the failure error message 503 associated with each other. 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 a plurality of processing solutions for repairing the test script 110, each of which may include a plurality of repair solutions for repairing the test script 110. Behavior tree is a graphical tool for describing complex system behaviors. It can decompose the behavior of a system into a set of simple behaviors, and then combine these behaviors into a hierarchical structure to better understand and manage the behavior of the system. In UI testing, using behavior tree as a priori knowledge base enables a better understanding of the various behaviors of the application and establishes a knowledge framework that is easy to maintain and expand.
[0092] According to an embodiment of the present disclosure, the prediction module 350 may be configured to find a repair solution 601 for the test script 110 from the behavior tree 610 for repairing the UI test script based on the failed DOM node 502 and the failed error message 503 associated with each other. If the prediction module 350 fails to find a repair solution for the test script 110 from the behavior tree 610 based on the failed DOM node 502 and the failed error message 503 associated with each other, or the found repair solution is not applicable, it may indicate that the repair of the test script 110 has failed, for example, a message or email may be sent to notify the test engineer of the failure to repair the test script 110. In addition, in response to the failure to repair the test script 110, the enhancement module 360 may enhance the behavior tree 610, for example, add a repair solution corresponding to the situation in the behavior tree 610, so that the same or similar situation may be repaired later. 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 failed error information 503 , the test script 110 may be repaired based on the found repair solution 601 to obtain a repaired test script 123 .
[0093] Figure 6BAn example process 600B of predicting a repair solution when there is no difference between the failed DOM tree 410 and the corresponding baseline DOM tree 420 according to an embodiment of the present disclosure is illustrated. According to an embodiment of the present disclosure, if there is no difference between the failed DOM tree 410 and the corresponding baseline DOM tree 420, the prediction module 350 may be configured to determine whether there is a repair solution 601 for the test script 110 from the behavior tree 610 for repairing the UI test script based on the failure error information 503. If a repair solution for the test script 110 is not found from the behavior tree 610 for repairing the UI test script based on the failure error information 503, or the repair solution found is not applicable, it may indicate that the repair of the test script 110 has failed. In addition, in response to the failure to repair the test script 110, the enhancement module 360 may enhance the behavior tree 610, for example, add a repair solution corresponding to the situation in the behavior tree 610, so that the repair can be performed when the same or similar situation occurs later. 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 .
[0094] Fig. 7A An example flow 700A of predicting a repair solution when there is a difference between a failed DOM tree 410 and a corresponding baseline DOM tree 420 according to an embodiment of the present disclosure is illustrated. According to an embodiment of the present disclosure, after receiving a failed DOM node 502 in a difference DOM tree 430 that causes a test script 110 for a user interface to fail to run, at block 710, the DOM type of the failed DOM node 502 may be determined. At block 720, it may be determined from a behavior tree 610 for repairing a UI test script whether there is a processing solution corresponding to the DOM type of the failed DOM node 502. If it is “no” at block 720, it may proceed to block 730 to perform an enhancement on the behavior tree 610, such as adding a processing solution corresponding to the DOM type of the failed DOM node 502 in the behavior tree 610. If it is “yes” at block 720, it may proceed to block 740 to determine whether there is a repair solution for the test script 110 based on the failure error information 503 related to the error when the test script 110 fails to run from the behavior tree 610. At block 750, it is determined whether there is a repair solution corresponding to the failure error message 503 in the behavior tree 610. If the answer is “No” at block 750, the process may proceed to block 730 to enhance the behavior tree 610, such as adding a repair solution corresponding to the failure error message 503 in 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.
[0095] Figure 7B An example flow 700B of predicting a repair solution when there is no difference between the failed DOM tree 410 and the corresponding baseline DOM tree 420 according to an embodiment of the present disclosure is illustrated. According to an embodiment of the present disclosure, after receiving the failure error information 503 related to the error when the test script 110 fails to run, at block 740, it is determined from the behavior tree 610 whether there is a repair solution for the test script 110 based on the failure error information 503. At block 750, it is determined whether there is a repair solution corresponding to the failure error information 503 in the behavior tree 610. If the answer is “no” at block 750, it can proceed to block 730 to perform an enhancement on the behavior tree 610, such as adding a repair solution corresponding to the failure error information 503 in the behavior tree 610. If the answer is “yes” at block 750, the repair solution corresponding to the failure error information 503 can be retrieved from the behavior tree 610.
[0096] Fig. 8A 800A is a diagram illustrating a behavior tree 610 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure. At a selection node 801, it can be selected whether a failed DOM tree 410 is the same as a corresponding baseline DOM tree 420. In response to determining that the failed DOM tree 410 is different from the baseline DOM tree 420, it can be selected in parallel to which DOM type the failed DOM node 502 belongs. Fig. 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. Fig. 8A The dashed box in the figure shows the explanation of the logical nodes that appear in the figure. Figure 8B and Figure 8C The behavior tree 610 for repairing the test script 110 for the user interface is described in further detail.
[0097] Figure 8B 800B illustrates an example process of seeking a fix for a test script 110 when a failed DOM tree 410 is different from a baseline DOM tree 420 according to an embodiment of the present disclosure. Figure 8B The block 820 shown in FIG. Fig. 8A, and further description of the processing scheme 1, processing scheme 2, ..., and processing scheme N shown in . By way of example, in response to determining that the DOM type of the failed DOM node 502 is DOM type 1, the failed DOM node 502 can be found, and the failure error information 503 associated with the failed DOM node 502 is selected. Figure 8B , failure error information 1, failure error information 2, ..., failure error information n are schematically shown. For example, in response to determining that failure error information 503 associated with failed DOM node 502 is key information 1, a repair solution for test script 110, namely, repair solution 1, can be determined, and repair solution 1 can be executed on test script 110. Figure 8B The dashed boxes in the figure show the explanation of the logical nodes appearing in the figure.
[0098] Figure 8C 800C illustrates an example process of seeking a fix for the test script 110 when the failed DOM tree 410 is identical to the baseline DOM tree 420 according to an embodiment of the present disclosure. Figure 8C The block 830 shown in FIG. Fig. 8A By way of example, in response to determining that the failure DOM tree 410 is the same as the baseline DOM tree 420, the failure DOM node 502 can be found, and the failure error information 503 associated with the failure DOM node 502 is selected. Figure 8C In the example, failure error information 1*, failure error information 2*, ..., and failure error information n* are schematically shown. For example, in response to determining that failure error information 503 associated with failed DOM node 502 is key information 1*, a repair solution for test script 110, namely, repair solution 1*, can be determined, and repair solution 1* can be executed on test script 110. Figure 8C The dashed boxes in the figure show the explanation of the logical nodes appearing in the figure.
[0099] Fig.8D 800D is another schematic diagram illustrating a behavior tree 610 for repairing a test script 110 for a user interface according to an embodiment of the present disclosure. At a selection node 804, it may be selected whether the failure DOM tree 410 is the same as the corresponding baseline DOM tree 420. In response to determining that the failure DOM tree 410 is different from the baseline DOM tree 420, it may be selected in parallel to which category the failure error information 503 belongs. Fig.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 the failure error information type 1, a processing solution for the test script 110, i.e., processing solution 1, can be determined. In addition, in response to determining that the failure DOM tree 410 is the same as the baseline DOM tree 420, a processing solution for the test script 110, i.e., processing solution *, can be determined. Fig.8D The dashed box in the figure shows the explanation of the logical nodes that appear in the figure. Fig. 8E and Figure 8F The behavior tree 610 for repairing the test script 110 for the user interface is described in further detail.
[0100] Fig. 8E 800E illustrates another example process of seeking a fix for the test script 110 when the failed DOM tree 410 is different from the baseline DOM tree 420 according to an embodiment of the present disclosure. Fig. 8E The block 850 shown in FIG. Fig.8D Further description of the treatment scheme 1, treatment scheme 2, ..., treatment scheme N shown in . Fig. 8E In the example, each type of failure error information corresponds to a repair solution. By way of example, in response to determining that the failure error information 503 belongs to the failure error information type 1, the failure DOM node 502 associated with the failure error information 503 can be found, and the DOM type of the failure DOM node 502 can be selected to which DOM type. For example, in response to determining that the DOM type of the failure DOM node 502 is DOM type 1, a repair solution for the test script 110, namely, repair solution 1, can be determined, and the repair solution 1 can be executed on the test script 110. Fig. 8E The dashed boxes in the figure show the explanation of the logical nodes appearing in the figure.
[0101] Figure 8F 800F illustrates another example process of seeking a fix for the test script 110 when the failed DOM tree 410 is identical to the baseline DOM tree 420 according to an embodiment of the present disclosure. Figure 8F The block 860 shown in FIG. Fig.8D A further depiction of the treatment scheme* shown in . Figure 8F In the example, each type of failure error message corresponds to a repair solution. By way of example, in response to determining that the failure DOM tree 410 is the same as the baseline DOM tree 420, it can be selected which type of failure error message the failure error message 503 belongs to. Figure 8F, schematically shows failure error information type 1, failure error information type 2, ..., failure error information type n. For example, in response to determining that failure error information 503 belongs to failure error information type 1, a failure DOM node 502 associated with failure error information 503 can be found, and repair solution 1* can be executed on test script 110. Figure 8F The dashed boxes in the figure show the explanation of the logical nodes appearing in the figure.
[0102] Fig. 9A FIG. 9 is an example process 900A for enhancing a behavior tree 610 when matching with a behavior tree 610 fails according to the present disclosure. According to an embodiment of the present disclosure, in response to a failure to match with the behavior tree 610, that is, a repair solution for a UI test script cannot be found from the behavior tree 610, at block 910, a target DOM node may be determined. The target DOM node may be the failed DOM node 502, or a difference DOM node in the difference DOM tree 430, or a DOM node within a predetermined threshold range of the difference DOM node in the difference DOM tree 430, and so on. At block 920, it may be determined whether to enhance the target DOM determined at block 910. The determination operation at block 920 may be performed by the test framework in response to a predetermined trigger condition, or may be determined by a test engineer or a tool development engineer. At block 930, it is determined whether enhancement is possible. If the answer at block 930 is “No”, proceed to block 940 to record the unrepairable situation, and avoid the path when designing a test case next time. If “yes” at block 930 , proceed to block 950 to enhance the behavior tree 610 .
[0103] Fig. 9B 900B illustrates an example process of enhancing the behavior tree 610 when the repair test script 123 fails to run according to the present disclosure. At box 920, it can be determined whether to enhance the target DOM determined at box 910. The determination operation at box 920 can be performed by the test framework in response to a predetermined trigger condition, or can be determined by a test engineer or a tool development engineer. At box 930, it is determined whether it can be enhanced. If the answer at box 930 is "No", proceed to box 940 to record this unrepairable situation and avoid this path when designing a test case next time. If the answer at box 930 is "Yes", proceed to box 950 to enhance the behavior tree 610.
[0104] Fig.10 FIG. 1 is a schematic block diagram of an apparatus 1000 for repairing a user interface according to some embodiments of the present disclosure. Fig.10As shown, the device 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 device 1000 can be the same or similar to those specifically described in the above embodiments, and can also be adjusted and changed according to specific circumstances. The device 1000 can be deployed in a distributed manner in multiple nodes, and the acquisition module 1010, the comparison module 1020 and the prediction module 1030 can also be distributed in one or more nodes separately or in combination.
[0105] According to an embodiment of the present disclosure, the acquisition module 1010 is configured to acquire a failed 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. 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 running.
[0106] The embodiment of the present disclosure further provides a computing device 1100, and the node of the embodiment of the present disclosure may include at least one computing device 1100. Fig.11 As shown, 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 through the bus 1102. The computing device 1100 can 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 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11Only one line is used to represent it, but it does not mean that there is only one bus or one type of bus. Bus 1104 may include a path for transmitting information between various components of computing device 1100 (e.g., memory 1106, processor 1104, communication interface 1108). Processor 1104 may include any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP). Memory 1106 may include volatile memory, such as random access memory (RAM). Processor 1104 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD) or solid state drive (SSD). The memory 1106 stores executable program codes, and the processor 1104 executes the executable program codes to respectively implement the methods of the interactive control module acquisition module 1010, the cloud rendering module comparison module 1020, and the material attachment module prediction module 1030 of the aforementioned embodiments of the present disclosure. That is, the memory 1106 may store instructions for the methods and functions in any of the above embodiments. The communication interface 1108 uses a transceiver module such as, but not limited to, a network interface card and a transceiver to implement communication between the computing device 1100 and other devices or communication networks.
[0107] The embodiment of the present disclosure also 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 a 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 a plurality of computing devices 1100, which 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, a laptop, or a smart phone.
[0108] like Fig.12 As shown, the computing device cluster 1200 includes at least one computing device 1100. The memory 1106 in one or more computing devices 1100 in the computing device cluster 1200 may store the same instructions for executing the method and function in any of the above 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 method and function of the embodiment of the present disclosure in any of the above embodiments. In other words, the combination of one or more computing devices 1100 can jointly execute the instructions for the method and function of the embodiment of the present disclosure. It should be noted that the memory 1106 in different computing devices 1100 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions of the apparatus 1100. That is, the instructions stored in the memory 1106 in different computing devices 1100 can implement the functions of one or more modules or sub-modules 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. The network may be a wide area network or a local area network. Fig.13 A possible implementation 1300 is shown. Fig.13 As shown, two computing devices 1100A and 1100B are connected via a network 1310 . Fig.13 The connection mode between the computing device clusters shown may be considered to be that the method of the present application needs to store a large amount of user data and perform intensive real-time or near real-time calculations, so it is considered to hand over part of the functions to the computing device 1100B for execution. It should be understood that Fig.13The functions of the computing device 1100A shown in the figure 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 including instructions, which, when executed on a computer, enables the computer to perform the method and functions of any of the above embodiments.
[0109] The embodiments of the present disclosure further provide a computer-readable storage medium on which computer instructions are stored. When a processor executes the instructions, the processor executes the method and function of any of the above embodiments.
[0110] In general, various embodiments of the present disclosure may be implemented in hardware or dedicated circuits, 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 performed 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 graphical 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 circuits or logic, general purpose hardware or controllers or other computing devices, or some combination thereof.
[0111] 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 a program module, which are executed in a device on a real or virtual processor of the target to perform the process / method as described above with reference to the accompanying drawings. Typically, 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 functions of program modules can be combined or divided between program modules as needed. Machine executable instructions for program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.
[0112] The computer program code for realizing the method of the present disclosure can be written in one or more programming languages. These computer program codes can be provided to the processor of general-purpose computer, special-purpose computer or other programmable data processing device, so that the program code, when being executed by computer or other programmable data processing device, causes the function / operation specified in flow chart and / or block diagram to be implemented. The program code can be executed completely on computer, partly on computer, as independent software package, partly on computer and partly on remote computer or completely on remote computer or server.
[0113] In the context of the present disclosure, computer program codes or related data may be carried by any appropriate 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 propagation signals, such as carrier waves, infrared signals, and the like.
[0114] A computer-readable medium may be any tangible medium containing or storing a program for or related 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.
[0115] In addition, although the operation of the method of the present disclosure is 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 flow chart can change the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution. 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.
[0116] The above descriptions of various implementations of the present disclosure are exemplary, non-exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described implementations. The selection of terms used herein is intended to explain the principles of the implementations, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the various implementations disclosed herein.
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
Cited By
Intelligent test script repairing method based on multi-modal perception and causal inference
CN121919106A
Adaptive contextual test automation using DOM comparison
US12717703B2
