UI automatic testing method and device based on coordinate positioning

Through the UI automation testing method based on coordinate positioning, the problems of unstable positioning and large code volume of UI automation testing in the existing technology are solved, and simplified test script writing and efficient test execution are realized, which are suitable for a variety of graphical interface applications.

CN120066957APending Publication Date: 2025-05-30四川中仑数科科技有限责任公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510103162.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The existing UI automation testing methods rely on stable servers or fixed-resolution displays, resulting in instability and complexity of test object positioning, and require a large amount of code, affecting testing efficiency.

Method used

The UI automation testing method based on coordinate positioning is adopted. By entering the coordinates and operation keywords of interface elements, the UI automation test script is called to simulate user operations, and the test results are recorded and the test report is generated. This method includes resolution adaptation, fault tolerance mechanism and multi-threading, simplifying the writing and execution of test scripts.

Benefits of technology

It reduces the complexity of UI recognition and positioning, reduces the need for code volume, improves testing efficiency, and can quickly complete the writing of test scripts and the creation of test cases. It is suitable for a variety of graphical interface applications, including desktop applications, web applications and mobile applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066957A_ABST
    Figure CN120066957A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a UI automatic testing method and device based on coordinate positioning. The method comprises the steps that coordinates and operation keywords of interface elements needed by operation of a test case are input; calling and executing a UI automatic test script based on the coordinates of the interface elements and the operation keywords, and simulating user interface operation; and recording an execution result of the test case, storing an interface screenshot during operation, and generating a test report after script execution is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of automated testing, and more particularly, to a coordinate-based UI automated testing method and apparatus. Background Art

[0002] In the UI automated testing of a cashier retail client, the involved modules include a login module, a cashier module, an order module, a promotion calculation and display module, a payment and confirmation module, etc. The goal of UI automated testing is to simulate the daily operations of users through an automated testing tool, verify whether the interface performance and functions of the client meet the expectations, and detect the correctness and stability of each functional module.

[0003] Currently, UI automated testing methods usually obtain the positions of interface elements in real time during the testing process based on algorithms (such as image recognition, OCR recognition, attribute positioning, etc.). Usually, it depends on a stable server or a display with a fixed resolution to ensure the stability and accuracy of test object positioning, and requires a large amount of code, which affects the testing efficiency. Summary of the Invention

[0004] Embodiments described herein provide a coordinate-based UI automated testing method, apparatus, and computer-readable storage medium storing a computer program.

[0005] According to a first aspect of the present disclosure, there is provided a coordinate-based UI automated testing method, including: inputting the coordinates and operation keywords of interface elements required for test case operations; calling and executing a UI automated testing script based on the coordinates and operation keywords of the interface elements to simulate user interface operations; and recording the execution results of the test cases and saving the interface screenshots during runtime, and generating a test report after the script execution is completed.

[0006] In some embodiments of the present disclosure, inputting the coordinates and operation keywords of interface elements required for test case operations includes: measuring the operation coordinates of interface elements required for test cases at a reference resolution; creating a test case file in a data table format, where the test case file includes the test case name and the operation coordinates and operation keywords of interface elements required for the test case, and the operation types corresponding to the operation keywords include waiting, clicking, inputting, and swiping.

[0007] In some embodiments of the present disclosure, the UI automated testing script modularly encapsulates a coordinate positioning method for resolution adaptation, an assertion method for test results, a mouse operation method, a screen capture method, an exception handling method, a fault tolerance mechanism handling method, and a method for handling multi-threaded test tasks based on a Jenkins distributed architecture based on the pytest framework.

[0008] In some embodiments of the present disclosure, the resolution adaptation coordinate positioning method includes: obtaining the resolution of the current window, calculating the scaling ratio of the operation coordinates according to the reference resolution and the resolution of the current window; and calculating the current operation coordinates based on the scaling ratio and the operation coordinates under the reference resolution.

[0009] In some embodiments of the present disclosure, the processing method of the fault tolerance mechanism includes: setting a fixed waiting time for known time-consuming operations; setting a display waiting mechanism for unknown time-consuming operations that depend on the UI state; and setting a retry mechanism for operation failures, retrying the operation until the maximum number of retries is reached or the operation is successful.

[0010] In some embodiments of the present disclosure, calling and executing a UI automation test script based on the coordinates of the interface element and the operation keyword to simulate user interface operations includes: reading the operation coordinates and operation keywords from a test case file in a data table format; calling an operation method according to the operation keyword, and simulating the operation behavior of the user interface based on the current operation coordinates.

[0011] In some embodiments of the present disclosure, recording the execution results of the test cases and saving the interface screenshots during runtime, and generating a test report after the script execution is completed includes: after each test case is executed, capturing the test results through assertion and logging functions; automatically saving the screen screenshots when a failed test case is executed, and generating a detailed test report through Allure.

[0012] In some embodiments of the present disclosure, the test report includes the execution time, execution status, error type, comparison between the execution result and the expected result of each test case, and the screen screenshot of the test failure.

[0013] According to the second aspect of the present disclosure, a UI automation test device based on coordinate positioning is provided. The device includes at least one processor; and at least one memory storing a computer program. When the computer program is executed by the at least one processor, the device is caused to: input the coordinates and operation keywords of the interface elements required for the test case operations; call and execute a UI automation test script based on the coordinates of the interface elements and the operation keywords to simulate user interface operations; and record the execution results of the test cases and save the interface screenshots during runtime, and generate a test report after the script execution is completed.

[0014] In some embodiments of the present disclosure, when executed by at least one processor, a computer program causes a device to record the coordinates and operation keywords of the interface elements required for test case operations through the following operations: measure the operation coordinates of the interface elements required for the test case at the reference resolution; create a test case file in a data table format, where the test case file includes the test case name and the operation coordinates and operation types of the interface elements required for the test case, and the operation types include wait, click, input, and slide.

[0015] In some embodiments of the present disclosure, when executed by at least one processor, a computer program causes a device to call and execute a UI automation test script based on the coordinates and operation keywords of the interface elements to simulate user interface operations through the following operations: read the operation coordinates and operation keywords from the test case file in a data table format; call the operation method according to the operation keyword and simulate the operation behavior of the user interface based on the current operation coordinates.

[0016] In some embodiments of the present disclosure, when executed by at least one processor, a computer program causes a device to record the test case execution results, save the screenshot of the interface during runtime, and generate a test report after the script execution is completed: after each test case is executed, capture the test results through the assertion and logging functions; when a failed test case is executed, automatically save the screenshot and generate a detailed test report through Allure.

[0017] According to a third aspect of the present disclosure, there is provided a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the UI automation test method based on coordinate positioning according to the first aspect of the present disclosure.

[0018] The UI automation test method and device based on coordinate positioning according to the embodiments of the present disclosure do not require knowledge of complex codes and frameworks. Testers only need to provide the screen coordinates of the controls and related operations, reducing the complexity of UI recognition and positioning. They can even complete the writing of test cases without writing too much code, lowering the threshold of automated testing, enabling quick completion of the writing of test scripts, and saving the creation time of test cases. Multiple test cases can be executed simultaneously, unaffected by changes in control attributes, style designs, etc., and can be applied to almost all types of graphical interface applications, including desktop applications, web applications, mobile applications, etc., improving test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly described below. It should be understood that the following described drawings only relate to some embodiments of the present disclosure and do not limit the present disclosure, where:

[0020] Figure 1 Exemplary flowchart showing the coordinate - based UI automation testing method 100 according to an embodiment of the present disclosure;

[0021] Figure 2 Schematic diagram of the input content of the test case file according to an embodiment of the present disclosure;

[0022] Figure 3 Schematic diagram of the content of the test report according to an embodiment of the present disclosure;

[0023] Figure 4 Schematic block diagram of the coordinate - based UI automation testing device 400 according to an embodiment of the present disclosure.

[0024] It should be noted that the elements in the drawings are schematic and not drawn to scale. Detailed implementation manners

[0025] In order to make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Apparently, the described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by those skilled in the art without creative efforts based on the described embodiments of the present disclosure also belong to the scope of protection of the present disclosure.

[0026] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art to which the subject matter of the present disclosure belongs. Further, it will be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the specification and the relevant art, and will not be interpreted in an idealized or overly formal form unless clearly defined otherwise herein.

[0027] In UI automation, accurately positioning UI elements is crucial. If the positions of interface elements change with different resolutions, screen sizes, resolution changes, operating system versions, etc., the automation scripts may fail. To achieve stable UI automation operations and solve the resolution - dependence problem, this solution proposes a coordinate - based UI automation testing method, which has the advantages of simplicity, low code requirements, and high efficiency. It does not require complex UI element positioning and parsing, and uses a keyword - driven method to run multiple test cases simultaneously, which can improve the script writing and testing efficiency.

[0028] Since each UI control (such as buttons, text boxes, check boxes, etc.) has a corresponding screen coordinate, the automation script can directly operate through these coordinates and interact with the interface by simulating mouse clicks (single or double clicks), drags, swipes, etc. By recording test data, taking screenshots of the interface and comparing them with the expected results, the correctness of UI operations can be verified. If it does not match the expectation, it can be marked as failed or abnormal, and a test report can be automatically generated.

[0029] Figure 1 FIG. 4 shows an exemplary flowchart of a UI automation test method 100 based on coordinate positioning according to an embodiment of the present disclosure.

[0030] Refer to Figure 1 As shown, at block S102, the coordinates of the interface elements required for the test case operation and the operation keywords are entered. Figure 1 In some embodiments of the present disclosure, the operation coordinates of the interface elements required for the test case are measured at the reference resolution. The pixel coordinates on the screen can be obtained using the screenshot function of PyAutoGUI or the monitor screenshot. At the reference resolution, such as 1920x1080 or 1366x768, the coordinate measurement is performed. A test case file in the form of a data table is created. The test case file includes the test case name, the operation coordinates of the interface elements required for the test case, and the operation keywords. The operation types corresponding to the operation keywords include waiting, clicking, inputting, swiping, etc.

[0031] For example, an Excel file is created. Each row records the name of a test case, the operation keyword, and its corresponding interface element coordinates. Briefly describe the function of this operation, list the test steps in detail, specific to each operation, the screen coordinates of each operation target object, which are used to locate the operation object. Assuming a pixel coordinate system, (X,Y) are the specific coordinate values, and you need to fill in these coordinates according to the actual application. The operation keyword defines the type of operation to be performed, for example: sleep: wait for a certain period of time, mouclick: mouse click, drag: drag, hover: mouse hover, type: input text.

[0032]

[0033] Figure 2 Figure 2 FIG. 21 is a schematic diagram of the content entered in the test case file according to an embodiment of the present disclosure. Refer to Figure 2As shown, for the operation of "selecting a table to open the table", it is necessary to enter use case names such as "wait, click on the table, click to open the table, select the table to be transferred, click the confirm transfer button, select the billing method,, enter the details of the transferred table, wait, click the checkout button" and the coordinates and operation keywords of the corresponding operation objects. For the operation of "selecting a table for table merging", it is necessary to enter use case names such as "wait, click on table A, click to open the table, click the return button, click on table B, click to open the table, click the return button, click the merge button, click on merged table A, click on merged table B" and the coordinates and operation keywords of the corresponding operation objects. The operation keywords include "sleep, mouclick, drag, hover, type", etc.

[0034] Subsequently, in the box S104, the UI automation test script is called and executed based on the coordinates and operation keywords of the interface elements to simulate the user interface operations.

[0035] In some embodiments of the present disclosure, the UI automation test script modularly encapsulates methods for coordinate positioning of resolution adaptation, assertion methods for test results, mouse operation methods, screenshot methods, exception handling methods, handling methods for fault tolerance mechanisms, and methods for handling multi-threaded test tasks based on the Jenkins distributed architecture based on the pytest framework.

[0036] Assume the process of adding a test product to the shopping cart and determine the elements that need to be automated. The elements include buttons, text boxes, dropdown boxes, etc. For the mouse click (mouclick) operation, pyautogui.click(x,y) can be used for the click operation, where (x,y) are the coordinates read from Excel, wait for the page to respond time.sleep(2), and verify the quantity of products in the shopping cart (assuming verification is through screenshot or image recognition). In addition, it also includes mouse hover (Hover): pyautogui.moveTo(x,y), drag (Drag): pyautogui.dragTo(x,y), and input text (Type) operation: use pyautogui.typewrite(text,interval=0.1) to enter text in the text box, etc. Test methods can be added according to test needs.

[0037] In order to ensure the stability of the automation test as much as possible under different resolutions and window sizes, by referring to the coordinates of the target element at a certain known resolution, the coordinate conversion is performed according to the ratio of the current resolution. The coordinate positioning method for resolution adaptation includes: obtaining the resolution of the current window, calculating the scaling ratio of the operation coordinates based on the reference resolution and the resolution of the current window. Based on the scaling ratio and the operation coordinates at the reference resolution, calculate the current operation coordinates.

[0038] In some embodiments of the present disclosure, operation coordinates are read from a test case file in a data table format (based on a reference resolution). If the reference resolution is 1920x1080 and the current resolution is 1366x768, then the scaling ratio of the X-axis is (current resolution width / reference resolution width), and the scaling ratio of the Y-axis is (current resolution height / reference resolution height).

[0039] Before starting the test, an adaptable resolution can be set for the resolution, and the operating system and libraries such as pyautogui and pytesseract can be checked. When there is a mismatch, corresponding error logs are given to facilitate troubleshooting and timely adjustment of the test environment, so as to meet the corresponding expected requirements and improve the success rate of the test script.

[0040] In some other embodiments of the present disclosure, different waiting mechanisms (such as fixed waiting, explicit waiting, retry mechanism) are used to ensure that the script can execute stably in various environments and conditions. These mechanisms can effectively reduce execution errors caused by test environment problems (such as network latency, hardware instability, etc.), thereby improving the robustness and maintainability of the test script. The processing methods of the fault tolerance mechanism include:

[0041] Set a fixed wait for operations with known time consumption. This method is used in scenarios where it is known that a certain operation will be completed within a certain period of time. For example, during the process of logging in to the cashier software, if it is known that the system normally takes 10 seconds to complete the login, then a fixed wait can be set.

[0042] Set an explicit wait mechanism for operations with unknown time consumption and dependent on the UI state. The explicit wait mechanism is to wait for a certain condition to be established before performing the next operation. The condition is generally a certain state of the UI element, such as whether the element is visible, clickable, etc. This method is more flexible and applicable to scenarios where the operation execution time is not fixed. For example, during the checkout process, the system needs to process a large amount of data, and the time will vary due to network latency or device performance differences.

[0043] Set a retry mechanism for operation failures. This method is applicable to unstable environments or operations. For example, when querying an order, due to network, hardware and other problems, the query result may be incorrect. By introducing a retry mechanism, the query operation is retried until the maximum number of retries is reached or success is achieved. It can ensure that the test can be completed within a certain fault tolerance range and will not cause the test to fail due to accidental network jitter or device instability.

[0044] In still other embodiments of the present disclosure, in the distributed build mode, different test scripts can be run simultaneously on different machines, thus achieving multi-threaded parallel execution and saving a large amount of test time. The method for processing multi-threaded test tasks based on the Jenkins distributed architecture can be encapsulated in the test script. First, configure the Master and Slave nodes of Jenkins, and then allocate the test tasks to different nodes for execution. When performing cross-platform tests, first focus on the operation object, and then use coordinate positioning for automated operation execution. When performing cross-operating system tests, install an emulator. For focusing on the operation object of the emulator, perform coordinate positioning for operation execution.

[0045] Therefore, when performing UI automated testing, the operation coordinates and operation keywords can be read from the test case file in the data table format. Call the operation method according to the operation keyword, and simulate the operation behavior of the user interface based on the current operation coordinates.

[0046] For example, the automated testing requirements of the cash register system include product addition to the cart, promotion calculation, member query, order verification, etc. The product information, promotion information, and member information to be tested can be entered in the test case file in the data table format. The test modules include the product addition to the cart module, the promotion module, and the order verification module. The product addition to the cart module is used to simulate users of different membership levels logging in, check whether the membership discounts can be correctly applied, simulate the user's behavior of adding products to the cart, and the addition behavior includes adding ordinary products to the cart, adding promotional products to the cart (time-limited discounts, products with full reduction, etc.), and adding products in different quantities to the cart; the promotion module is used to check the linkage relationship between the promotion and product addition to the cart and settlement, and verify the impact of different promotions on the product price and calculation; the order verification module is used to simulate the selection of the payment method and verify whether the order status is correct after payment.

[0047] For the product addition to the cart test, the automated test script can simulate the user's behavior of selecting products and adding them to the cart, covering adding ordinary products to the cart, adding promotional products to the cart (time-limited discounts, products with full reduction, etc.), and adding products in different quantities to the cart (changing the product quantity, verifying the total price update). After adding the products to the cart, verify whether the quantity and total price of the products in the cart are consistent with the expectations. Verify the status of the product inventory and check whether there is a correct prompt when the inventory is insufficient. Simulate emptying the cart and verify whether the cart status is reset to the initial state.

[0048] For the promotion, check whether the full reduction amount is correctly applied, check whether the discount is calculated as expected, verify whether the user's coupon is correctly applied, check the price after the discount, and check the linkage relationship between the promotion and product addition to the cart and settlement to ensure that the promotion rules can correctly affect the product price and order amount.

[0049] For member query and verification, users with different membership levels can be simulated to log in and check whether membership discounts, such as member discounts, points, privileges, etc., can be correctly applied. For order verification, it can be verified whether the product list, total price, payment method, promotional discounts, etc. are consistent with expectations, and the payment method selection can be simulated and the order status after payment (such as "payment successful" or "payment failed") can be verified whether it is correct.

[0050] When requirements change or new features are launched, execute core function test cases such as product addition to cart, promotions, and member queries, verify whether the order is correct after settlement, and ensure that the new features do not disrupt the existing functions.

[0051] Regression testing mainly focuses on whether the product addition to cart logic is still correct, whether the promotion calculation is normal, and whether the order settlement is correct. Tests can be executed simultaneously on multiple browsers or devices to quickly verify the cross-platform compatibility of the system. It is not necessary to manually execute all scenarios from beginning to end, but relevant test cases can be executed according to the changed content of the requirements.

[0052] In automated testing, using the data-driven method can greatly improve the code reusability and maintainability. Embodiments of the present disclosure combine the pytest framework and encapsulate methods such as coordinate positioning, resolution adaptation, mouse operations, screenshot taking, assertions, etc. into a keyword-driven form, which can make the writing of automated scripts more efficient and concise.

[0053] Finally, at Figure 1 in the box S106, record the execution results of the test cases, save the interface screenshots during runtime, and generate a test report after the script execution is completed.

[0054] In some embodiments of the present disclosure, after each test case is executed, the test results are captured through assertion and logging functions. When a failed test case is executed, a screen screenshot is automatically saved, and a detailed test report is generated through Allure.

[0055] Figure 3 is a schematic diagram of the content of the test report according to the embodiments of the present disclosure. Refer to Figure 3 As shown, the test report may include the execution time, execution status (passed / failed), error type, comparison between the execution result and the expected result, and the screen screenshot of the test failure of each test case. Double-clicking can view the specific content of the screenshot.

[0056] For key operation objects, such as the submission of documents, the amount after checkout, and the query of orders, record the corresponding interface response time. Check the data accuracy by calling the database to ensure the validity of the submitted data and the correctness of the query results.

[0057] If during the testing process, it is found that a certain link is inconsistent with the expectation, the system will alarm in a timely manner and feedback the abnormal information to the relevant personnel via email or other notification methods, which can improve the response speed to problems and enable timely repair. During the test execution process, when an exception occurs, it can be captured in a timely manner and detailed log information is recorded. For example, price inconsistency exception: if the promotional price calculation is incorrect, the system should output detailed error information, such as the difference between the expected price and the actual price. Operation failure exception, if a certain operation (such as adding a product to the cart, checking out) fails, the system should record detailed error logs for easy troubleshooting.

[0058] Figure 4 FIG. 4 is a schematic block diagram of a UI automated testing apparatus 400 based on coordinate positioning according to an embodiment of the present disclosure. As Figure 4 shown, the apparatus 400 may include a processor 410 and a memory 420 storing a computer program. When the computer program is executed by the processor 410, the apparatus 400 is enabled to execute the steps of a UI automated testing method 100 based on coordinate positioning as Figure 1 shown. In one example, the apparatus 400 may be a computer device or a cloud computing node. The apparatus 400 can input the coordinates and operation keywords of the interface elements required for test case operations; call and execute a UI automated testing script based on the coordinates and operation keywords of the interface elements to simulate user interface operations; and record the execution results of the test cases and save the screenshots of the interface during runtime, and generate a test report after the script execution is completed.

[0059] In some embodiments of the present disclosure, the apparatus 400 can measure the operation coordinates of the interface elements required for test cases at the reference resolution; create a test case file in a data table format, and the test case file includes the test case name and the operation coordinates and operation keywords of the interface elements required for the test case, and the operation types corresponding to the operation keywords include wait, click, input, and slide.

[0060] In some embodiments of the present disclosure, the apparatus 400 can encapsulate the coordinate positioning method for resolution adaptation, the assertion method for test results, the operation method for the mouse, the screen capture method, the exception handling method, the processing method for the fault tolerance mechanism, and the method for processing multi-threaded test tasks based on the Jenkins distributed architecture in the UI automated testing script.

[0061] In some embodiments of the present disclosure, the apparatus 400 can read the operation coordinates and operation keywords from the test case file in a data table format; call the corresponding operation method according to the operation keywords, and simulate the operation behavior of the user interface based on the current operation coordinates.

[0062] In some embodiments of the present disclosure, after each test case is executed, the device 400 can capture the test results through assertion and logging functions; when a failed test case is executed, a screen shot is automatically saved, and a detailed test report is generated through Allure. The test report includes the execution time, execution status, error type, comparison between the execution result and the expected result, and the screen shot of the test failure for each test case.

[0063] In an embodiment of the present disclosure, the processor 410 can be, for example, a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a processor based on a multi-core processor architecture, etc. The memory 420 can be any type of memory implemented using data storage technology, including but not limited to random access memory, read-only memory, semiconductor-based memory, flash memory, disk memory, etc.

[0064] In addition, in an embodiment of the present disclosure, the device 400 may also include an input device 430, such as a keyboard, a mouse, etc., for inputting the name of the Excel file to be executed and the type of operation to be performed. Additionally, the device 400 may further include an output device 440, such as a display, etc., for outputting the test results and the screen shots.

[0065] In other embodiments of the present disclosure, a computer-readable storage medium storing a computer program is further provided, wherein the computer program, when executed by a processor, can implement the steps of the UI automation test method 100 based on coordinate positioning as Figure 1 shown.

[0066] In summary, according to the UI automation test method and device based on coordinate positioning in the embodiments of the present disclosure, there is no need to understand complex codes and frameworks. Testers only need to provide the screen coordinates of the controls and related operations, reducing the complexity of UI recognition and positioning. Even without writing too much code, the test cases can be written, lowering the threshold of automated testing, enabling the rapid completion of test script writing, and saving the creation time of test cases. Multiple test cases can be executed simultaneously, unaffected by changes in control attributes, style designs, etc., and can be applied to almost all types of graphical interface applications, including desktop applications, web applications, mobile applications, etc., improving the test efficiency.

[0067] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatuses and methods according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions noted in the blocks may occur in a different order than that noted in the accompanying drawings. For example, two consecutive blocks may in fact be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or acts, or by a combination of dedicated hardware and computer instructions.

[0068] Unless the context clearly dictates otherwise, the singular forms of the words used in this specification and the appended claims include the plural, and vice versa. Thus, when reference is made to the singular, it generally includes the plural of the corresponding term. Similarly, the phrases "comprises" and "comprising" are to be construed as inclusive rather than exclusive. Likewise, the term "or" should be interpreted as inclusive, unless expressly prohibited by the context of this application. Where the term "exemplary" is used herein, particularly when it is placed after a list of terms, the "exemplary" is merely illustrative and explanatory and should not be considered exclusive or extensive.

[0069] Further aspects and scopes of adaptability become apparent from the description provided herein. It should be understood that the various aspects of the present application may be implemented alone or in combination with one or more other aspects. It should also be understood that the description herein and the specific embodiments are for illustrative purposes only and are not intended to limit the scope of the present application.

[0070] The above has described in detail several embodiments of the present disclosure. However, it is obvious that those skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the present disclosure. The protection scope of the present disclosure is defined by the appended claims.

Claims

1. A UI automation testing method based on coordinate positioning, characterized in that: include: Enter the coordinates of the interface elements and operation keywords required for the test case operation; Calling and executing UI automation test scripts based on the coordinates and operation keywords of the interface elements to simulate user interface operations; as well as Record the test case execution results, save the interface screenshots during runtime, and generate a test report after the script execution is completed.

2. The UI automation testing method based on coordinate positioning according to claim 1, characterized in that: The coordinates of the interface elements and operation keywords required for entering the test case operation include: Measuring the manipulation coordinates of the interface elements required for the test case at the baseline resolution; and Create a test case file in a data table format, which includes the test case name and the interface element operation coordinates and operation keywords required for the test case. The operation types corresponding to the operation keywords include wait, click, input, and slide.

3. The UI automation testing method based on coordinate positioning according to claim 1, characterized in that: The UI automated test script modularly encapsulates a coordinate positioning method for resolution adaptation, a test result assertion method, a mouse operation method, a screenshot method, an exception handling method, a fault-tolerant mechanism processing method, and a method for processing multi-threaded test tasks based on a Jenkins distributed architecture based on the pytest framework.

4. The coordinate positioning based UI automated testing method according to claim 3, characterized in that: The coordinate positioning method of the resolution adaptation includes: Obtaining the resolution of the current window, and calculating the scaling ratio of the operation coordinates according to the reference resolution and the resolution of the current window; and Based on the scaling factor and the operating coordinates at the reference resolution, current operating coordinates are calculated.

5. The UI automated testing method based on coordinate positioning according to claim 3, characterized in that: The processing method of the fault tolerance mechanism includes: Set fixed waits for operations that are known to be time-consuming; Set up an explicit waiting mechanism for operations that are unknown in duration and depend on UI state; and Set a retry mechanism for failed operations and retry the operation until the maximum number of retries is reached or it succeeds.

6. The coordinate positioning based UI automated testing method according to claim 4, characterized in that: The calling and executing of the UI automation test script based on the coordinates and operation keywords of the interface elements to simulate the user interface operation includes: Reading operation coordinates and operation keywords from the test case file in the data table format; and The corresponding operation method is called according to the operation keyword, and the operation behavior of the user interface is simulated based on the current operation coordinates.

7. The UI automated testing method based on coordinate positioning according to claim 1, characterized in that: The test case execution results are recorded, and the interface screenshots are saved during runtime. After the script execution is completed, a test report is generated, including: Capture test results after each test case is executed through assertions and logging capabilities; and Automatically save screenshots when failed test cases are executed and generate detailed test reports through Allure.

8. The coordinate positioning-based UI automated testing method according to claim 7, characterized in that: The test report includes the execution time, execution status, error type, comparison of execution results with expected results, and screenshots of test failures for each test case.

9. A UI automation testing device based on coordinate positioning, characterized in that: The device comprises: at least one processor; and at least one memory storing a computer program; Wherein, when the computer program is executed by the at least one processor, the device executes the steps of the UI automation testing method based on coordinate positioning according to any one of claims 1 to 8.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the UI automation testing method based on coordinate positioning according to any one of claims 1 to 8.

Citation Information

Cited By

  • Interface testing method and device and electronic equipment

    CN121579351A