An interface test method, device, computer equipment and storage medium

By acquiring the layout information and identifiers of the interface elements on the display screen, the problem of not being able to perform synchronous testing on multi-screen terminal devices in the existing technology is solved, realizing efficient automated testing of multi-screen interfaces, reducing labor costs and improving testing efficiency.

CN119883897BActive Publication Date: 2026-05-12CHENGDU GREAT WALL MOTOR R&D CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHENGDU GREAT WALL MOTOR R&D CO LTD
Filing Date
2024-12-24
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing interface testing tools cannot support simultaneous automated testing of multiple displays, resulting in low testing efficiency for multi-screen terminal devices.

Method used

By obtaining the layout information of the interface elements and the display screen identifier, the element positioning information of the interface elements is determined and added to the test script file to achieve synchronous testing of multiple displays.

Benefits of technology

实现了对多个显示屏的同时界面自动化测试,降低了人工成本,提升了测试效率,并提高了元素定位的精确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883897B_ABST
    Figure CN119883897B_ABST
Patent Text Reader

Abstract

The application provides an interface test method and device, computer equipment and a storage medium. The method is applied to the computer field and includes the following steps: a computer equipment acquires interface element layout information of a display screen by receiving a user's off-screen operation event for the display screen. When detecting an interactive operation for an interface element, element positioning information of the interface element is determined based on the interface element layout information and the display screen identifier. The element positioning information of the interface element and the operation record are added to a test script file. When receiving a test instruction, at least one display screen is tested according to the test script file. The above method realizes automatic interface testing of multiple display screens at the same time, reduces the labor cost, and improves the test efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more specifically, to an interface testing method, apparatus, computer device, and storage medium in the field of computers. Background Technology

[0002] With the development of technology, automated interface testing technology has provided reliable assurance for software development. However, existing interface testing tools are all designed based on a single display screen. When a terminal device has multiple displays, existing interface testing tools do not support simultaneous automated interface testing on multiple displays, which greatly reduces the testing efficiency of multi-screen terminal devices. Summary of the Invention

[0003] This application provides an interface testing method, apparatus, computer device, and storage medium. The method enables simultaneous automated interface testing of multiple displays, reducing labor costs and improving testing efficiency.

[0004] Firstly, a method for testing interfaces is provided. This method includes: in response to an off-screen operation event targeting a target display screen, acquiring layout information of interface elements on the target display screen; when a target interactive operation is detected on a target interface element on the target display screen, determining target element positioning information of the target interface element based on the layout information of the interface elements and the target display screen identifier; adding the target element positioning information and a target operation record of the target interface element to a test script file, the target operation record including the target interface element and the target interactive operation; and if a test instruction is received, testing at least one interface element to be tested on a display screen to be tested based on the test script file.

[0005] The above technical solution acquires the layout information of the display screen's interface elements by detecting off-screen operation events. Upon detecting an interaction with an interface element, the element's location information is determined based on the layout information and the display screen identifier. The element's location information and operation records are added to a test script file. Upon receiving a test command, at least one display screen is tested according to the test script file. This method enables automated interface testing of multiple display screens simultaneously, reducing labor costs and improving testing efficiency.

[0006] In conjunction with the first aspect, in some possible implementations, the step of obtaining the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen includes: obtaining the interface element label information of the target display screen in response to an off-screen operation event for the target display screen; and parsing the interface element label information to construct a tree-structured interface element layout information.

[0007] In combination with the first aspect and the above implementation methods, in some possible implementation methods, before the step of obtaining the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen, the method further includes: obtaining display screen information of multiple display screens; and creating multiple test execution units in the test script file based on the number of display screens of the multiple display screens.

[0008] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the step of testing at least one interface element in a display screen to be tested based on a test script file if a test instruction is received includes: if a test instruction is received, determining at least one interface element in a display screen to be tested through element positioning information in the test script file; allocating a test execution unit for each display screen to be tested; and testing the interface element in the display screen to be tested in the test execution unit corresponding to each display screen to be tested.

[0009] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the test execution unit corresponding to each display screen to be tested shall perform test steps on the interface elements to be tested on the display screen to be tested, including: in each test execution unit corresponding to the display screen to be tested, obtaining the operation record corresponding to the interface elements to be tested on the display screen to be tested; calling the operation function of the interaction operation in the operation record, interacting with the interface elements to be tested through the operation function, and obtaining the interaction result; and determining whether the interface elements to be tested pass the test based on the interaction result.

[0010] Combining the first aspect and the above implementation methods, in some possible implementation methods, after adding the target element location information and the target operation record steps of the target interface element to the test script file, it also includes: determining the target assertion statement based on the target interface element and the target expected result corresponding to the target interaction operation; determining the target interface element as the target assertion point, and inserting the target assertion statement at the target assertion point.

[0011] Combining the first aspect and the above implementation methods, in some possible implementation methods, the step of determining whether the interface element under test passes the test based on the interaction result includes: comparing the expected result of the assertion statement corresponding to the interface element under test with the interaction result to obtain a comparison result; if the comparison result indicates that the expected result is the same as the interaction result, then it is determined that the interface element under test passes the test; if the comparison result indicates that the expected result is different from the interaction result, then it is determined that the interface element under test fails the test, and a repair prompt for the interface element under test is output.

[0012] Secondly, an interface testing apparatus is provided, the apparatus comprising:

[0013] The interface element acquisition unit is used to respond to off-screen operation events for the target display screen and acquire the layout information of the interface elements of the target display screen.

[0014] The element positioning unit is used to determine the target element positioning information of the target interface element based on the interface element layout information and the target display screen identifier of the target display screen when a target interactive operation on the target interface element in the target display screen is detected.

[0015] The script generation unit is used to add target element location information and target operation records of target interface elements to the test script file. The target operation records include target interface elements and target interaction operations.

[0016] The test unit is used to test at least one interface element on the display screen to be tested based on a test script file if a test instruction is received.

[0017] Thirdly, a computer device is provided, the computer device comprising: a memory for storing executable program code;

[0018] A processor for calling and running executable program code from memory to perform the methods in the first aspect or any possible implementation of the first aspect described above.

[0019] Fourthly, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.

[0020] Fifthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof. Attached Figure Description

[0021] Figure 1 This is a system architecture diagram of an interface testing method provided in an embodiment of this application;

[0022] Figure 2 This is a flowchart illustrating an interface testing method provided in an embodiment of this application;

[0023] Figure 3 This is a flowchart illustrating an interface testing method provided in an embodiment of this application;

[0024] Figure 4 This is a schematic diagram of an assertion check provided in an embodiment of this application;

[0025] Figure 5 This is a schematic diagram of an interface testing process provided in an embodiment of this application;

[0026] Figure 6 This is a schematic diagram of the structure of an interface testing device provided in an embodiment of this application;

[0027] Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0028] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0029] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.

[0030] Please see Figure 1 , Figure 1 This is a system architecture diagram of an interface testing method provided in an embodiment of this application. For example... Figure 1 As shown, the interface testing method provided in this application embodiment can be applied to a computer device 10. The computer device 10 is connected to a terminal device 20 with multiple displays, and performs interface testing on the displays of the terminal device 20. The terminal device 20 can be a vehicle, a multi-screen computer, a multi-screen medical device, or a multi-screen industrial device, etc. The test script file used by the computer device 10 for interface testing can be generated by an interface testing tool. The computer device 10 obtains display information of the terminal device 20 through the connection between the computer device 10 and the terminal device 20, and simultaneously monitors user interactions with interface elements on the display. Based on the user's interactions with the interface elements, script code is automatically generated, thus obtaining the test script file. However, in related technologies, the computer device 10 can only monitor one display of the terminal device 20, and the generated test script file can only be used to test one display.

[0031] To address the aforementioned issues, this application provides an interface testing method. A computer device receives off-screen operation events for a display screen and obtains the interface element layout information of that display screen. Upon detecting an interactive operation on an interface element, the element positioning information of the interface element is determined based on the interface element layout information and the display screen identifier. The element positioning information and operation records of the interface elements are added to a test script file. Upon receiving a test instruction, at least one display screen is tested according to the test script file. Through this method, when performing off-screen operations on other display screens, the monitoring perspective of the computer device can be switched, enabling the interface testing tool in the computer device to obtain the interface element layout information of multiple display screens and monitor user interactions with interface elements on multiple display screens. This achieves automated interface testing of multiple display screens simultaneously, reducing labor costs and improving testing efficiency.

[0032] based on Figure 1 The system architecture diagram shown below will be used in conjunction with... Figures 2-5 This paper provides a detailed description of the interface testing method provided in the embodiments of this application.

[0033] Please see Figure 2 , Figure 2 This is a flowchart illustrating an interface testing method provided in an embodiment of this application. Figure 2 As shown, the method in this application embodiment may include the following steps S101-S104.

[0034] S101, the computer device responds to an off-screen operation event for the target display screen and obtains the layout information of the interface elements of the target display screen.

[0035] Specifically, the computer device responds to user off-screen operation events on the target display screen of the terminal device and obtains the interface element layout information of the target display screen. The computer device is equipped with an interface testing tool, which monitors the terminal device's display screen through its recording function. When the computer device captures a user's off-screen operation event on the target display screen through the interface testing tool's recording function, it switches the recording focus to the target display screen, allowing the interface testing tool to obtain the interface element layout information of the target display screen. Off-screen operation events are touch operations that occur outside the display view of the screen. Interface elements include, but are not limited to, controls on the display screen such as buttons, sliders, and input boxes. The interface element layout information is represented by a tree structure, which clearly shows the nesting relationships between interface elements. Each node in the tree structure is an interface element, and each node contains element attributes, including but not limited to element identifier (ID), element positioning method, element coordinates, and element margins.

[0036] S102, when the computer device detects a target interactive operation on a target interface element in a target display screen, it determines the target element positioning information of the target interface element based on the interface element layout information and the target display screen identifier of the target display screen.

[0037] Specifically, when a computer device captures a user's interactive operation on a target interface element on a target display screen using the recording function of an interface testing tool, it can determine the target element location information of the target interface element based on the interface element layout information and the target display screen identifier. The interactive operation includes actions such as single-click, double-click, long-press, swipe, and text input. The element location information includes unique identifiers such as element attributes or information combining these identifiers with the interface element. Since the interface testing method provided in this application can perform interface testing on terminal devices with multiple displays, to prevent duplication of element location information, a display screen identifier is added to the existing element location information to improve the accuracy of element location.

[0038] S103, The computer device adds target element location information and target operation records of target interface elements to the test script file.

[0039] Specifically, after determining the target element's location information, the computer device adds the target element's location information, along with the target operation record of the target interface element, to the test script file. The test script file is a code file automatically generated by the interface testing tool during recording, used for subsequent automated interface testing. When the target element's location information is determined, the interface testing tool adds the target element's location information to the test script file. Simultaneously, since an interface element can perform multiple interactive operations—for example, a button element can perform single-click, double-click, and long-press operations—the test script file also needs to add the target operation record of the target interface element. The target operation record includes the target interface element and the target interactive operation, enabling accurate determination of the interactive operation for the interface element based on the operation record during automated testing based on the test script file, and subsequently calling the corresponding operation function. The operation function is the operation method pre-encapsulated in the test script file.

[0040] S104, if the computer device receives a test instruction, it tests at least one interface element on the display screen to be tested based on the test script file.

[0041] Specifically, when a computer device receives a test instruction, it tests at least one interface element on the terminal device's display screen based on a test script file generated by an interface testing tool. During testing, the element location information in the test script file is parsed to locate the interface element on the display screen. The operation record for each interface element in the test script file is obtained, and the corresponding operation function is called based on the interaction operations in the operation record to achieve interaction with the interface element and obtain the interaction result. The test result is determined based on the interaction result.

[0042] In this embodiment, the computer device obtains the interface element layout information of the display screen by receiving off-screen operation events from the user. Upon detecting an interactive operation on an interface element, the element positioning information of the interface element is determined based on the interface element layout information and the display screen identifier. The element positioning information and operation records are added to a test script file. Upon receiving a test instruction, at least one display screen is tested according to the test script file. This method enables automated interface testing of multiple display screens simultaneously, reducing labor costs and improving testing efficiency.

[0043] Please see Figure 3 This is a flowchart illustrating an interface testing method provided in an embodiment of this application. Figure 3 As shown, the method in this application embodiment may include the following steps S201-S209.

[0044] S201, The computer device obtains display information from multiple displays of the terminal device, and creates multiple test execution units in the test script file based on the number of displays.

[0045] Specifically, a computer device connects to a terminal device with multiple displays. The computer device obtains display information from all displays of the terminal device through an installed interface testing tool. Based on the number of displays, test execution units corresponding to the number of displays are created in the test script file. The display information includes, but is not limited to, display identifiers, display resolutions, and display frame rates. The display identifier serves as a unique identifier for multiple displays; the display resolution is used to determine the position and margins of interface elements during subsequent element positioning; and the display frame rate is used to determine the performance and response speed of the display interface. The interface testing tool has a recording function, which monitors the multiple displays of the terminal device connected to the computer device. The test script file is the code file written by the interface testing tool during the recording process and is used for subsequent automated interface testing. The test execution units are used to implement parallel testing of multiple displays; the test execution units can be in the form of threads or processes.

[0046] S202, the computer device responds to an off-screen operation event for the target display screen and obtains the interface element label information of the target display screen.

[0047] Specifically, in response to off-screen operation events targeting a target display screen on a terminal device, the computer device acquires the interface element label information of the target display screen. With the recording function of an interface testing tool, the computer device can capture user off-screen operation events on the target display screen, and then switch the focus of the recording function to the target display screen to obtain the interface label information of the currently displayed interface. Off-screen operation events are touch operations that occur outside the display view of the screen. Interface elements include, but are not limited to, controls on the display screen such as buttons, sliders, and input boxes. The interface element label information is the interface source code of the display screen. The interface source code defines the content and layout of the interface elements on the display screen in the form of HyperText Markup Language (HTML) or Extensible Markup Language (XML), including the color, font, margins, alignment, etc. of the interface elements.

[0048] S203, The computer device parses the interface element label information based on the interface testing tool to construct a tree-structured interface element layout information.

[0049] Specifically, computer devices use HTML or XML parsers in interface testing tools to parse interface element tag information, thereby constructing a tree-structured interface element layout. This tree-structured layout clearly shows the nesting relationships between elements on the display screen. Nodes are the basic units of the tree structure, which expands from the root node to its child elements and deeper levels. Each node in the tree structure represents an interface element, and each node contains element attributes. These attributes include, but are not limited to, element ID, element positioning method, element coordinates, and element margins. The element identifier is the element's ID, used to uniquely identify an interface element. Element coordinates and margins are determined based on the obtained display screen resolution. Element positioning methods include, but are not limited to, positioning based on the nesting relationship of interface elements and positioning based on the element ID. It should be noted that the element positioning method in the interface element layout information can only locate interface elements on a single display screen.

[0050] S204, when the computer device detects a target interactive operation on a target interface element in a target display screen, it determines the target element positioning information of the target interface element based on the interface element layout information and the target display screen identifier of the target display screen.

[0051] Specifically, when a computer device captures a user's target interaction operation on a target interface element on a target display screen using the recording function of an interface testing tool, it can determine the target element location information of the target interface element based on the interface element layout information and the target display screen identifier. The interaction operation includes actions such as single-click, double-click, long-press, swipe, and text input. The element location information includes unique identifiers such as element attributes or information combining identifiers of the interface element. The interface testing method provided in this application embodiment can perform interface testing on terminal devices with multiple displays. Therefore, to prevent duplication of element location information, a display screen identifier is added to the existing element location information, that is, a display screen identifier is added to the element location method in step S203 to obtain the target element location information, realizing multi-screen logic for element location and improving the accuracy of element location in multi-screen interface testing.

[0052] S205, The computer device adds target element location information and target operation records of target interface elements to the test script file. The target operation records include target interface elements and target interaction operations.

[0053] Specifically, after determining the target element's location information, the computer device adds the target element's location information, along with the target operation record of the target interface element, to the test script file. Each time the target element's location information is determined, the interface testing tool adds the target element's location information to the test script file. Simultaneously, since a single interface element can perform multiple interactive operations—for example, a button element can be clicked, double-clicked, and long-pressed—the test script file also needs to add the target operation record of the target interface element. The target operation record includes the target interface element and the target interactive operation, enabling accurate determination of the interactive operation for the interface element based on the operation record during automated testing based on the test script file, and subsequently calling the corresponding operation function. The operation function is the operation method pre-encapsulated in the test script file.

[0054] S206, The computer device determines the target assertion statement based on the target interface elements and the target expected results corresponding to the target interactive operations.

[0055] Specifically, to achieve automated testing, interface testing tools in computer devices can determine target assertion statements based on the target interface elements and the expected results corresponding to the target interactive operations. Target interface elements can correspond to multiple interactive operations, each yielding different results. The expected results are determined based on the target interactive operations for the target interface elements, and target assertion statements are generated based on these expected results. The assertion statement is a Boolean expression containing the expected result. When the interactive result matches the expected result, the expression is true, and the script can continue running; when the interactive result differs from the expected result, the expression is false, the script throws an exception, and execution is interrupted.

[0056] S207, The computer device identifies the target interface element as the target assertion point and inserts the target assertion statement at the target assertion point.

[0057] Specifically, interface testing tools in computer devices identify target interface elements as target assertion points and insert target assertion statements at these points. Assertion points are checkpoints set in the code of the test script file. These checkpoints are typically set after the operation function is called to manipulate the target interface element and an interaction result is obtained, in order to compare the interaction result with the expected result.

[0058] S208, if the computer device receives a test instruction, it determines at least one interface element to be tested in the display screen to be tested through the element location information in the test script file.

[0059] Specifically, when the computer device receives a test command, it automatically runs the test script file and parses the element location information in the test script file. The test script file includes at least one element location information. All element location information is parsed, and based on the display screen identifier in the element location information, the test interface element on at least one display screen to be tested is located.

[0060] S209, the computer equipment assigns a test execution unit to each display screen to be tested, and tests the interface elements to be tested in the display screen to be tested in the test execution unit corresponding to each display screen to be tested.

[0061] Specifically, the computer equipment assigns one test execution unit to each display screen under test among multiple pre-created test execution units. Within each test execution unit corresponding to a display screen, the interface elements to be tested on that display screen are tested. This multi-test execution unit enables synchronous testing of multiple display screens. It should be noted that each display screen under test can include at least one interface element to be tested. Within each test execution unit corresponding to a display screen, the operation sequence of the interface elements to be tested on that display screen is followed according to the generation process of the test script file.

[0062] During testing, in the test execution unit corresponding to each display screen under test, the operation record corresponding to the interface element under test on the display screen is retrieved. The operation function of the interaction operation in the operation record is called, and the interaction with the interface element under test is performed through the operation function to obtain the interaction result. Based on the interaction result, it is determined whether the interface element under test passes the test. The interaction result is obtained in the form of an interface screenshot for comparison with the expected result. The specific judgment process is to compare the expected result of the assertion statement corresponding to the interface element under test with the interaction result to obtain the comparison result. If the comparison result indicates that the expected result is the same as the interaction result, the interface element under test is determined to have passed the test; if the comparison result indicates that the expected result is different from the interaction result, the interface element under test is determined to have failed the test, and a repair prompt for the interface element under test is output. Please refer to [link to relevant documentation]. Figure 4 , Figure 4 This is a schematic diagram of an assertion check process provided in an embodiment of this application. Figure 4 As shown, screenshots are taken of at least one display screen to be tested to obtain multiple interaction results. When comparing the interaction results with the expected results, the screenshots are segmented into target regions to reduce the comparison range and improve comparison efficiency. Comparisons can be made between elements within the interface or between interface images. If comparing interface elements, an element detection algorithm is used to check whether the expected interface element indicated by the expected result appears in the interaction result. If it appears, the test passes; otherwise, the test fails. If comparing interface images, an image comparison algorithm is used to determine whether the interface image of the interaction result is the same as the expected interface image of the expected result. If they are the same, the test passes; otherwise, the test fails. The test result is obtained based on the comparison results.

[0063] It should be noted that if stability testing is performed on the interface element under test, a test count threshold should be preset. At the start of the test, the number of tests on the interface element under test is recorded in real time. After the interface element passes the test, the test is repeated until the test count reaches the threshold or the test fails, thus determining the stability of the interface element and generating a test report. If the interface element fails the test, a repair prompt is output to remind the user to fix the vulnerability, and a vulnerability log is generated in the test report. Optionally, if no user vulnerability repair is detected within a preset time, the interface element under test can be skipped, and subsequent tests can be performed automatically. Please refer to [link to relevant documentation]. Figure 5 , Figure 5 This is a schematic diagram of an interface testing process provided in an embodiment of this application.

[0064] In this embodiment, a computer device acquires display information from multiple displays of a connected terminal device to create a test execution unit based on the number of displays. Upon receiving an off-screen operation event from a user, the device acquires the interface element layout information of that display. Upon detecting an interactive operation on an interface element, the device determines the element positioning information of the interface element based on the interface element layout information and the display identifier. The element positioning information and operation records are added to a test script file, and assertion statements are added to the execution logic of the interface elements in the test script file. If a test instruction is received, the device tests the interface elements to be tested on at least one display according to the test script file, determines the test results based on the assertion statements, and outputs a test report. This method achieves automated interface testing of multiple displays simultaneously, reducing labor costs and improving testing efficiency. Adding display identifiers to the element positioning information enables multi-screen element positioning, improving the accuracy of element positioning. The test execution unit enables synchronous testing of multiple displays.

[0065] based on Figure 1 The system architecture diagram will be presented below, in conjunction with... Figure 6 This application provides a detailed description of the interface testing apparatus provided in its embodiments. It should be noted that... Figure 6 The interface testing device in the present application is used to perform the test. Figures 2-5 The methods shown in the embodiments are for illustrative purposes only, illustrating the parts relevant to the embodiments of this application. For specific technical details not disclosed, please refer to this application. Figures 2-5 The example shown.

[0066] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of an interface testing device provided in an embodiment of this application. Figure 6 As shown, the interface testing device 1 in this application embodiment may include: an interface element acquisition unit 11, an element positioning unit 12, a script generation unit 13, and a testing unit 14.

[0067] The interface element acquisition unit 11 is used to acquire the interface element layout information of the target display screen in response to off-screen operation events for the target display screen.

[0068] The element positioning unit 12 is used to determine the target element positioning information of the target interface element based on the interface element layout information and the target display screen identifier of the target display screen when a target interactive operation is detected on the target interface element in the target display screen.

[0069] The script generation unit 13 is used to add target element location information and target operation records of target interface elements to the test script file. The target operation records include target interface elements and target interaction operations.

[0070] Test unit 14 is used to test at least one interface element in the display screen to be tested based on a test script file if a test instruction is received.

[0071] Optionally, the interface element acquisition unit 11 is specifically used to acquire the interface element label information of the target display screen in response to an off-screen operation event for the target display screen.

[0072] The interface element tag information is parsed to construct a tree-structured interface element layout information.

[0073] Optionally, the interface testing device 1 is specifically used to acquire display information of multiple displays;

[0074] Based on the number of displays, multiple test execution units are created in the test script file.

[0075] Optionally, the test unit 14 is specifically used to determine at least one interface element to be tested in the display screen under test by using the element positioning information in the test script file if a test instruction is received.

[0076] Assign a test execution unit to each display screen to be tested;

[0077] In the test execution unit corresponding to each display screen to be tested, the interface elements to be tested in the display screen to be tested are tested.

[0078] Optionally, the test unit 14 is specifically used to obtain the operation records corresponding to the interface elements under test in the test execution unit corresponding to each display screen under test;

[0079] Call the operation function of the interaction operation in the operation record, and interact with the interface element to be tested through the operation function to obtain the interaction result;

[0080] The test results determine whether the interface elements under test pass the test.

[0081] Optionally, the interface testing device 1 is specifically used to determine the target assertion statement based on the target interface elements and the target expected results corresponding to the target interactive operations;

[0082] The target interface element is identified as the target assertion point, and the target assertion statement is inserted at the target assertion point.

[0083] Optionally, test unit 14 is specifically used to compare the expected result of the assertion statement corresponding to the interface element to be tested with the interaction result to obtain the comparison result;

[0084] If the comparison result indicates that the expected result is the same as the interaction result, then the interface element under test is determined to have passed the test;

[0085] If the comparison result indicates that the expected result is different from the interaction result, it is determined that the interface element under test has failed the test, and a repair prompt for the interface element under test is output.

[0086] In this embodiment, a computer device acquires display information from multiple displays of a connected terminal device to create a test execution unit based on the number of displays. Upon receiving an off-screen operation event from a user, the device acquires the interface element layout information of that display. Upon detecting an interactive operation on an interface element, the device determines the element positioning information of the interface element based on the interface element layout information and the display identifier. The element positioning information and operation records are added to a test script file, and assertion statements are added to the execution logic of the interface elements in the test script file. If a test instruction is received, the device tests the interface elements to be tested on at least one display according to the test script file, determines the test results based on the assertion statements, and outputs a test report. This method achieves automated interface testing of multiple displays simultaneously, reducing labor costs and improving testing efficiency. Adding display identifiers to the element positioning information enables multi-screen element positioning, improving the accuracy of element positioning. The test execution unit enables synchronous testing of multiple displays.

[0087] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application.

[0088] For example, such as Figure 7 As shown, the computer device 700 includes a processor 701 and a memory 702, wherein the processor 701 is electrically connected to the memory 702.

[0089] Processor 701 is the control center of computer device 700 and may include one or more processing cores. Processor 701 connects to various parts of the computer device using various interfaces and lines. By running or calling computer programs stored in memory 702, and by calling data stored in memory 702, it executes various functions of the computer device and processes data, thereby providing overall control of computer device 700. Optionally, processor 701 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 701 may integrate one or more of the following: CPU, Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user page, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 701 and may be implemented separately through a communication chip.

[0090] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the computer programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function, etc.; the data storage area may store data created based on the use of the computer device 700, etc.

[0091] Furthermore, memory 702 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, memory 702 may also include a memory controller to provide processor 701 with access to memory 702.

[0092] In this embodiment, the processor 701 in the computer device 700 loads the instructions corresponding to the processes of one or more computer programs into the memory 702 according to the following steps, and the processor 701 runs the computer programs stored in the memory 702 to realize various functions, as follows:

[0093] In response to off-screen operation events targeting the target display, obtain the layout information of the interface elements on the target display.

[0094] When a target interactive operation is detected on a target interface element in a target display screen, the target element positioning information of the target interface element is determined based on the interface element layout information and the target display screen identifier of the target display screen.

[0095] Add target element location information and target operation records for target UI elements to the test script file. The target operation records include target UI elements and target interaction operations.

[0096] If a test instruction is received, at least one interface element on the display screen to be tested is tested based on the test script file.

[0097] Optionally, when the processor 701 executes the following in response to an off-screen operation event for the target display screen and obtains the layout information of the interface elements of the target display screen:

[0098] In response to off-screen operation events targeting the target display, obtain the interface element label information of the target display;

[0099] The interface element tag information is parsed to construct a tree-structured interface element layout information.

[0100] Optionally, before executing the process of obtaining the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen, the processor 701 also executes:

[0101] Obtain display information from multiple displays;

[0102] Based on the number of displays, multiple test execution units are created in the test script file.

[0103] Optionally, when the processor 701 executes the command to test at least one interface element on the display screen under test based on the test script file upon receiving a test instruction, it specifically performs the following:

[0104] If a test instruction is received, at least one interface element to be tested in the display screen to be tested is determined by the element location information in the test script file.

[0105] Assign a test execution unit to each display screen to be tested;

[0106] In the test execution unit corresponding to each display screen to be tested, the interface elements to be tested in the display screen to be tested are tested.

[0107] Optionally, when the processor 701 executes tests on the interface elements to be tested in the test execution unit corresponding to each display screen under test, it specifically performs the following:

[0108] In the test execution unit corresponding to each display screen to be tested, the operation records corresponding to the interface elements to be tested in the display screen to be tested are obtained;

[0109] Call the operation function of the interaction operation in the operation record, and interact with the interface element to be tested through the operation function to obtain the interaction result;

[0110] The test results determine whether the interface elements under test pass the test.

[0111] Optionally, after executing the steps to add target element location information and target operation records of target interface elements to the test script file, processor 701 also executes:

[0112] The target assertion statement is determined based on the target interface elements and the target interactive operation corresponding to the expected result.

[0113] The target interface element is identified as the target assertion point, and the target assertion statement is inserted at the target assertion point.

[0114] Optionally, when processor 701 executes the following steps to determine whether the interface element under test passes the test based on the interaction result:

[0115] The expected results of the assertion statements corresponding to the elements of the interface to be tested are compared with the interaction results to obtain the comparison results;

[0116] If the comparison result indicates that the expected result is the same as the interaction result, then the interface element under test is determined to have passed the test;

[0117] If the comparison result indicates that the expected result is different from the interaction result, it is determined that the interface element under test has failed the test, and a repair prompt for the interface element under test is output.

[0118] In this embodiment, a computer device acquires display information from multiple displays of a connected terminal device to create a test execution unit based on the number of displays. Upon receiving an off-screen operation event from a user, the device acquires the interface element layout information of that display. Upon detecting an interactive operation on an interface element, the device determines the element positioning information of the interface element based on the interface element layout information and the display identifier. The element positioning information and operation records are added to a test script file, and assertion statements are added to the execution logic of the interface elements in the test script file. If a test instruction is received, the device tests the interface elements to be tested on at least one display according to the test script file, determines the test results based on the assertion statements, and outputs a test report. This method achieves automated interface testing of multiple displays simultaneously, reducing labor costs and improving testing efficiency. Adding display identifiers to the element positioning information enables multi-screen element positioning, improving the accuracy of element positioning. The test execution unit enables synchronous testing of multiple displays.

[0119] It should be understood that the apparatus provided in this application embodiment is used to execute the above-described interface testing method, and therefore can achieve the same effect as the above-described implementation method.

[0120] When using integrated units, the device may include a processing module and a storage module. When applied to a computer device, the processing module can be used to control and manage the operations of the computer device. The storage module can be used to support the computer device in executing relevant program code, etc.

[0121] The processing module may be a processor or a controller, which can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.

[0122] In addition, the device provided in this application embodiment may specifically be a chip, component or module. The chip may include a connected processor and a memory. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can execute an interface testing method provided in the above embodiment.

[0123] This application also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the above-described related method steps to implement the interface testing method provided in the above embodiments.

[0124] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the interface testing method provided in the above embodiment.

[0125] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0126] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0127] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0128] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for testing user interfaces, characterized in that, The method includes: In response to an off-screen operation event targeting a target display screen among multiple displays, obtain the interface element layout information of the target display screen; When a target interactive operation is detected on a target interface element in the target display screen, the target element positioning information of the target interface element is determined based on the interface element layout information and the target display screen identifier of the target display screen; the target element positioning information includes: element attributes and target display screen identifier; Add the target element location information and the target operation record of the target interface element to the test script file. The target operation record includes the target interface element and the target interaction operation. If a test instruction is received, at least one interface element on the display screen to be tested is tested based on the test script file.

2. The method according to claim 1, characterized in that, The step of obtaining the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen includes: In response to an off-screen operation event targeting the target display screen, obtain the interface element label information of the target display screen; The interface element label information is parsed to construct a tree-structured interface element layout information.

3. The method according to claim 1, characterized in that, Before obtaining the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen, the method further includes: Obtain display information from multiple displays; Based on the number of displays, multiple test execution units are created in the test script file.

4. The method according to claim 3, characterized in that, If a test instruction is received, the test script file is used to test at least one interface element on the display screen to be tested, including: If a test instruction is received, at least one interface element to be tested in the display screen to be tested is determined by the element location information in the test script file. Assign a test execution unit to each of the aforementioned display screens to be tested; In each test execution unit corresponding to the display screen to be tested, the interface elements to be tested in the display screen to be tested are tested.

5. The method according to claim 4, characterized in that, The step of testing the interface elements to be tested in each test execution unit corresponding to the test display screen includes: In each test execution unit corresponding to the display screen to be tested, the operation records corresponding to the interface elements to be tested in the display screen to be tested are obtained; The operation function of the interaction operation in the operation record is called, and the interaction with the interface element to be tested is carried out through the operation function to obtain the interaction result; Based on the interaction results, determine whether the interface element to be tested passes the test.

6. The method according to claim 5, characterized in that, After adding the target element location information and the target operation record of the target interface element to the test script file, the method further includes: The target assertion statement is determined based on the target interface elements and the target expected results corresponding to the target interaction operations; The target interface element is identified as the target assertion point, and the target assertion statement is inserted at the target assertion point.

7. The method according to claim 6, characterized in that, The step of determining whether the interface element under test passes the test based on the interaction result includes: The expected result of the assertion statement corresponding to the interface element to be tested is compared with the interaction result to obtain the comparison result; If the comparison result indicates that the expected result is the same as the interaction result, then the interface element to be tested is determined to have passed the test; If the comparison result indicates that the expected result is different from the interaction result, it is determined that the interface element under test has failed the test, and a repair prompt for the interface element under test is output.

8. An interface testing device, characterized in that, The device includes: The interface element acquisition unit is used to acquire the interface element layout information of the target display screen in response to an off-screen operation event for the target display screen among multiple display screens. An element positioning unit is used to determine the target element positioning information of a target interface element based on the interface element layout information and the target display screen identifier when a target interactive operation is detected on a target interface element in the target display screen; the target element positioning information includes: element attributes and target display screen identifier; The script generation unit is used to add the target element positioning information and the target operation record of the target interface element to the test script file. The target operation record includes the target interface element and the target interaction operation. The testing unit is used to test at least one interface element in a display screen to be tested based on the test script file if a test instruction is received.

9. A computer device, characterized in that, The computer device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the computer device to perform the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program code that, when executed, implements the method as described in any one of claims 1 to 7.