User interface testing exception handling method and apparatus
By detecting and replacing abnormal resource identifiers and icon files in user interface testing, the problem of abnormal resource identifiers in automated testing was solved, achieving the uniqueness of resource identifiers and the flexibility of test scripts, thereby improving testing efficiency and reducing maintenance costs.
Patent Information
- Application Number
- CN202511909681.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-05-26
AI Technical Summary
In existing automated testing, user interface testing is highly dependent on interface consistency. The content, size, and position of icons change frequently, which requires frequent modifications to automated test scripts. Furthermore, existing devices have difficulty handling resource identifier anomalies, affecting testing efficiency.
By acquiring the interface structure information and images of the user interface, abnormal resource identifiers are detected and replaced to ensure the uniqueness of resource identifiers. Furthermore, abnormal icon files are handled through similarity detection and preset replacement strategies, enabling the customization of resource identifiers and the replacement of icon files.
The issue of abnormal resource identifiers has been resolved, ensuring that test scripts are not affected by developers' code naming rules and UI changes, thereby improving testing flexibility and efficiency and reducing maintenance costs.
Smart Images

Figure CN122086749A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technology, specifically to an exception handling method and apparatus for user interface testing. Background Technology
[0002] In the automotive industry, cockpit testing faces challenges such as shortened project cycles, increased module counts, and a large number of test cases. Furthermore, the testing of the central control system in intelligent cockpits involves a significant amount of manual and repetitive testing. While automated testing equipment can reduce such repetitive and simple testing tasks, current automated testing of UI-related content still heavily relies on interface consistency. In actual R&D, the content, size, and position of icons frequently change, a problem that current automated testing cannot handle. This necessitates spending considerable manpower and time modifying scripts related to UI (user interface) changes one by one. This is a serious waste of time, and some personnel may even abandon the use of automated equipment altogether, rendering much of it unusable and failing to achieve its intended effect.
[0003] During actual testing, due to imperfections in the initial development process, testers encountered issues when simulating click events based on resource identifiers. They found that some icons and buttons lacked corresponding resource identifiers, or multiple icons shared the same resource identifier. In such cases, they had to resort to capturing images of the target controls to trigger click events. Furthermore, some test item prefetching results required verification of UI consistency. In such situations, any UI changes, such as alterations to size or aspect ratio, necessitated numerous scripts re-capturing images of the target controls. While current automated equipment supports reducing image similarity to find similar images, the actual effectiveness is poor, frequently resulting in the wrong target image being selected.
[0004] Therefore, there is an urgent need for an exception handling method for user interface testing to solve the problems of the uniqueness of icon resource identifiers and the replacement of icon files in user interfaces. Summary of the Invention
[0005] To address the aforementioned technical problems, this application proposes an exception handling method and apparatus for user interface testing, which can resolve the issue of resource identifier anomalies in user interface testing.
[0006] On one hand, embodiments of this application provide an exception handling method for user interface testing, the method comprising: In response to the target object's identifier acquisition command, the interface structure information and current interface image of the current user interface of the device under test are acquired; the interface structure information includes the position information and original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control; Anomaly detection is performed on the original resource identifier corresponding to each control to determine the original resource identifier with anomalies and the corresponding anomaly type; Based on the aforementioned exception type, the original resource identifier containing the exception is replaced to obtain the replaced resource identifier.
[0007] In an optional implementation, after replacing the original resource identifier containing the exception according to the exception type to obtain the replaced resource identifier, the method further includes: Based on the correspondence between the replaced resource identifier and the original resource identifier that was not replaced, and each control, the resource identifier corresponding to each control is determined; The icon file and resource identifier corresponding to each control are displayed, and the resource identifier corresponding to the target object is processed in response to the identification processing instruction.
[0008] In an optional implementation, after determining the icon file corresponding to each control from the current interface image based on the position information corresponding to each control, the method further includes: A similarity detection process is performed on the icon file corresponding to each control to obtain a similarity detection result set; the similarity detection result set includes the icon similarity between the icon files corresponding to any two controls; The similarity of all icons in the similarity detection result set is compared with a preset similarity threshold in turn, and the similarity of icons that is greater than the preset similarity threshold is regarded as abnormal icon similarity. Obtain the two controls corresponding to the similarity of the abnormal icons as abnormal controls, and use the original resource identifier corresponding to the abnormal controls as the similarity abnormal resource identifier; The similarity-abnormal resource identifier is replaced to obtain a replaced resource identifier, and the replaced resource identifier is used as the resource identifier corresponding to the abnormal control.
[0009] In an optional implementation, the step of performing similarity detection processing on the icon files corresponding to each control to obtain a similarity detection result set includes: The icon file corresponding to each control is resized to obtain the resized icon file for each control. The adjusted icon file corresponding to each control is converted to grayscale to obtain a grayscale icon file for each control. The grayscale icon files corresponding to the control are subjected to brightness similarity detection, contrast similarity detection, and structural similarity detection to obtain the similarity detection result set.
[0010] In an optional implementation, the exception type includes missing original resource identifiers. The step of performing anomaly detection on the original resource identifiers corresponding to each control to determine the anomaly-causing original resource identifiers and their corresponding exception types includes: For each control, an anomaly detection of missing identifiers is performed on the original resource identifier to determine whether there are any abnormal controls with missing original resource identifiers. In the case of an abnormal control with a missing original resource identifier, the exception type corresponding to the abnormal control with a missing original resource identifier is determined to be the missing original resource identifier. The step of replacing the original resource identifier containing the anomaly according to the anomaly type to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the missing original resource identifier; Based on the preset replacement strategy corresponding to the missing original resource identifier, a resource identifier is added to the abnormal control with the missing original resource identifier to obtain the replaced resource identifier.
[0011] In an optional implementation, the exception type includes duplicate original resource identifiers. The step of performing exception detection on the original resource identifiers corresponding to each control to determine the original resource identifiers with exceptions and their corresponding exception types includes: For any two controls in the original resource identifiers corresponding to each control, a duplicate identifier anomaly detection is performed to determine whether there are any abnormal controls with duplicate original resource identifiers. In the case of an exception control with a duplicate original resource identifier, the exception type corresponding to the exception control with the duplicate original resource identifier is determined to be the duplicate original resource identifier. The step of replacing the original resource identifier containing the anomaly according to the anomaly type to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the duplicate of the original resource identifier; Based on the preset replacement strategy corresponding to the duplicate original resource identifier, the original resource identifier of the abnormal control with missing original resource identifier is replaced to obtain the replaced resource identifier.
[0012] In an optional implementation, displaying the icon file and resource identifier corresponding to each control, in response to an identifier processing instruction for a target object, and processing the resource identifier corresponding to the identifier processing instruction, includes: Based on the location information, determine the correspondence between the icon file corresponding to each control and the resource identifier corresponding to each control; Based on the correspondence, the icon file corresponding to each control and the resource identifier corresponding to each control are displayed so that the target object can recognize the replaced resource identifier and the control corresponding to the replaced resource identifier; In response to the identification processing instruction issued by the target object, the identification processing instruction is parsed and processed to process the resource identifier corresponding to the identification processing instruction.
[0013] In an optional implementation, the method further includes: In response to the icon file replacement instruction, the icon file to be replaced and the resource identifier corresponding to the icon file to be replaced are parsed from the icon file replacement instruction, and the resource identifier corresponding to the icon file to be replaced is used as the target resource identifier. Obtain the historical icon file corresponding to the target resource identifier; The historical icon file is used to replace the icon file to be replaced, thereby completing the icon file replacement instruction.
[0014] In an optional implementation, after obtaining the interface structure information and current interface image of the current user interface of the device under test, the method further includes: The interface structure information is parsed to obtain the position information and original resource identifiers corresponding to each control. Based on the position information corresponding to each control, the icon file corresponding to each control is determined from the current interface image.
[0015] On the other hand, embodiments of this application also provide an exception handling apparatus for user interface testing, the apparatus comprising: The acquisition module is used to acquire the interface structure information and the current interface image of the current user interface of the device under test in response to the target object identifier acquisition command; the interface structure information includes the position information and the original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control; An anomaly detection module is used to perform anomaly detection on the original resource identifier corresponding to each control, so as to determine the original resource identifier with anomalies and the corresponding anomaly type. An exception replacement module is used to replace the original resource identifier that has an exception based on a preset identification strategy and the exception type, so as to obtain a replaced resource identifier; the preset identification strategy includes a preset exception type and a preset replacement strategy corresponding to the preset exception type.
[0016] On the other hand, embodiments of this application also provide an electronic device, which includes a processor and a memory. The memory stores at least one instruction or at least one program. The at least one instruction or at least one program is loaded and executed by the processor to implement an exception handling method for a user interface test as described above.
[0017] On the other hand, embodiments of this application also provide a computer-readable storage medium storing at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded and executed by a processor to implement an exception handling method for a user interface test as described above.
[0018] On the other hand, embodiments of this application also provide a computer program product, which, when executed by a processor, implements an exception handling method for user interface testing as described above.
[0019] This application provides an exception handling method and apparatus for user interface testing, applied in the field of automated testing technology. The method includes: responding to a target object identification acquisition instruction, acquiring the interface structure information and current interface image of the current user interface of the device under test; the interface structure information includes the position information and original resource identifiers of each control in the current user interface; the current interface image includes the icon file corresponding to each control; performing exception detection on the original resource identifiers corresponding to each control to determine the original resource identifiers with exceptions and their corresponding exception types; and replacing the original resource identifiers with exceptions according to the exception types to obtain the replaced resource identifiers. This method can solve the problem of user interface resource identifier exceptions, ensuring the uniqueness of resource identifiers, and freeing test scripts from the influence of developers' code naming rules and UI changes. It allows for easy integration through a simple and easy-to-understand human-computer interaction interface, reducing the maintenance cost of automated testing. This effectively meets the testing needs of users in different scenarios, greatly enhances testing flexibility, saves testers time maintaining automated test scripts, significantly reduces the time spent on this test item, and improves work efficiency. Attached Figure Description
[0020] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the application environment for an exception handling method for user interface testing provided in an embodiment of this application.
[0022] Figure 2 This is a flowchart illustrating an exception handling method for user interface testing provided in an embodiment of this application.
[0023] Figure 3 This is a flowchart illustrating a method for handling icon file anomalies provided in an embodiment of this application.
[0024] Figure 4 This is a flowchart illustrating a method for detecting the similarity of icon files provided in an embodiment of this application.
[0025] Figure 5 This is a schematic diagram of a human-computer interaction interface of an exception handling system for a user interface provided in an embodiment of this application.
[0026] Figure 6 This is a schematic diagram of another human-computer interaction interface of an exception handling system for a user interface provided in an embodiment of this application.
[0027] Figure 7 This is a schematic diagram illustrating the process of obtaining and parsing resource identifiers and icon files provided in an embodiment of this application.
[0028] Figure 8 This is a structural block diagram of a data annotation device provided in an embodiment of this application.
[0029] Figure 9 This is a hardware structure block diagram of a server for an exception handling method for user interface testing provided in an embodiment of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0031] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of the embodiments of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the present application described herein can be implemented in orders other than those illustrated or described herein. Thus, features defined with "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments, unless otherwise stated, "a plurality of" means two or more. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices.
[0032] The following describes an application provided by an embodiment of this application that allows for the customization of resource identifiers and the replacement of control icon files through an integrated human-computer interaction interface. Figure 1 This is a schematic diagram illustrating the structure of an exception handling system for user interface testing provided in an embodiment of this application. Exemplarily, this exception handling system is installed on a host computer as a control or application. The host computer refers to a computer system used to control and monitor slave computers or other terminal devices, typically used in fields such as automation control, data acquisition and processing, and remote monitoring. Exemplarily, in this embodiment, the host computer is used to connect to the device under test, thereby enabling functions such as sending control commands to the device under test, collecting data from the device under test, and performing automated testing. Exemplarily, the host computer can be a terminal device, such as a computer.
[0033] It should be noted that the exception handling system for user interface testing provided in this application embodiment will not change the internal code or internal files of the device under test during processing or operation, and can process and display abnormal resource identifiers in the host computer.
[0034] Specifically, Figure 1 This is a schematic diagram illustrating the application environment of an exception handling method for user interface testing provided in an embodiment of this application. Figure 1 As shown, the system includes the following modules: The resource identifier acquisition module is used to obtain the resource identifiers of each control in the device under test after the host computer and the device under test are connected. At this time, the resource identifiers exist in an Extensible Markup Language (XML) file and are in a state of unparsed.
[0035] The icon file acquisition module is used to obtain the icon files of each control in the device under test. At this time, the icon files exist in the current interface image and are in a state of pending parsing.
[0036] The parsing module is used to parse and process resource identifiers and icon files.
[0037] The anomaly detection and replacement module is used to detect anomalies in resource identifiers and icon files, and to perform preliminary system corrections on abnormal items according to a preset replacement strategy.
[0038] The display and human-computer interaction module is used to display the icon files and corresponding resource identifiers of each control in the current user interface of the device under test; and to display human-computer interaction functions and to receive user control commands, including but not limited to acquisition commands, resource identifier modification commands, icon modification commands, etc.
[0039] This program acts as a processing relay station between an automated test program and the cockpit device under test. It does not change the resource ID in the internal code of the smart cockpit device under test, and provides the automated test script with a resource library of unique and missing resource IDs.
[0040] The following describes an exception handling method for user interface testing provided by an embodiment of this application. Figure 2 This is a flowchart illustrating an exception handling method for user interface testing provided in this application. This specification provides the operational steps of the method as described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only execution order. In actual system or server product execution, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as shown in the embodiments or drawings... Figure 2 As shown, the method can be applied to a server / host computer corresponding to an in-vehicle system, and the method includes: S1: In response to the target object identification acquisition command, acquire the interface structure information and current interface image of the current user interface of the device under test; the interface structure information includes the position information and original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control.
[0041] The method provided in this application is applicable to automated testing technology for automotive cabins.
[0042] In this embodiment, the target object refers to the user, i.e., the tester. The identifier acquisition instruction refers to the instruction to obtain the resource identifier and icon file of the current user interface from the device under test. The device under test can be a car cockpit, including but not limited to a smart cockpit. The user interface (UI) is the medium through which a user interacts with a product, service, or system, while controls are elements in the user interface used for interaction, allowing users to input information, make selections, or perform operations. The interface structure information includes information about each control in the current user interface, including the position information corresponding to each control and the original resource identifier. The position information refers to the position of the control in the current user interface, which can be represented by coordinates. A resource identifier (Resource ID) is a string or code used to uniquely identify and locate resources in software, systems, or networks; common forms include URLs, URIs, file paths, control IDs, etc. The original resource identifier refers to the existing resource identifier in the device under test. The current interface image refers to an image of the current user interface at the current moment, which can be a screenshot. It should be noted that the current interface image and interface structure information are acquired synchronously to ensure their consistency.
[0043] Specifically, after establishing a connection between the host computer and the device under test, the UIAutomator tool built into the Android system can be used to obtain the interface structure information. Optionally, the connection between the host computer and the device under test can be established using the adb debugging tool, and the interface structure information can be in an Extensible Markup Language (XML) file.
[0044] For example, in Python, this can be achieved using the `subprocess.run` tool, such as... Figure 7 As shown. Figure 7 As shown, the current user interface can be saved as an XML file using the above tools and pulled from the device (i.e., the device under test) to the local current directory (i.e., the file storage directory corresponding to the exception handling system for user interface testing in the host computer).
[0045] Optionally, the identifier acquisition command can be implemented in the above-mentioned user interface test exception handling system through voice interaction, function key interaction selection, or other methods.
[0046] S3: Perform anomaly detection on the original resource identifier corresponding to each control to determine the original resource identifier with anomalies and the corresponding anomaly type.
[0047] In this embodiment of the application, the exception type refers to the exception classification corresponding to the specific reason of the original resource identifier of the control. By performing exception detection on the original resource identifier of each control, it is possible to identify whether there is an abnormal original resource identifier in the current user interface obtained from the device under test. If there is, according to the exception reason of the abnormal original resource identifier, the exception type analysis is performed on the exception reason of the abnormal original resource identifier to obtain the exception type corresponding to the abnormal original resource identifier.
[0048] Optionally, the exception type includes, but is not limited to, the original resource identifier. S5: Based on the anomaly type, replace the original resource identifier that has the anomaly to obtain the replaced resource identifier.
[0049] In this embodiment, the replacement process refers to replacing the original resource identifier of the exception to ensure that the resource identifier of each control in the current user interface conforms to the principle of uniqueness. The specific replacement method is determined according to the exception type.
[0050] It should be noted that the replacement process is performed in the user interface testing exception handling system provided in this application embodiment, and does not modify the original files in the device under test. That is, after obtaining the interface structure information of the current user interface in step S1 above, it is saved in the user interface testing exception handling system, and subsequent processing is performed in the user interface testing exception handling system without modifying the original files (i.e., the files corresponding to the current user interface structure in the device under test). In this way, a user interface exception testing and handling system can be integrated into the host computer, so that the resource identifiers of exceptions can be modified. This allows the test scripts of the device under test to be unaffected by the naming rules of the resource identifiers of controls set by the developers, achieving control over the uniqueness of resource identifiers. This system can well meet the testing needs of users in different scenarios, greatly enhances testing flexibility, saves testers the time to maintain automated test scripts, significantly reduces the time spent on this test item, and improves work efficiency.
[0051] In an optional implementation, after step S5 above, the method further includes: S7: Based on the correspondence between the replaced resource identifier and the original resource identifier that was not replaced, and each control, determine the resource identifier corresponding to each control.
[0052] In this embodiment of the application, the resource identifier corresponding to each control is the current resource identifier of each control. That is, in the case of an abnormal original resource identifier, the replaced resource identifier is used as the current resource identifier of the control corresponding to the abnormal original resource identifier, while the normal original resource identifier is directly used as the current resource identifier of the control.
[0053] S9: Display the icon file corresponding to each control and the resource identifier corresponding to each control, and process the resource identifier corresponding to the identifier processing instruction in response to the target object's identifier processing instruction.
[0054] In this embodiment, upon obtaining the resource identifier corresponding to each control, the resource identifier and icon file corresponding to each control are displayed to the tester on the human-computer interaction screen of the host computer, so that the target object can identify the aforementioned abnormal original resource identifier and the control corresponding to the abnormal resource identifier. The target object's identifier processing instruction refers to the resource identifier processing instruction issued by the target object, which may include a resource identifier modification instruction. After processing the resource identifier according to the identifier processing instruction, the self-editing function of the resource identifier can be realized.
[0055] In an optional implementation, displaying the icon file and resource identifier corresponding to each control, in response to an identifier processing instruction for a target object, and processing the resource identifier corresponding to the identifier processing instruction, includes: S91: Based on the location information, determine the correspondence between the icon file corresponding to each control and the resource identifier corresponding to each control; S93: Based on the correspondence, display the icon file corresponding to each control and the resource identifier corresponding to each control, so that the target object can recognize the replaced resource identifier and the control corresponding to the replaced resource identifier; S95: In response to the identification processing instruction issued by the target object, the identification processing instruction is parsed and processed to process the resource identifier corresponding to the identification processing instruction.
[0056] In step S91 above, to ensure the correct correspondence between the icon files and resource identifiers of the controls, matching is performed based on location information to obtain the correspondence between the icon files and resource identifiers of each control. This correspondence is then displayed on the human-computer interaction interface, thus visualizing the resource identifiers. Users can then identify any abnormal resource identifiers based on these identifiers. Since the replaced resource identifiers are replaced or named according to rules set by the testers, the target object can identify the replaced resource identifiers and the controls corresponding to them. In practice, custom resource identifiers are supported; the target object can issue an identifier processing command, which the system automatically identifies and parses, allowing modification of the resource identifier corresponding to the command. Optionally, the target object can issue an identifier processing command for any resource identifier, not just abnormal ones. This reduces the difficulty of modifying and debugging abnormal resource identifiers, and the test scripts are no longer affected by the developers' code naming rules and UI changes. Integration can be easily achieved through a simple and easy-to-understand human-computer interaction interface, reducing the maintenance cost of automated testing and shortening the test cycle, making the testing work more flexible and convenient.
[0057] In an optional implementation, this application also provides a method for handling icon file anomalies, such as... Figure 3 As shown, after step S1 above, that is, after determining the icon file corresponding to each control from the current interface image based on the position information corresponding to each control, the method further includes steps S201-S207: S201: Perform similarity detection processing on the icon file corresponding to each control to obtain a similarity detection result set; the similarity detection result set includes the icon similarity between the icon files corresponding to any two controls.
[0058] In this embodiment of the application, in order to better distinguish abnormal controls with high or completely identical icon files, similarity detection processing is performed on the icon files corresponding to the controls to obtain the icon similarity between the icon files corresponding to each two spaces, thereby obtaining a similarity detection result set.
[0059] In an optional implementation, this application also provides a method for detecting the similarity of icon files, such as... Figure 4 As shown, the similarity detection process performed on the icon files corresponding to each control to obtain a similarity detection result set includes steps S301-S305: S301: Adjust the size of the icon file corresponding to each control to obtain the adjusted icon file for each control; S303: Perform grayscale conversion on the adjusted icon file corresponding to each control to obtain a grayscale icon file corresponding to each control; S305: Perform brightness similarity detection, contrast similarity detection, and structural similarity detection on the grayscale icon file corresponding to the control to obtain the similarity detection result set.
[0060] In this embodiment, the icon file corresponding to each control is first resized to obtain an adjusted icon file for each control, ensuring that the size of the adjusted icon file for each control is completely consistent. The specific size of the adjusted icon file can be determined according to actual testing requirements.
[0061] Alternatively, in Python, for example, you can use the cv2.resize function to resize images of different sizes to the same size.
[0062] In step S303 above, the grayscale conversion process can replace each icon file with a grayscale image, thereby reducing the amount of color processing during similarity detection.
[0063] Optionally, using Python as an example, the COLOR_BGR2GRAY function can be used to convert the adjusted icon file corresponding to each control into a grayscale image.
[0064] In step S305 above, similarity detection is performed from three perspectives: brightness, contrast, and structure. First, the similarity detection results for brightness, contrast, and structure are obtained respectively. Then, based on the weights corresponding to the brightness, contrast, and structure similarity detection results, the similarity between the icon files of the two controls is calculated.
[0065] Optionally, similarity can be calculated as follows: Assuming the brightness similarity detection result is A, the contrast similarity detection result is B, and the structural similarity detection result is C, with corresponding weights a, b, and c, then the similarity detection result = A*a + B*b + C*c. Alternatively, similarity can also be calculated as follows: Similarity detection result = A a +B b +C c In the above formula, a, b, and c can be equal or unequal, depending on the actual needs.
[0066] Alternatively, in Python, for example, the Structural Similarity (SSIM) function can be used to calculate similarity.
[0067] S203: Compare the similarity of all icons in the similarity detection result set with a preset similarity threshold in turn, and take the icon similarity that is greater than the preset similarity threshold as abnormal icon similarity; S205: Obtain the two controls corresponding to the similarity of the abnormal icons as abnormal controls, and use the original resource identifier corresponding to the abnormal controls as the similarity abnormal resource identifier. S207: Replace the similarity-abnormal resource identifier to obtain the replaced resource identifier, and use the replaced resource identifier as the resource identifier corresponding to the abnormal control.
[0068] In this embodiment of the application, the similarity of each icon in the similarity detection result set is compared with a preset similarity threshold in turn. Icons with similarity greater than the preset similarity threshold are regarded as abnormal icon similarities. This is because when the icon similarity is greater than the preset similarity threshold, it means that the icon files corresponding to the two controls are very similar or completely identical.
[0069] In step S205 above, the two controls corresponding to the abnormal icon similarity are identified as abnormal controls, and the original resource identifiers corresponding to the abnormal controls are used as similarity abnormal resource identifiers. At this time, the abnormal controls can also be called icon abnormal controls.
[0070] In step S207 above, the resource identifier of the similarity anomaly is replaced to distinguish the two controls, and the replaced resource identifier is used as the resource identifier corresponding to the abnormal control for display in step S5 above.
[0071] Optionally, step S205 further includes: performing a uniqueness check on the original resource identifier corresponding to the abnormal control. If the two original resource identifiers are inconsistent, step S207 can be skipped, and the abnormal resource identifier can be directly used as the resource identifier corresponding to the abnormal control. If the two original resource identifiers are consistent, then step S207 is executed.
[0072] Optionally, the replacement of resource identifiers with abnormal similarity can be handled by the system automatically distinguishing them by adding an incrementing sequence number to the original resource identifier, such as... Figure 5 As shown, Figure 5 A schematic diagram of a human-computer interaction interface for an exception handling system provided in this application embodiment is shown below. Figure 5As shown, Icon 1 and Icon 3 are highly similar, and their original resource identifiers are both Home. After the above steps S201-S205, their resource identifiers are distinguished as Home1 and Home2, thus ensuring that icon files with high similarity are distinguished.
[0073] Optionally, the preset similarity threshold can be any value between 90% and 100.
[0074] This application embodiment detects the similarity of icons, thereby distinguishing the resource identifiers corresponding to icon files with too high similarity, enabling the target object to identify similar controls, thus clarifying the unique identification rules of controls and effectively enhancing the accuracy of control clicks in test scripts.
[0075] In an optional implementation, the anomaly type includes missing original resource identifiers. In step S3 above, the anomaly detection of the original resource identifiers corresponding to each control to determine the anomaly-causing original resource identifiers and their corresponding anomaly types includes: For each control, an anomaly detection of missing identifiers is performed on the original resource identifier to determine whether there are any abnormal controls with missing original resource identifiers; if there are abnormal controls with missing original resource identifiers, the anomaly type corresponding to the abnormal control with missing original resource identifiers is determined to be missing original resource identifiers. In step S5 above, the replacement process for the original resource identifier containing the anomaly, based on the anomaly type, to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the missing original resource identifier; Based on the preset replacement strategy corresponding to the missing original resource identifier, a resource identifier is added to the abnormal control with the missing original resource identifier to obtain the replaced resource identifier.
[0076] In this embodiment of the application, the abnormal types of resource identifiers include missing original resource identifiers. Therefore, in the anomaly detection, it is checked whether the resource identifier of each control is missing, and the control with missing original resource identifiers is identified as an abnormal control with missing original resource identifiers, and the corresponding anomaly type is identified as missing original resource identifiers.
[0077] Optionally, in this embodiment of the application, a preset replacement strategy is pre-set in the exception handling system for user interface testing. The preset replacement strategy is a correspondence between preset exception types and preset replacement strategies. Therefore, when an exception type is determined, the replacement strategy corresponding to the exception type can be obtained from the preset replacement strategy.
[0078] Specifically, when the exception type is missing original resource identifier, the preset replacement strategy corresponding to the missing original resource identifier can be obtained from the preset replacement strategy. Then, based on the preset replacement strategy corresponding to the missing original resource identifier, a resource identifier is added to the exception control with missing original resource identifier to obtain the replaced resource identifier.
[0079] For example, such as Figure 5 As shown, for controls without a resource ID (such as...) Figure 5 The fifth control can be named "unknown" using a preset replacement strategy. During subsequent displays, it will be displayed as "unknown." When a user clicks "unknown," a custom resource ID can be generated based on the control's actual function. Users are reminded that duplicates are not allowed; if a duplicate is found, the input will not be saved. This effectively prevents the automated script from failing to accurately locate the clicked control. If multiple controls lack resource IDs, they can be distinguished by adding a serial number to "unknown" to ensure the uniqueness of the resource identifier.
[0080] In an optional implementation, the exception type includes duplicate original resource identifiers. In step S3 above, the step of performing exception detection on the original resource identifiers corresponding to each control to determine the original resource identifiers with exceptions and the corresponding exception types includes: For any two controls in the original resource identifiers corresponding to each control, a duplicate identifier anomaly detection is performed to determine whether there are any abnormal controls with duplicate original resource identifiers. In the case of an exception control with a duplicate original resource identifier, the exception type corresponding to the exception control with the duplicate original resource identifier is determined to be the duplicate original resource identifier. In step S5 above, the replacement process for the original resource identifier containing the anomaly, based on the anomaly type, to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the duplicate of the original resource identifier; Based on the preset replacement strategy corresponding to the duplicate original resource identifier, the original resource identifier of the abnormal control with missing original resource identifier is replaced to obtain the replaced resource identifier.
[0081] In this embodiment of the application, the abnormal types of resource identifiers include duplicate original resource identifiers. Therefore, in the anomaly detection, it is checked whether the resource identifier of each control is duplicated, and the control with duplicate original resource identifiers is identified as an abnormal control with missing original resource identifiers, and the corresponding anomaly type is identified as duplicate original resource identifier.
[0082] Specifically, when the exception type is missing duplicate resource identifier, the preset replacement strategy corresponding to the missing duplicate resource identifier can be obtained from the preset replacement strategy. Then, based on the preset replacement strategy corresponding to the duplicate original resource identifier, the resource identifier of the exception control with duplicate original resource identifier is modified to obtain the replaced resource identifier.
[0083] In a specific embodiment, for controls with duplicate resource IDs, the preset replacement strategy can use the original resource identifier plus a serial number. For example, if there are two HOME controls, their resource identifiers can be modified to HOME1 and HOME2 respectively. This ensures the uniqueness of resource identifiers. Thus, this embodiment of the application automatically modifies abnormal resource identifiers by defining specific resource identifier modification strategies, thereby ensuring the uniqueness of resource identifiers. This can well meet the testing needs of users in different scenarios, greatly enhance testing flexibility, save testers the time of maintaining automated test scripts, significantly reduce the time spent on this test item, and improve work efficiency.
[0084] In an optional implementation, this application also provides a method for batch replacement of icon files, the method further comprising: S601: In response to the icon file replacement instruction, parse the icon file to be replaced and the resource identifier corresponding to the icon file to be replaced from the icon file replacement instruction, and use the resource identifier corresponding to the icon file to be replaced as the target resource identifier.
[0085] In cockpit testing, the pre-fetched results of some test items need to verify the consistency of the UI. When the UI changes, it is necessary to re-capture the icon file of the target control. This application embodiment achieves a one-click replacement function by adding an icon file replacement command. Specifically, the icon file replacement command is integrated into the exception handling system of the user interface test. It can be issued by the user through human-computer interaction, or it can be issued by the system after recognizing the UI change.
[0086] After receiving an icon file replacement instruction, the system parses the icon file to be replaced and its corresponding resource identifier from the instruction, thus determining the corresponding control. Then, it uses the resource identifier of the icon file to be replaced as the target resource identifier. S603: Obtain the historical icon file corresponding to the target resource identifier; S605: Replace the icon file to be replaced with the historical icon file to complete the icon file replacement instruction.
[0087] In this embodiment, the system can store historical icon files corresponding to each control and represent these historical icon files using resource identifiers. Upon receiving an icon file replacement instruction, the system retrieves the historical icon file corresponding to the target resource identifier from the host computer. Then, the historical icon file is used to replace the icon file to be replaced, thus completing the icon file replacement instruction.
[0088] Optionally, if there are multiple historical icon files, determine the size of each historical icon file, select the historical icon file whose size matches the icon file size in the modified UI, and replace the icon file to be replaced.
[0089] Optional, such as Figure 6 As shown, the function of replacing icon files can be integrated into the content saved in the exception handling system of the user interface test (i.e., the interface for viewing saved content). For example, clicking an icon can replace the original image, where the original image is the historical icon file. Optionally, in Python, the `replace_complete` function can be used to completely replace the old image (i.e., maintain aspect ratio and size). Previously read icon files and resource identifiers are saved in the default / custom path on the host computer. When modification is needed, the saved panel is located, and the icon to be modified is replaced. For example, the program uses the `replace_complete` function in the background to completely replace the old image (i.e., maintain aspect ratio and size) and saves it. For example, `def complete_replace(image1,image2): completely replaces image2 with image1, return image1.copy(): directly returns image1. That is, image1 is the saved historical icon file, and image2 is the icon file to be replaced. In this way, when there are partial changes to the UI, some icon files can be replaced. Specifically, the historical icon files of this icon file can be obtained based on the resource identifier and replaced with one click. This ensures that the test scripts are not affected by UI changes. Integrated processing can be easily achieved through a simple and easy-to-understand human-computer interaction interface, reducing the cost of automated testing and maintenance.
[0090] In an optional implementation, after obtaining the interface structure information and the current interface image of the device under test, the method further includes: parsing the interface structure information to obtain the position information and original resource identifier corresponding to each control; and determining the icon file corresponding to each control from the current interface image based on the position information corresponding to each control.
[0091] In this embodiment, by parsing the interface structure information, the position information and original resource identifier of each control in the current user interface can be obtained. Specifically, the position information and original resource identifier are parsed from the interface structure information stored in the host computer. Then, based on the position information, the current interface image is cropped to obtain the icon file corresponding to each control.
[0092] Optionally, in the Python language, such as Figure 7 As shown, the `window_dump.xml` file is first parsed into a DOM tree (Document Object Model Tree), returning an `ElementTree` object. Specifically, this step includes: retrieving the locally stored XML file corresponding to the interface structure, for example, using the `parse` function of the `xml.etree.ElementTree` module to read and parse the entire `window_dump.xml` file in a tree structure. Then, an `ElementTree` object is returned (usually stored as the variable `tree`). This object internally maintains all information such as parent-child node relationships, tag names, attributes, and text, and can be traversed or queried at any time, but the "entry" node is not yet exposed. If the XML file does not exist or has an incorrect format, a `FileNotFoundError` or `xml.etree.ElementTree.ParseError` will be thrown, so it is often placed in a `try / except` block for exception handling. Then, obtain the root node of the DOM tree (i.e., the Element corresponding to the outermost tag in the XML file). Specifically, this involves calling `getroot()` on the parsed `ElementTree` to obtain an `Element` instance representing the "top-level tag" of the entire XML tree. The `Element` object supports: `tag` (tag name string), `attrib` (attribute dictionary), `text` / `tail` (the tag's own text and the trailing text after the closing tag), etc. After obtaining the root, you can use `root.iter('node')` to traverse all UI nodes, and use `root.findall(". / / node[@text='Login']")` to locate specific controls. Then, you can extract attributes such as `bounds` (boundary box, rectangle coordinates, range rectangle), `resource-id` (resource identifier), and `clickable` (clickable / clickable; in Android UI node attributes, this indicates whether the control can respond to click events) for automated analysis.
[0093] Optionally, in the Python language, such as Figure 7As shown, the location information can be obtained through the target_node.attrib.get function, which retrieves the value with the key 'bounds' from the attribute dictionary of the target node (target_node).
[0094] Optionally, in the Python language, please continue to see Figure 7 You can use fullscreen.png to read the current screen icon, and then crop the original image according to the position information using rectangular areas specified by the four coordinates of left, top, right, and bottom to get a new Image object control_img (control image); the coordinate order is left, top, right, and bottom pixel values, excluding the right / bottom column / row itself (consistent with Python slicing rules).
[0095] Thus, in this embodiment of the application, the icons and resource identifiers of each control can be parsed by pulling the current interface icon and interface result information from the host computer. This allows the resource identifiers and icon files to be displayed or perform other operations according to the rules specified by the tester, laying the foundation for test scripts to be unaffected by the developer's code naming rules and UI changes.
[0096] On the other hand, such as Figure 8 As shown in the figure, this application embodiment also provides an exception handling device for user interface testing, the device comprising: The acquisition module 601 is used to acquire the interface structure information and the current interface image of the current user interface of the device under test in response to the target object identifier acquisition instruction; the interface structure information includes the position information and the original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control; The anomaly detection module 603 is used to perform anomaly detection on the original resource identifier corresponding to each control, so as to determine the original resource identifier with anomalies and the corresponding anomaly type. The exception replacement module 605 is used to replace the original resource identifier that has an exception based on a preset identification strategy and the exception type, so as to obtain the replaced resource identifier; the preset identification strategy includes a preset exception type and a preset replacement strategy corresponding to the preset exception type.
[0097] In an optional implementation, the apparatus further includes: The determination module is used to determine the resource identifier corresponding to each control based on the correspondence between the replaced resource identifier and the original resource identifier that was not replaced, and each control. The exception handling module is used to display the icon file and resource identifier corresponding to each control, and to process the resource identifier corresponding to the target object's identifier processing instruction in response to the identifier processing instruction.
[0098] In an optional implementation, the apparatus further includes: The similarity detection module is used to perform similarity detection processing on the icon files corresponding to each control to obtain a similarity detection result set; the similarity detection result set includes the icon similarity between the icon files corresponding to any two controls; The similarity comparison module is used to compare the similarity of all icons in the similarity detection result set with a preset similarity threshold in turn, and to regard the icon similarity that is greater than the preset similarity threshold as an abnormal icon similarity. The similarity anomaly resource identifier determination module is used to obtain two controls corresponding to the similarity of the anomaly icon as anomaly controls, and to use the original resource identifier corresponding to the anomaly control as the similarity anomaly resource identifier. The resource identifier replacement module is used to replace the similarity-abnormal resource identifier to obtain the replaced resource identifier, and use the replaced resource identifier as the resource identifier corresponding to the abnormal control.
[0099] In an optional implementation, the similarity detection module includes: The size adjustment unit is used to adjust the size of the icon file corresponding to each control to obtain the adjusted icon file for each control. The grayscale conversion unit is used to perform grayscale conversion processing on the adjusted icon file corresponding to each control to obtain a grayscale icon file corresponding to each control. The detection unit is used to perform brightness similarity detection, contrast similarity detection, and structural similarity detection on the grayscale icon file corresponding to the control, and obtain the similarity detection result set.
[0100] In an optional implementation, the anomaly type includes a missing original resource identifier, and the anomaly detection module includes: The missing detection unit is used to perform anomaly detection on the original resource identifier corresponding to each control to determine whether there are any abnormal controls with missing original resource identifiers. The missing identification unit is used to determine the exception type corresponding to the missing original resource identifier as the missing original resource identifier when there is an exception control with a missing original resource identifier. The replacement module includes: The first acquisition unit is used to acquire the preset replacement strategy corresponding to the missing original resource identifier; The first replacement unit is used to add a resource identifier to the abnormal control with a missing original resource identifier based on a preset replacement strategy corresponding to the missing original resource identifier, so as to obtain the replaced resource identifier.
[0101] In an optional implementation, the anomaly type includes duplicate original resource identifiers, and the anomaly detection module includes: The duplicate checking unit is used to perform duplicate detection on any two controls in the original resource identifiers corresponding to each control, so as to determine whether there are any abnormal controls with duplicate original resource identifiers. The duplicate determination unit is used to determine the exception type corresponding to the duplicated original resource identifier as the duplicated original resource identifier when there is an exception control with a duplicated original resource identifier. The replacement module includes: The second acquisition unit is used to acquire the preset replacement strategy corresponding to the duplicate original resource identifier; The second replacement unit is used to replace the original resource identifier of the abnormal control whose original resource identifier is missing, based on the preset replacement strategy corresponding to the original resource identifier, to obtain the replaced resource identifier.
[0102] In one optional implementation, the exception handling module includes: The correspondence determination unit is used to determine the correspondence between the icon file corresponding to each control and the resource identifier corresponding to each control based on the location information; The display unit is used to display the icon file corresponding to each control and the resource identifier corresponding to each control based on the correspondence, so that the target object can recognize the replaced resource identifier and the control corresponding to the replaced resource identifier; The identifier processing instruction response unit is used to respond to the identifier processing instruction issued by the target object, and to parse and process the identifier processing instruction in order to process the resource identifier corresponding to the identifier processing instruction.
[0103] In an optional implementation, the apparatus further includes: An icon file replacement instruction response module is used to respond to an icon file replacement instruction by parsing the icon file to be replaced and the resource identifier corresponding to the icon file to be replaced from the icon file replacement instruction, and using the resource identifier corresponding to the icon file to be replaced as the target resource identifier. The historical file acquisition module is used to acquire the historical icon file corresponding to the target resource identifier; The icon file replacement module is used to replace the icon file to be replaced with the historical icon file to complete the icon file replacement instruction.
[0104] In an optional implementation, the apparatus further includes: The parsing module is used to parse and process the interface structure information to obtain the position information and original resource identifiers corresponding to each control; The icon file determination module is used to determine the icon file corresponding to each control from the current interface image based on the position information corresponding to each control.
[0105] It should be noted that the embodiment of the exception handling device for user interface testing provided in this application is based on the same inventive concept as the above-described embodiment of the exception handling method for user interface testing.
[0106] This application also provides a data annotation electronic device, which includes a processor and a memory. The memory stores at least one instruction or at least one program. The at least one instruction or at least one program is loaded and executed by the processor to implement the exception handling method for user interface testing as provided in any of the above embodiments.
[0107] Embodiments of this application also provide a computer-readable storage medium that can be disposed in a terminal to store at least one instruction or at least one program for implementing an exception handling method for user interface testing as described in the method embodiments. The at least one instruction or at least one program is loaded and executed by a processor to implement the exception handling method for user interface testing as described in the above method embodiments.
[0108] Optionally, in the embodiments of this specification, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0109] The memory described in this specification can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for functions, etc.; the data storage area may store data created based on the use of the device, etc. Furthermore, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0110] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the exception handling method for user interface testing provided in the above-described method embodiments.
[0111] The methods and embodiments provided in this application can be executed on a terminal, computer terminal, server, or similar computing device. Taking running on a server as an example, Figure 9 This is a hardware structure block diagram of a server for an exception handling method for user interface testing according to an exemplary embodiment. (e.g.) Figure 9As shown, the server 400 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 410 (CPUs 410 may include, but are not limited to, microprocessors such as MCUs or programmable logic devices such as FPGAs), a memory 430 for storing data, and one or more storage media 420 (e.g., one or more mass storage devices) for storing application programs 423 or data 422. The memory 430 and storage media 420 may be temporary or persistent storage. The program stored in the storage media 420 may include one or more modules, each module may include a series of instruction operations on the server. Furthermore, the CPU 410 may be configured to communicate with the storage media 420 and execute the series of instruction operations stored in the storage media 420 on the server 400. Server 400 may also include one or more power supplies 460, one or more wired or wireless network interfaces 450, one or more input / output interfaces 440, and / or one or more operating systems 421, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, etc.
[0112] The input / output interface 440 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of server 400. In one example, the input / output interface 440 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 440 may be a radio frequency (RF) module used for wireless communication with the Internet.
[0113] Those skilled in the art will understand that Figure 9 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, server 400 may also include... Figure 9 The more or fewer components shown, or having the same Figure 9 The different configurations shown.
[0114] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0115] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and server embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0116] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0117] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for handling exceptions in user interface testing, characterized in that, The method includes: In response to the target object's identifier acquisition command, the interface structure information and current interface image of the current user interface of the device under test are acquired; the interface structure information includes the position information and original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control; Anomaly detection is performed on the original resource identifier corresponding to each control to determine the original resource identifier with anomalies and the corresponding anomaly type; Based on the aforementioned exception type, the original resource identifier containing the exception is replaced to obtain the replaced resource identifier.
2. The exception handling method according to claim 1, characterized in that, After replacing the original resource identifier with an anomaly based on the anomaly type to obtain the replaced resource identifier, the method further includes: Based on the correspondence between the replaced resource identifier and the original resource identifier that was not replaced, and each control, the resource identifier corresponding to each control is determined; The icon file and resource identifier corresponding to each control are displayed, and the resource identifier corresponding to the target object is processed in response to the identification processing instruction.
3. The anomaly handling method according to claim 1, characterized in that, After determining the icon file corresponding to each control from the current interface image based on the position information corresponding to each control, the method further includes: A similarity detection process is performed on the icon file corresponding to each control to obtain a similarity detection result set; the similarity detection result set includes the icon similarity between the icon files corresponding to any two controls; The similarity of all icons in the similarity detection result set is compared with a preset similarity threshold in turn, and the similarity of icons that is greater than the preset similarity threshold is regarded as abnormal icon similarity. Obtain the two controls corresponding to the similarity of the abnormal icons as abnormal controls, and use the original resource identifier corresponding to the abnormal controls as the similarity abnormal resource identifier; The similarity-abnormal resource identifier is replaced to obtain a replaced resource identifier, and the replaced resource identifier is used as the resource identifier corresponding to the abnormal control.
4. The anomaly handling method according to claim 3, characterized in that, The step of performing similarity detection on the icon files corresponding to each control to obtain a similarity detection result set includes: The icon file corresponding to each control is resized to obtain the resized icon file for each control. The adjusted icon file corresponding to each control is converted to grayscale to obtain a grayscale icon file for each control. The grayscale icon files corresponding to the control are subjected to brightness similarity detection, contrast similarity detection, and structural similarity detection to obtain the similarity detection result set.
5. The anomaly handling method according to any one of claims 1-4, characterized in that, The anomaly types include missing original resource identifiers. The anomaly detection performed on the original resource identifiers corresponding to each control to determine the anomaly-causing original resource identifiers and their corresponding anomaly types includes: For each control, an anomaly detection of missing identifiers is performed on the original resource identifier to determine whether there are any abnormal controls with missing original resource identifiers. In the case of an abnormal control with a missing original resource identifier, the exception type corresponding to the abnormal control with a missing original resource identifier is determined to be the missing original resource identifier. The step of replacing the original resource identifier containing the anomaly according to the anomaly type to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the missing original resource identifier; Based on the preset replacement strategy corresponding to the missing original resource identifier, a resource identifier is added to the abnormal control with the missing original resource identifier to obtain the replaced resource identifier.
6. The anomaly handling method according to any one of claims 1-4, characterized in that, The anomaly type includes duplicate original resource identifiers. The anomaly detection performed on the original resource identifiers corresponding to each control to determine the anomaly-causing original resource identifiers and their corresponding anomaly types includes: For any two controls in the original resource identifiers corresponding to each control, a duplicate identifier anomaly detection is performed to determine whether there are any abnormal controls with duplicate original resource identifiers. In the case of an exception control with a duplicate original resource identifier, the exception type corresponding to the exception control with the duplicate original resource identifier is determined to be the duplicate original resource identifier. The step of replacing the original resource identifier containing the anomaly according to the anomaly type to obtain the replaced resource identifier includes: Obtain the preset replacement strategy corresponding to the duplicate of the original resource identifier; Based on the preset replacement strategy corresponding to the duplicate original resource identifier, the original resource identifier of the abnormal control with missing original resource identifier is replaced to obtain the replaced resource identifier.
7. The anomaly handling method according to any one of claims 2, characterized in that, The step of displaying the icon file and resource identifier corresponding to each control, in response to the identifier processing instruction of the target object, involves processing the resource identifier corresponding to the identifier processing instruction, including: Based on the location information, determine the correspondence between the icon file corresponding to each control and the resource identifier corresponding to each control; Based on the correspondence, the icon file corresponding to each control and the resource identifier corresponding to each control are displayed so that the target object can recognize the replaced resource identifier and the control corresponding to the replaced resource identifier; In response to the identification processing instruction issued by the target object, the identification processing instruction is parsed and processed to process the resource identifier corresponding to the identification processing instruction.
8. The anomaly handling method according to any one of claims 1-4, characterized in that, The method further includes: In response to the icon file replacement instruction, the icon file to be replaced and the resource identifier corresponding to the icon file to be replaced are parsed from the icon file replacement instruction, and the resource identifier corresponding to the icon file to be replaced is used as the target resource identifier. Obtain the historical icon file corresponding to the target resource identifier; The historical icon file is used to replace the icon file to be replaced, thereby completing the icon file replacement instruction.
9. The anomaly handling method according to any one of claims 1-4, characterized in that, After obtaining the interface structure information and current interface image of the current user interface of the device under test, the method further includes: The interface structure information is parsed to obtain the position information and original resource identifiers corresponding to each control. Based on the position information corresponding to each control, the icon file corresponding to each control is determined from the current interface image.
10. An exception handling apparatus for user interface testing, characterized in that, The device includes: The acquisition module is used to acquire the interface structure information and the current interface image of the current user interface of the device under test in response to the target object identifier acquisition command; the interface structure information includes the position information and the original resource identifier of each control in the current user interface; the current interface image includes the icon file corresponding to each control; An anomaly detection module is used to perform anomaly detection on the original resource identifier corresponding to each control, so as to determine the original resource identifier with anomalies and the corresponding anomaly type. An exception replacement module is used to replace the original resource identifier that has an exception based on a preset identification strategy and the exception type, so as to obtain a replaced resource identifier; the preset identification strategy includes a preset exception type and a preset replacement strategy corresponding to the preset exception type.