User interface automatic test method and device, equipment and storage medium
By using assertions in UI automated testing to determine and re-execute the starting position of test data, the accuracy problem caused by the influence of the test environment is solved, achieving higher test accuracy and fewer test script runs.
Patent Information
- Application Number
- CN202510841069.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-09-30
AI Technical Summary
In the prior art, user interface automated testing is easily affected by the testing environment, resulting in low test accuracy.
By using assertions in the test script to judge the test results, locate the starting position of the test data and re-execute it, repeated testing can be used to reduce the impact of the test environment and improve test accuracy.
It improves the accuracy of user interface automation testing, reduces the number of times test scripts are run, and enhances the reliability of test results.
Smart Images

Figure CN120723641A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing technology, and in particular to a user interface automated testing method, apparatus, device, and storage medium. Background Art
[0002] Before releasing an application, its user interface (UI) needs to be tested. This process simulates user interactions with the application to verify that the application works as expected. Currently, UI testing is mostly performed using automated testing to save labor costs.
[0003] In the related art, user interface automated testing is generally achieved by having the device automatically execute test cases written in advance by the tester. However, the execution of the test script may be affected by the test environment, resulting in some test data execution failures, which in turn leads to low test accuracy. Summary of the Invention
[0004] The purpose of this application is to provide a user interface automation testing method, device, equipment and storage medium, aiming to improve the accuracy of interface automation testing.
[0005] This embodiment of the present application provides a user interface automated testing method, including: Reading a target test script; the target test script includes several sets of test data and assertions related to the test data, wherein the test data is used to test the user interface of the target application; Executing the test data in the target test script, and determining a data execution result of the current test data according to the assertion; the data execution result indicates that a test result of the current test data is detected or a test result of the current test data is not detected; When the data execution result indicates that the test result of the current test data is not detected, locate the starting position of the first test data, and re-execute the current test data starting from the first test data to obtain the test result of the current test data; the first test data is the current test data or the most recent set of test data that provides execution conditions for the current test data.
[0006] In one embodiment, before obtaining the target test script, the method further includes: Obtaining an original test script and a test case corresponding to the original test script; The original test script is divided into several groups of test data according to the test case and assertions of the test data are generated to obtain the target test script.
[0007] In one embodiment, determining the data execution result of the current test data according to the assertion includes: According to the verification logic in the assertion, the actual execution environment of the current test data is compared with the expected execution environment, and the data execution result of the current test data is determined according to the comparison result.
[0008] In one embodiment, before executing the test data in the target test script, the method further includes: The test data in the target test script are sorted according to the association strength between the test data, so that the arrangement distance between each test data is negatively correlated with the association strength.
[0009] In one embodiment, the starting position of the test data is marked, and locating the starting position of the first test data includes: extracting index tags in the assertion; determining a strength of match between the identifier and the index tag; The first identifier is indexed according to the matching strength, and the starting position of the first test data is located according to the first identifier; the first identifier is the identifier of the current test data or the previous identifier whose matching strength meets the preset matching conditions and is closest to the index label.
[0010] In one embodiment, the user interface automated testing method further includes: Indexing the second identifier based on the matching strength to locate the starting position of the second test data; the second identifier is a subsequent identifier whose matching strength meets the preset matching condition, the second test data is the test data where the second identifier is located, and the execution condition is provided by the current test data; When the test result of the current test data is that the test is successful, the second test data is executed.
[0011] In one embodiment, executing the test data in the target test script includes: Calling a corresponding test tool according to the type of the target object targeted by the test data; the target object is an element or an image; According to the test strategy included in the test data, the test tool is used to operate the target object to obtain the test result of the current test data; The proxy tool is called to monitor the test tool to capture the test result of the current test data and save it to the memory space under the preset storage path.
[0012] The present invention also provides a user interface automation testing device, including: The first module is configured to read a target test script, wherein the target test script includes several sets of test data and assertions related to the test data, wherein the test data is used to test the user interface of the target application; A second module is configured to execute the test data in the target test script and determine a data execution result of the current test data according to the assertion; the data execution result indicates whether a test result of the current test data is detected or not detected; A third module is configured to locate a starting position of first test data and re-execute the current test data starting from the first test data to obtain a test result of the current test data when the data execution result indicates that the test result of the current test data is not detected; the first test data is the current test data or a most recent set of test data that provides execution conditions for the current test data.
[0013] An embodiment of the present application further provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned user interface automatic testing method when executing the computer program.
[0014] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned user interface automatic testing method is implemented.
[0015] The beneficial effects of the present application are as follows: in the process of executing the test data in the target test script, whether the test result of the test data is detected is determined by a preset assertion; when the test result of the current test data is not detected, the starting position of the current test data or the starting position of the most recent set of test data that provides execution conditions for the current test data is located, and the current test data is re-executed from the first test data to obtain the test result of the current test data. The impact of the test environment is reduced by repeated testing, so that more accurate test results can be obtained, and the number of times the entire test script is run is reduced, thereby improving test accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 This is a schematic diagram of an application scenario of the user interface automation testing method provided in an embodiment of the present application.
[0017] Figure 2 This is a flowchart of the user interface automation testing method provided in an embodiment of the present application.
[0018] Figure 3 This is a flowchart of locating the starting position of the first test data provided by an embodiment of the present application.
[0019] Figure 4 This is a flowchart of executing test data in a target test script provided by an embodiment of the present application.
[0020] Figure 5 It is a structural diagram of the user interface automatic testing device provided in an embodiment of the present application.
[0021] Figure 6 This is a schematic diagram of the hardware structure of the test terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0023] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps illustrated may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. Terms such as "first" and "second" in the specification, claims, and drawings are used to distinguish similar items and are not intended to describe a specific sequence or precedence.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0025] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0026] Before releasing an application, its corresponding user interface (UI) needs to be tested. This involves simulating user interactions with the application to verify that the application functions as expected. For example, a web-based office management application, due to its complex workflow, diverse user roles, and repetitive operations, regression testing requires significant time and effort from testers. Therefore, most current UI testing relies on automated UI testing to reduce labor costs.
[0027] In the related art, user interface automated testing is generally achieved by having the device automatically execute test scripts written in advance by testers. However, the process of executing the test data in the test script may be affected by the test environment, resulting in some test data execution failures, which in turn leads to low test accuracy.
[0028] In response to the technical problem of low test accuracy in the prior art, the inventors discovered in their research that in order to solve this technical problem, the impact of the test environment can be reduced. Considering the randomness of the impact of the test environment, it is possible that the test is affected this time but not the next time. In view of this, the test data that failed the test can be tested repeatedly. Specifically, by making an assertion at the end of each test data execution, the assertion result is used to determine whether the conditions for repeating the test are needed. When the assertion result indicates that the test result of the current test data is not detected, it means that the target object does not exist in the user interface or the test may be affected by the test environment. The current test data is re-executed using the current test data or the most recent set of test data that provides execution conditions for the current test data. Repeated testing reduces the impact of the test environment, thereby obtaining more accurate test results and improving test accuracy.
[0029] The following introduces the application scenarios of the user interface automation testing method provided in the embodiments of the present application. Figure 1 This is a schematic diagram of an application scenario of the user interface automation testing method provided in the embodiment of the present application. Figure 1 This application scenario includes a test terminal 1 for performing automated interface testing. In this embodiment, a tester pre-writes a target test script, which includes several sets of test data and assertions related to the test data. The test data is used to test the user interface of the target application. The test terminal 1 is then triggered to read the target test script, execute the test data in the target test script, and determine the data execution result of the current test data based on the assertions. If the data execution result indicates that no test result for the current test data is detected, the test terminal locates the starting position of the first test data and re-executes the current test data starting from the first test data to obtain the test result of the current test data. The first test data is the current test data or the most recent set of test data that provides execution conditions for the current test data.
[0030] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0031] Figure 2 This is a flowchart of a user interface automation testing method provided by an embodiment of the present application. Figure 2 In one embodiment, the method includes but is not limited to steps S201 to S203.
[0032] Step S201: Read a target test script, wherein the target test script includes several groups of test data and assertions related to the test data, and the test data is used to test the user interface of the target application.
[0033] The target application is any web application, such as a web office management application, a web gaming application, or a web social networking application. The target application has a corresponding user interface through which users interact with the target application. Before releasing the target application, it needs to be tested to ensure that it functions as expected. The target test script is pre-written by the tester and includes several sets of test data and assertions related to the test data. The test data in the target test script is used to test the target application's corresponding user interface.
[0034] When a user interface test is required for a target application, the tester triggers the test terminal to read the target test script so that the test data in the target test script are run one by one, thereby enabling the test terminal to execute the user interface automation testing method provided in this embodiment.
[0035] Step S202: execute the test data in the target test script and determine the data execution result of the current test data according to the assertion, wherein the data execution result indicates whether the test result of the current test data is detected or whether the test result of the current test data is not detected.
[0036] An assertion is a type of first-order logic in a program (e.g., a logical statement with a true or false result). Its purpose is to represent and verify the results expected by the software developer. When the program executes to the assertion, the corresponding assertion should be true. If the assertion is not true, the program will terminate execution and give an error message. The test results of the current test data include test success and test failure. Determining the data execution result of the current test data can be achieved by comparing the user interface when the test result of the current test data represents the test result or the user interface when the test result of the current test data represents the test failure with the user interface after executing the current test data.
[0037] After reading the target test script, the test terminal executes the test data in the target test script one by one. During the execution of the test data in the target test script, the test objects in the test interface are operated according to the test logic specified in the test data, simulating user operations. After detecting that the test data has been executed, the test terminal determines the data execution result of the test data based on the assertion result corresponding to the test data. If the data execution result indicates that no test result for the current test data has been detected, step S203 is executed.
[0038] Step S203: When the data execution result indicates that no test result for the current test data is detected, the starting position of the first test data is located, and the current test data is re-executed starting from the first test data to obtain the test result for the current test data. The first test data is the current test data or the most recent set of test data that provides execution conditions for the current test data.
[0039] When the data execution result indicates that the test result of the current test data is not detected, it means that the user interface after executing the current test data does not correspond to the user interface when the test result is achieved or the user interface when the test fails. In this case, the test terminal locates the first test data based on the degree of correlation between the current test data and other previous test data. That is, if the correlation between the current test data and other previous test data is weak, the test terminal locates to the starting position of the current test data. If the correlation between the current test data and other previous test data is strong and the previous test data provides execution conditions for the current test data, the test terminal locates to the most recent set of test data that provides execution conditions for the current test data. After locating to the starting position of the first test data, starting from the first test data, each test data between the first test data and the current test data is executed one by one. After each test data is executed and the test results are all successful, the current test data is re-executed to obtain the test result of the current test data.
[0040] The user interface automation testing method provided by the embodiment of the present application determines whether the test result of the test data is detected through a preset assertion during the process of executing the test data in the target test script. When the test result of the current test data is not detected, the method locates the starting position of the current test data or the starting position of the most recent set of test data that provides execution conditions for the current test data, and re-executes the current test data from the first test data to obtain the test result of the current test data. The impact of the test environment is reduced by repeated testing, so that more accurate test results can be obtained, and the number of times the entire test script is run is reduced, thereby improving test accuracy.
[0041] In one embodiment, before obtaining the target test script, the method further includes: obtaining the original test script and the test case corresponding to the original test script; dividing the original test script into several groups of test data according to the test case and generating assertions of the test data to obtain the target test script.
[0042] The original test script can be considered a script framework. The test data in the original test script is compiled based on the corresponding test case. The script structure of the original test script requires further assertion supplementation before subsequent automated testing can be performed. For example, the original test script is used for subsequent user interface automated testing. A test case is a detailed description of a set of execution steps, input data, expected results, and actual results designed to verify a specific function or scenario. It is the smallest execution unit of software testing and is used to determine whether the system under test functions as expected.
[0043] After obtaining the original test script and the test cases corresponding to the original test script, the original test script is divided according to the test cases to obtain test data corresponding to multiple test cases. According to the execution type, execution action, and execution environment of the test items corresponding to the test cases, corresponding assertions are generated. The generated assertions are inserted at the end of the test data to obtain the target test script. In actual use, after the test terminal executes the current test data, the assertions corresponding to the current test data are executed and the corresponding assertion results are obtained, i.e., the data execution results of the current test data.
[0044] In one embodiment, determining the data execution result of the current test data according to the assertion includes: comparing the actual execution environment of the current test data with the expected execution environment according to the verification logic in the assertion and determining the data execution result of the current test data according to the comparison result.
[0045] After executing the current test data, the actual execution environment of the current test data is obtained. The actual execution environment of the current test data is compared with the expected execution environment based on the verification logic in the assertion to obtain a corresponding assertion result. When the actual execution environment of the current test data matches the expected execution environment, an assertion result is obtained indicating that the test result of the current test data is detected. When the actual execution environment of the current test data does not match the expected execution environment, an assertion result is obtained indicating that the test result of the current test data is not detected. Based on the obtained assertion result, the data execution result of the current test data is determined.
[0046] In one embodiment, before executing the test data in the target test script, the method further includes: sorting the test data in the target test script according to the correlation strength between the test data, so that the arrangement distance between each test data is negatively correlated with the correlation strength.
[0047] The strength of the association between test data is determined based on the execution hierarchical relationship between the test operations corresponding to the test data. When the test operations corresponding to two test data have a hierarchical relationship, it means that the two test data are associated. The strength of the association is related to the number of execution hierarchical layers between the corresponding test operations of the two test operations. The fewer the number of layers, the stronger the association strength, and the more the number of layers, the weaker the association strength. For example, for test operations A, B, and C, test operation A provides execution conditions for test operation B, and test operation B provides execution conditions for test operation C. That is, test operations A, B, and C are associated with each other, and the strength of the association between test operations B and C is greater than the strength of the association between test operations A and C.
[0048] Before executing the test data in the target test script, each test data in the target test script is traversed to determine the associations between the test data, and the associated test data are divided into corresponding test data sets. For each test data in the test data set, the test data in the target test script is sorted according to the strength of the association between the test data, so that the test data are arranged according to the strength of the association, and the strength of the association between two adjacent test data is greater than the strength of the association between two non-adjacent test data, even if the arrangement distance between the test data is negatively correlated with the strength of the association.
[0049] Figure 3 This is a flowchart of locating the starting position of the first test data provided by an embodiment of the present application. Figure 3 In one embodiment, the method includes but is not limited to steps S301 to S303.
[0050] In this embodiment, a marker is set at the starting position of the test data.
[0051] Step S301: extract the index tag in the assertion.
[0052] Tags contain identification text that describes the test operation corresponding to the test data. Assertions include assertion statements and index tags that index the tags, which summarize the identification text. Using text recognition tools to perform text recognition on the target test script can extract the index tags in the assertions.
[0053] Step S302: Determine the matching strength between the identifier and the index tag.
[0054] The similarity between the identifier and the index label is calculated using a text similarity calculation method, such as a cosine distance, to determine the matching strength between the identifier and the index label.
[0055] Step S303: index the first identifier based on the matching strength, and locate the starting position of the first test data based on the first identifier. The first identifier is the identifier of the current test data or the previous identifier whose matching strength meets the preset matching condition and is closest to the index tag.
[0056] The matching strength between the identifier and the index tag indicates whether the previous test data provides execution conditions for the current test data. If the matching strength meets the preset matching conditions, the previous test data provides execution conditions for the current test data. If the matching strength does not meet the preset matching conditions, the previous test data does not provide execution conditions for the current test data. Based on the matching strength between the identifier and the index tag, the previous identifier relative to the current test data is indexed starting from the current test data. When the matching strength between the index tag of the current test data and the previous identifier exceeds the preset matching strength threshold, and the matching strength between the index tag of the current test data and the previous identifier meets the preset matching conditions, the previous identifier obtained by the first index with a matching strength that meets the preset matching conditions is used as the first identifier, or when there is no previous identifier with a matching strength that meets the preset matching conditions, the identifier of the current test data is used as the first identifier. After the first identifier is obtained by indexing, the starting position of the first test data is located according to the first identifier.
[0057] Furthermore, in one embodiment, the method further includes: indexing the second identifier based on the match strength to locate the starting position of the second test data; and executing the second test data when the test result of the current test data is a success. The second identifier is a subsequent identifier whose match strength meets the preset matching condition, and the second test data is the test data where the second identifier is located. The execution condition is provided by the current test data.
[0058] Based on the matching strength between the identifier and the index tag, the subsequent identifier relative to the current test data is indexed starting from the current test data. When the matching strength between the index tag of the current test data and the subsequent identifier exceeds a preset matching strength threshold, and when the matching strength between the index tag of the current test data and the subsequent identifier meets the preset matching condition, the subsequent identifier whose matching strength meets the preset matching condition is used as the second identifier. When the test result of the current test data is a successful test, the starting position of the second test data is located and the second test data is executed to obtain the test result of the second test data. By providing execution conditions for the corresponding subsequent test data through associated execution, the configuration time required to execute the test data can be saved. Figure 4 This is a flowchart of executing test data in a target test script provided by an embodiment of the present application. Figure 4 In one embodiment, the method includes but is not limited to steps S401 to S403.
[0059] Step S401: Call the corresponding test tool according to the type of the target object targeted by the test data. The target object is an element, an image, or a pop-up window.
[0060] In the embodiments of the present application, an element is an operable control in a user interface, an image is a screenshot of a portion of the user interface, and a pop-up window is a window that pops up suddenly while the user is operating the user interface, used to prompt information, request confirmation, or perform additional interaction. Testing tools include Selenium and PyAutoGUI. Selenium is primarily used for automating browser operations (such as clicking, input, form submission, etc.) and can simulate user behavior to capture dynamic web page data. PyAutoGUI is primarily used for desktop GUI automation (such as simulating mouse and keyboard operations and controlling any desktop application). When the target object of the test data is an element or image, Selenium is called; when the target object of the test data is a pop-up window, PyAutoGUI is called.
[0061] Step S402 : operating the target object using a test tool according to the test strategy included in the test data to obtain a test result of the current test data.
[0062] In an embodiment of the present application, when calling Selenium, Selenium WebDriver is used to drive a browser (such as Chrome or Firefox) to simulate user operations such as clicking a button, scrolling a page, or entering text based on the test strategy contained in the test data. Page elements are located using XPath, CSS Selector, or element ID, and dynamically rendered content (such as user comments or real-time prices) is extracted to obtain the test results of the current test data. When calling PyAutoGUI, the PyAutoGUI library is used to simulate operations such as mouse clicks or keyboard input using screen coordinates and image recognition technology based on the test strategy contained in the test data. A specific element on the screen (such as a pop-up button or verification code input box) is located using the "locateOnScreen()" method, and the "click()" or "typewrite()" method is called to perform the operation to obtain the test results of the current test data.
[0063] Step S403: calling the proxy tool to monitor the test tool to capture the test results of the current test data and save them to the memory space under the preset storage path.
[0064] In the embodiment of the present application, the proxy tool is Fiddler. When the test tool is called to operate on the target object, the proxy tool is called to monitor the test tool, and custom rules are written through FiddlerScript (a scripting language based on JScript.NET) to filter the target interface (such as requests containing specific URLs or keywords) and extract structured data in the response (such as product details in JSON or XML format).
[0065] See also Figure 5 The present application also provides a user interface automation testing device that can implement the above-mentioned user interface automation testing method. The device includes: The first module 501 is used to read a target test script; the target test script includes several sets of test data and assertions related to the test data, and the test data is used to test the user interface of the target application; The second module 502 is configured to execute the test data in the target test script and determine a data execution result of the current test data according to the assertion; the data execution result indicates whether the test result of the current test data is detected or not detected; The third module 503 is used to locate the starting position of the first test data when the data execution result indicates that the test result of the current test data is not detected, and re-execute the current test data from the first test data to obtain the test result of the current test data; the first test data is the current test data or the most recent set of test data that provides execution conditions for the current test data.
[0066] The specific implementation of the user interface automation testing device is substantially the same as the specific embodiment of the above-mentioned user interface automation testing method, and will not be described in detail here.
[0067] Figure 6 The figure is a block diagram of a test terminal according to an exemplary embodiment.
[0068] Refer to the following Figure 6 The test terminal 600 according to this embodiment of the present disclosure will be described. Figure 6 The test terminal 600 shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0069] like Figure 6 As shown, the test terminal 600 is implemented as a general-purpose computing device. Components of the test terminal 600 may include, but are not limited to, at least one processing unit 610, at least one storage unit 620, a bus 630 connecting various system components (including the storage unit 620 and the processing unit 610), a display unit 640, and the like.
[0070] The storage unit stores program codes, which can be executed by the processing unit 610 , so that the processing unit 610 executes the steps according to various exemplary embodiments of the present disclosure described in the above user interface automated testing method section of this specification.
[0071] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0072] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0073] Bus 630 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0074] The test terminal 600 can also communicate with one or more external devices 600' (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the test terminal 600, and / or any device that enables the test terminal 600 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication can occur via an input / output (I / O) interface 650. Furthermore, the test terminal 600 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 660. The network adapter 660 can communicate with other modules of the test terminal 600 via a bus 630. It should be understood that, although not shown, other hardware and / or software modules can be used in conjunction with the test terminal 600, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0075] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned user interface automatic testing method is implemented.
[0076] The user interface automation testing method, apparatus, device and storage medium provided by the embodiments of the present application, in the process of executing the test data in the target test script, determines whether the test result of the test data is detected through a preset assertion. When the test result of the current test data is not detected, it locates the starting position of the current test data or the starting position of the most recent set of test data that provides execution conditions for the current test data, and re-executes the current test data from the first test data to obtain the test result of the current test data. The impact of the test environment is reduced by repeated testing, so that more accurate test results can be obtained, and the number of times the entire test script is run is reduced, thereby improving test accuracy.
[0077] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above-mentioned method according to the embodiments of the present disclosure.
[0078] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable 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 fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0079] Computer-readable storage media may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0080] Those skilled in the art will appreciate that the modules described above can be distributed in the device according to the description of the embodiment, or can be modified accordingly to be used in one or more devices that are different from the embodiment. The modules of the above embodiment can be combined into one module or further divided into multiple submodules.
[0081] While the exemplary embodiments of the present disclosure have been specifically illustrated and described above, it should be understood that the present disclosure is not limited to the detailed structures, configurations, or implementations described herein; rather, the present disclosure is intended to encompass various modifications and equivalent configurations within the spirit and scope of the appended claims.
Claims
1. A user interface automated testing method, characterized in that: include: Read the target test script; The target test script includes several sets of test data and assertions related to the test data, wherein the test data is used to test the user interface of the target application; Execute the test data in the target test script and determine the data execution result of the current test data based on the assertion; The data execution result indicates a test result in which the current test data is detected or a test result in which the current test data is not detected; When the data execution result indicates that no test result of the current test data is detected, locating a starting position of first test data, and re-executing the current test data starting from the first test data to obtain a test result of the current test data; The first test data is the current test data or a most recent set of test data that provides execution conditions for the current test data.
2. The user interface automation testing method according to claim 1, wherein: Before obtaining the target test script, the method further includes: Obtaining an original test script and a test case corresponding to the original test script; The original test script is divided into several groups of test data according to the test case and assertions of the test data are generated to obtain the target test script.
3. The user interface automation testing method according to claim 1, wherein: Determining the data execution result of the current test data according to the assertion includes: According to the verification logic in the assertion, the actual execution environment of the current test data is compared with the expected execution environment, and the data execution result of the current test data is determined according to the comparison result.
4. The user interface automation testing method according to claim 1, wherein: Before executing the test data in the target test script, the method further includes: The test data in the target test script are sorted according to the association strength between the test data, so that the arrangement distance between each test data is negatively correlated with the association strength.
5. The user interface automation testing method according to claim 4, characterized in that: The starting position of the test data is marked, and locating the starting position of the first test data includes: extracting index tags in the assertion; determining a strength of match between the identifier and the index tag; The first identifier is indexed according to the matching strength, and the starting position of the first test data is located according to the first identifier; the first identifier is the identifier of the current test data or the previous identifier whose matching strength meets the preset matching conditions and is closest to the index label.
6. The user interface automated testing method according to claim 5, characterized in that: Also includes: indexing the second identifier according to the matching strength to locate the starting position of the second test data; The second identifier is a subsequent identifier whose matching strength meets the preset matching condition, the second test data is the test data where the second identifier is located, and the execution condition is provided by the current test data; When the test result of the current test data is that the test is successful, the second test data is executed.
7. The user interface automated testing method according to any one of claims 1 to 6, characterized in that: The executing the test data in the target test script includes: Calling a corresponding test tool according to the type of the target object targeted by the test data; the target object is an element or an image; According to the test strategy included in the test data, the test tool is used to operate the target object to obtain the test result of the current test data; The proxy tool is called to monitor the test tool to capture the test result of the current test data and save it to the memory space under the preset storage path.
8. A user interface automated testing device, characterized in that: include: The first module is used to read the target test script; The target test script includes several sets of test data and assertions related to the test data, wherein the test data is used to test the user interface of the target application; A second module is configured to execute the test data in the target test script and determine a data execution result of the current test data based on the assertion; The data execution result indicates a test result in which the current test data is detected or a test result in which the current test data is not detected; a third module configured to locate a starting position of first test data and re-execute the current test data starting from the first test data to obtain a test result of the current test data when the data execution result indicates that no test result of the current test data is detected; The first test data is the current test data or a most recent set of test data that provides execution conditions for the current test data.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the user interface automation testing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the user interface automation testing method according to any one of claims 1 to 7 is implemented.