Interface testing method and device, computer equipment and storage medium
By acquiring and processing interface element layout information and interactive operation of multiple display screens, the problem that the existing technology cannot test multiple display screens simultaneously is solved, and efficient interface automation testing is achieved, reducing costs and improving testing efficiency.
Patent Information
- Application Number
- CN202411911729.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-24
AI Technical Summary
The existing interface testing tools cannot support multiple display screens to perform interface automation testing at the same time, resulting in a greatly reduced test efficiency of multi-screen terminal devices.
By responding to off-screen operation events of the display screen, the interface element layout information of the display screen is obtained, and when an interaction is detected, the element positioning information of the interface element is determined. Add this information to the test script file, and after receiving the test instructions, multiple display screens are tested based on the script file.
It realizes the interface automation test of multiple display screens simultaneously, reducing labor costs and improving testing efficiency. By adding display logos to element positioning information, the accuracy of multi-screen element positioning is improved.
Smart Images

Figure CN119883897A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the computer field, and more specifically, to an interface testing method, apparatus, computer equipment and storage medium in the computer field. Background Art
[0002] With the development of science and technology, interface automation testing technology provides a reliable guarantee for software development. However, existing interface testing tools are designed based on a single display screen. When the terminal device has multiple displays, the existing interface testing tools do not support simultaneous interface automation testing of multiple displays, which greatly reduces the testing efficiency of multi-screen terminal devices. Summary of the invention
[0003] The present application provides an interface testing method, apparatus, computer equipment and storage medium, which can realize automatic interface testing of multiple display screens at the same time, reduce labor costs and improve testing efficiency.
[0004] In a first aspect, an interface testing method is provided, the method comprising: in response to an off-screen operation event for a target display screen, obtaining interface element layout information of a target display screen; when a target interaction operation for a target interface element in a target display screen is detected, determining target element positioning information of the target interface element based on the interface element layout information and a target display screen identifier of the target display screen; 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 interaction operation; if a test instruction is received, testing the interface element to be tested in at least one display screen to be tested based on the test script file.
[0005] Through the above technical solution, the interface element layout information of the display screen is obtained through the off-screen operation events for the display screen. When an interactive operation on the interface element is detected, 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 record of the interface element are added to the test script file, and when the test instruction is received, at least one display screen is tested according to the test script file. The above method realizes the simultaneous automatic interface testing of multiple display screens, reduces labor costs, and improves test efficiency.
[0006] In combination with the first aspect, in some possible implementations, the step of obtaining interface element layout information of the target display screen in response to an off-screen operation event for the target display screen includes: obtaining interface element label information of the target display screen in response to an off-screen operation event for the target display screen; parsing the interface element label information to construct interface element layout information with a tree structure.
[0007] In combination with the first aspect and the above-mentioned 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 the off-screen operation event for the target display screen, it also 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-mentioned implementation methods, in some possible implementation methods, if a test instruction is received, a test step is performed on the interface elements to be tested in at least one display screen to be tested based on the test script file, including: if a test instruction is received, determining the interface elements to be tested in at least one display screen to be tested through the element positioning information in the test script file; allocating a test execution unit to each display screen to be tested; and testing 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.
[0009] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, in the test execution unit corresponding to each display screen to be tested, the test steps are performed on the interface elements to be tested in the display screen to be tested, including: in the test execution unit corresponding to each display screen to be tested, obtaining the operation record corresponding to the interface elements to be tested in the display screen to be tested; calling the operation function of the interactive operation in the operation record, interacting with the interface elements to be tested through the operation function, and obtaining the interaction result; and judging whether the interface elements to be tested pass the test based on the interaction result.
[0010] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, after adding the target element positioning information and the target operation recording step of the target interface element in 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 interactive operation; determining the target interface element as the target assertion point, and inserting the target assertion statement at the target assertion point.
[0011] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the step of judging whether the interface element to be tested has passed the test based on the interaction result includes: comparing the expected result of the assertion statement corresponding to the interface element to be tested 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, it is determined that the interface element to be tested has 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 to be tested has not passed the test, and a repair prompt for the interface element to be tested is output.
[0012] In a second aspect, an interface testing device is provided, the device comprising:
[0013] An interface element acquisition unit, configured to acquire interface element layout information of a target display screen in response to an off-screen operation event on the target display screen;
[0014] an element positioning unit, configured to determine 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 interaction operation on the target interface element in the target display screen is detected;
[0015] A script generation unit, used to add target element location information and target operation records of target interface elements in a test script file, wherein the target operation records include target interface elements and target interactive operations;
[0016] The testing unit is used to test the interface elements to be tested in at least one display screen to be tested based on the test script file if a test instruction is received.
[0017] In a third aspect, a computer device is provided, the computer device comprising: a memory for storing executable program code;
[0018] A processor is used to call and run executable program code from a memory to execute the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0019] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.
[0020] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a system architecture diagram of an interface testing method provided in an embodiment of the present application;
[0022] Figure 2 It is a flowchart of an interface testing method provided in an embodiment of the present application;
[0023] Figure 3 It is a flowchart of an interface testing method provided in an embodiment of the present application;
[0024] Figure 4 It is a flowchart of an assertion check provided by an embodiment of the present application;
[0025] Figure 5 It is a flowchart of an interface test provided in an embodiment of the present application;
[0026] Figure 6 is a structural schematic diagram of an interface testing device provided in an embodiment of the present application;
[0027] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0029] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying 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 the features.
[0030] See also Figure 1 , Figure 1 : is a system architecture diagram of an interface testing method provided in an embodiment of the present application. Figure 1 As shown, the interface testing method provided in the embodiment of the present application can be applied to a computer device 10. The computer device 10 is connected to a terminal device 20 having multiple display screens, and an interface test is performed on the display screen of the terminal device 20. The terminal device 20 can be a vehicle, a multi-screen computer, a multi-screen medical device, a multi-screen industrial device, and other devices. The test script file based on which the computer device 10 performs the interface testing method can be generated by an interface testing tool, and the display screen information of the terminal device 20 is obtained through the connection between the computer device 10 and the terminal device 20, while monitoring the user's interactive operations on the interface elements in the display screen, and automatically generating script code according to the user's interactive operations on the interface elements, thereby obtaining a test script file. However, in the related art, the computer device 10 can only monitor one display screen of the terminal device 20, and the generated test script file can only test one display screen.
[0031] Based on the above problems, an embodiment of the present application provides an interface testing method. The computer device obtains the interface element layout information of the display screen by receiving an off-screen operation event for the display screen. When an interactive operation on the interface element is detected, 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 record of the interface element are added to the test script file, and when the test instruction is received, at least one display screen is tested according to the test script file. Through the above method, when performing off-screen operations on other display screens, the monitoring perspective of the computer device can be switched, so that the interface testing tool in the computer device obtains the interface element layout information of multiple display screens, and monitors the user's interactive operations on the interface elements in multiple display screens. The interface automation testing of multiple display screens is realized at the same time, which reduces labor costs and improves testing efficiency.
[0032] based on Figure 1 The system architecture diagram shown below will be combined with Figure 2-Figure 5 , the interface testing method provided in the embodiment of the present application is introduced in detail.
[0033] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of an interface testing method provided in an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application may include the following steps S101-S104.
[0034] S101: In response to an off-screen operation event on a target display screen, a computer device obtains interface element layout information of the target display screen.
[0035] Specifically, the computer device responds to the user's off-screen operation event on the target display screen in the terminal device, and obtains the interface element layout information of the target display screen. Among them, an interface testing tool is installed in the computer device, and the display screen of the terminal device is monitored through the recording function of the interface testing tool. When the computer device captures the user's off-screen operation event on the target display screen through the recording function of the interface testing tool, the focus of the recording function is switched to the target display screen, and the interface testing tool can obtain the interface element layout information of the target display screen. The off-screen operation event is an operation event in which the touch operation occurs outside the display view of the display screen. The interface elements include but are not limited to controls in the display screen such as buttons, sliders, and input boxes. The interface element layout information is represented by a tree structure, and the tree structure clearly shows the nested relationship between the interface elements. Each node of the tree structure is an interface element, and each node contains the element attributes of the interface element, and the element attributes include but are not limited to attribute information such as 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, 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.
[0037] Specifically, when the computer device captures the user's target interactive operation on the target interface element in the target display screen under the recording function of the interface testing tool, the target element positioning information of the target interface element can be determined based on the interface element layout information and the target display screen identifier of the target display screen. Among them, the interactive operations are single-click, double-click, long press, slide, text input and other operations. The element positioning information includes unique identifiers such as element attributes or information combined with identifiers of interface elements. The interface testing method provided in the embodiment of the present application can perform interface testing on terminal devices with multiple display screens. Therefore, in order to prevent duplication of element positioning information of interface elements, a display screen identifier is added to the existing element positioning information to improve the accuracy of element positioning.
[0038] S103, the computer device adds the target element location information and the target operation record of the target interface element to the test script file.
[0039] Specifically, after determining the target element location information, the computer device adds the target element location information and the target operation record of the target interface element to the test script file. The test script file is a code file automatically written by the interface testing tool during the recording process, which is used for subsequent interface automation testing. When the target element location information is determined, the interface testing tool adds the target element location information to the test script file. At the same time, since an interface element can perform multiple interactive operations, for example, a single-click operation, a double-click operation, and a long-press operation can be performed for a button element, the target operation record of the target interface element needs to be added to the test script file. The target operation record includes the target interface element and the target interactive operation, so that when performing automated testing based on the test script file, the interactive operation for the interface element can be accurately determined according to the operation record, and then the corresponding operation function is called. The operation function is an operation method pre-encapsulated in the test script file.
[0040] S104: If the computer device receives the test instruction, it tests the interface element to be tested in at least one display screen to be tested based on the test script file.
[0041] Specifically, when receiving the test instruction, the computer device tests the interface element to be tested in at least one display screen to be tested of the terminal device based on the test script file generated by the interface testing tool. During the test, the element positioning information in the test script file is parsed to locate the interface element to be tested in the display screen to be tested. The operation record of each interface element to be tested in the test script file is obtained, and the corresponding operation function is called according to the interactive operation in the operation record to realize the interaction with the interface element to be tested and obtain the interaction result. The test result is determined according to the interaction result.
[0042] In an embodiment of the present application, a computer device obtains the interface element layout information of a display screen by receiving an off-screen operation event of a user on the display screen. When an interactive operation on an interface element is detected, 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 record of the interface element are added to a test script file, and when a test instruction is received, at least one display screen is tested according to the test script file. The above method realizes the simultaneous automatic interface testing of multiple display screens, reduces labor costs, and improves test efficiency.
[0043] See also Figure 3 , which is a flow chart of an interface testing method provided in an embodiment of the present application. Figure 3 As shown, the method of the embodiment of the present application may include the following steps S201-S209.
[0044] S201, a computer device obtains display screen information of multiple display screens of a terminal device, and creates multiple test execution units in a test script file based on the number of display screens of the multiple display screens.
[0045] Specifically, a computer device is connected to a terminal device having multiple display screens. The computer device obtains the display screen information of all display screens of the terminal device through an installed interface testing tool, and creates a test execution unit corresponding to the number of display screens in a test script file based on the number of display screens. The display screen information includes, but is not limited to, information such as display screen identification, display screen resolution, and display screen frame rate. The display screen identification is a unique identification of multiple display screens. The display screen resolution is used to determine the position and margin size of interface elements when the elements are subsequently positioned. The display screen frame rate is used to determine the performance and response speed of the display screen interface. The interface testing tool has a recording function, which monitors multiple display screens of a terminal device connected to the computer device through the recording function. The test script file is a code file written by the interface testing tool during the recording process, which is used for subsequent interface automation testing. The test execution unit is used to implement parallel testing of multiple display screens, and the test execution unit can be in the form of a thread or a process.
[0046] S202: In response to an off-screen operation event on a target display screen, the computer device obtains interface element label information of the target display screen.
[0047] Specifically, the computer device responds to an off-screen operation event for a target display screen in the terminal device, and obtains the interface element label information of the target display screen. Under the recording function of the interface testing tool, the computer device can capture the user's 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 interface currently displayed on the target display screen. Off-screen operation events are operation events in which touch operations occur outside the display view of the display screen. Interface elements include but are not limited to controls in 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 in the display screen interface and the layout of the interface elements in the form of HyperText Markup Language (HTML) or Extensible Markup Language (XML), including the color, font, margin, alignment, etc. of the interface elements.
[0048] S203, the computer device parses the interface element tag information based on the interface testing tool to construct the interface element layout information in a tree structure.
[0049] Specifically, the computer device parses the interface element tag information through the HTML parser or XML parser in the interface testing tool, and then constructs the interface element layout information of the tree structure. The interface element layout information of the tree structure clearly shows the nested relationship between the elements in the display screen interface. The node is the basic unit of the tree structure. The tree structure starts from the root node and gradually expands to the interface elements at the child and deeper levels. Each node of the tree structure is an interface element, and each node contains the element attributes of the interface element. The element attributes include but are not limited to attribute information such as element ID, element positioning method, element coordinates, and element margins. The element identifier is the ID of the element, which is used to uniquely identify an interface element. The element coordinates and element margins are determined based on the display screen resolution obtained above. The element positioning method includes but is not limited to positioning according to the nested relationship of the interface elements and positioning according to the element ID. It should be noted that the element positioning method in the interface element layout information can only locate the interface element in 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, 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.
[0051] Specifically, when the computer device captures the user's target interactive operation on the target interface element in the target display screen under the recording function of the interface testing tool, it can 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. Among them, the interactive operations are single-click, double-click, long press, slide, text input and other operations. The element positioning information includes unique identifiers such as element attributes or information combined with identifiers of interface elements. The interface testing method provided in the embodiment of the present application can perform interface testing on terminal devices with multiple display screens. Therefore, in order to prevent duplication of element positioning information of interface elements, a display screen identifier is added to the existing element positioning information, that is, the display screen identifier is added to the element positioning method in step S203 to obtain the target element positioning information, implement the multi-screen logic of element positioning, and improve the accuracy of element positioning in multi-screen interface testing.
[0052] S205, the computer device adds target element location information and a target operation record of the target interface element to the test script file, where the target operation record includes the target interface element and the target interactive operation.
[0053] Specifically, after determining the target element location information, the computer device adds the target element location information and the target operation record of the target interface element to the test script file. After each target element location information is determined, the interface testing tool adds the target element location information to the test script file. At the same time, since a type of interface element can perform multiple interactive operations, for example, a single-click operation, a double-click operation, and a long-press operation can be performed for a button element, the target operation record of the target interface element needs to be added to the test script file. The target operation record includes the target interface element and the target interactive operation, so that when performing automated testing based on the test script file, the interactive operation for the interface element can be accurately determined based on the operation record, and then the corresponding operation function can be called. The operation function is an operation method pre-encapsulated in the test script file.
[0054] S206, the computer device determines a target assertion statement based on the target interface element and the target expected result corresponding to the target interactive operation.
[0055] Specifically, in order to achieve automated testing, the interface testing tool in the computer device can determine the target assertion statement based on the target interface element and the target expected result corresponding to the target interactive operation. The target interface element can correspond to a variety of interactive operations, and each interactive operation has different interactive results. The target expected result is determined according to the target interactive operation for the target interface element, and the target assertion statement is generated according to the target expected result. The assertion statement is a Boolean expression containing the expected result. When the interactive result is the same as the expected result, the expression is true and the script can continue to run; when the interactive result is different from the expected result, the expression is false, the script throws an exception prompt, and the operation is interrupted.
[0056] S207, the computer device determines the target interface element as a target assertion point, and inserts a target assertion statement at the target assertion point.
[0057] Specifically, the interface testing tool in the computer device determines the target interface element as the target assertion point and inserts the target assertion statement at the target assertion point. The assertion point is a checkpoint set in the code of the test script file, which is generally after calling the operation function to operate the target interface element to obtain the interaction result, so as to compare the interaction result with the expected result.
[0058] S208: If the computer device receives the test instruction, it determines the interface element to be tested in at least one display screen to be tested according to the element positioning information in the test script file.
[0059] Specifically, when receiving the test instruction, the computer device automatically runs the test script file and parses the element positioning information in the test script file. The test script file includes at least one element positioning information, all element positioning information is parsed, and the interface element to be tested in at least one display screen to be tested is located according to the display screen identifier in the element positioning information.
[0060] S209, the computer device allocates 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 device allocates a test execution unit to each display screen to be tested among the multiple test execution units created in advance, 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. The multiple test execution units are used to implement the synchronous testing of multiple display screens to be tested. It should be noted that each display screen to be tested may include at least one interface element to be tested, and in the test execution unit corresponding to each display screen to be tested, the operation sequence of the interface elements to be tested in the display screen to be tested is tested according to the generation process of the test script file.
[0062] During the test, in the test execution unit corresponding to each display screen to be tested, the operation record corresponding to the interface element to be tested in the display screen to be tested is obtained, the operation function of the interactive operation in the operation record is called, and the operation function is used to interact with the interface element to be tested to obtain the interaction result. Based on the interaction result, it is judged whether the interface element to be tested has passed 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 to be tested 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, it is determined that the interface element to be tested has 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 to be tested has not passed the test, and a repair prompt for the interface element to be tested is output. Please refer to Figure 4 , Figure 4 is a flowchart of an assertion check provided by an embodiment of the present application. Figure 4 As shown, an interface screenshot is taken for at least one display screen to be tested to obtain multiple interaction results. When comparing the interaction result with the expected result, the interface screenshot is segmented into a target area to reduce the comparison scope and improve the comparison efficiency. Elements in the interface can be compared, or interface images can be compared. If the interface elements are compared, an element detection algorithm is used to detect whether the expected interface element indicated by the expected result appears in the interaction result. If it appears, the test passes; if it does not appear, the test fails; if the interface images are compared, 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; if they are different, the test fails. The test result is obtained according to the comparison result.
[0063] It should be noted that if a stability test is performed on the interface element to be tested, a test number threshold is set in advance. When the test starts, the test number of the interface element to be tested is recorded in real time. After the interface element to be tested passes the test, the interface element to be tested is tested repeatedly until the test number reaches the test number threshold or the test fails, so as to determine the stability of the interface element to be tested and output a test report. If the interface element to be tested fails the test, a repair prompt for the interface element to be tested is output to prompt the user to repair the vulnerability of the interface element to be tested, and a vulnerability log is generated in the test report. Optionally, if the user is not detected to repair the vulnerability of the interface element to be tested within the preset time, the interface element to be tested can be skipped and subsequent test operations can be automatically performed. Please refer to Figure 5 , Figure 5 It is a flowchart of an interface test provided in an embodiment of the present application.
[0064] In an embodiment of the present application, a computer device obtains display screen information of multiple display screens of a terminal device connected thereto to create a test execution unit based on the number of display screens. When an off-screen operation event of a user on a display screen is received, the interface element layout information of the display screen is obtained. When an interactive operation on an interface element is detected, 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 record of the interface element are added to the test script file, and an assertion statement is added to the execution logic of the interface element in the test script file. If a test instruction is received, the interface element to be tested in at least one display screen is tested according to the test script file, the test result is determined according to the assertion statement, and a test report is output. The above method realizes the simultaneous interface automation testing of multiple display screens, reduces labor costs, and improves test efficiency. The display screen identifier is added to the element positioning information to realize multi-screen element positioning, which improves the accuracy of element positioning. Through the test execution unit, synchronous testing of multiple display screens is realized.
[0065] based on Figure 1 The system architecture diagram will be combined with Figure 6 , the interface testing device provided in the embodiment of the present application is introduced in detail. It should be noted that, Figure 6 The interface testing device in the present application is used to perform Figure 2-Figure 5 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 2-Figure 5 The embodiment shown.
[0066] See also Figure 6 , Figure 6 Schematic diagram of the structure of an interface testing device provided in an embodiment of the present application. Figure 6 As shown, the interface testing device 1 of the embodiment of the present application 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 the off-screen operation event for the target display screen;
[0068] An element positioning unit 12 is used to determine 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 interaction operation on the target interface element in the target display screen is detected;
[0069] The script generating unit 13 is used to add the target element location information and the target operation record of the target interface element in the test script file, wherein the target operation record includes the target interface element and the target interactive operation;
[0070] The testing unit 14 is configured to test the interface elements to be tested in at least one 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 configured to acquire interface element label information of the target display screen in response to an off-screen operation event on the target display screen;
[0072] Parse the interface element label information to construct the interface element layout information in a tree structure.
[0073] Optionally, the interface testing device 1 is specifically used to obtain display screen information of multiple display screens;
[0074] Based on the number of display screens of the multiple display screens, multiple test execution units are created in the test script file.
[0075] Optionally, the testing unit 14 is specifically configured to determine the interface element to be tested in at least one display screen to be tested according to the element positioning information in the test script file if a test instruction is received;
[0076] Allocating 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 testing unit 14 is specifically used to obtain, in a test execution unit corresponding to each display screen to be tested, an operation record corresponding to the interface element to be tested in the display screen to be tested;
[0079] Call the operation function of the interactive operation in the operation record, interact with the interface element to be tested through the operation function, and obtain the interaction result;
[0080] Determine whether the interface element to be tested passes the test based on the interaction results.
[0081] Optionally, the interface testing device 1 is specifically used to determine a target assertion statement based on a target interface element and a target expected result corresponding to a target interactive operation;
[0082] The target interface element is determined as the target assertion point, and the target assertion statement is inserted at the target assertion point.
[0083] Optionally, the testing 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 a comparison result;
[0084] If the comparison result indicates that the expected result is the same as the interaction result, it is determined that the interface element to be tested has 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 to be tested has failed the test, and a repair prompt for the interface element to be tested is output.
[0086] In an embodiment of the present application, a computer device obtains display screen information of multiple display screens of a terminal device connected thereto to create a test execution unit based on the number of display screens. When an off-screen operation event of a user on a display screen is received, the interface element layout information of the display screen is obtained. When an interactive operation on an interface element is detected, 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 record of the interface element are added to the test script file, and an assertion statement is added to the execution logic of the interface element in the test script file. If a test instruction is received, the interface element to be tested in at least one display screen is tested according to the test script file, the test result is determined according to the assertion statement, and a test report is output. The above method realizes the simultaneous interface automation testing of multiple display screens, reduces labor costs, and improves test efficiency. The display screen identifier is added to the element positioning information to realize multi-screen element positioning, which improves the accuracy of element positioning. Through the test execution unit, synchronous testing of multiple display screens is realized.
[0087] See also Figure 7 , Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application.
[0088] For example, 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] The processor 701 is the control center of the computer device 700 and may include one or more processing cores. The processor 701 uses various interfaces and lines to connect the various parts of the entire computer device, and executes various functions of the computer device and processes data by running or calling the computer program stored in the memory 702, and calling the data stored in the memory 702, so as to control the computer device 700 as a whole. Optionally, the processor 701 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 701 can integrate one or a combination of CPU, graphics processing unit (GPU), modem, etc. Among them, the CPU mainly processes the operating system, user pages, and applications; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 701, but may be implemented separately through a communication chip.
[0090] The memory 702 can be used to store software programs and modules, and 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 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, a computer program required for at least one function, etc.; the data storage area can store data created according to the use of the computer device 700, etc.
[0091] In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0092] In this embodiment, the processor 701 in the computer device 700 loads 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 program stored in the memory 702 to implement various functions, as follows:
[0093] In response to an off-screen operation event for a target display screen, obtaining interface element layout information of the target display screen;
[0094] When a target interaction operation on a target interface element in a target display screen is detected, 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 the target element location information and the target operation record of the target interface element in the test script file, the target operation record includes the target interface element and the target interactive operation;
[0096] If a test instruction is received, the interface element to be tested in at least one display screen to be tested is tested based on the test script file.
[0097] Optionally, when the processor 701 executes the acquisition of the interface element layout information of the target display screen in response to the off-screen operation event for the target display screen, the processor 701 specifically executes:
[0098] In response to an off-screen operation event for a target display screen, obtaining interface element label information of the target display screen;
[0099] Parse the interface element label information to construct the interface element layout information in a tree structure.
[0100] Optionally, before executing the acquisition of the interface element layout information of the target display screen in response to the off-screen operation event for the target display screen, the processor 701 further executes:
[0101] Get display screen information of multiple display screens;
[0102] Based on the number of display screens of the multiple display screens, multiple test execution units are created in the test script file.
[0103] Optionally, when the processor 701 receives a test instruction and tests the interface element to be tested in at least one display screen to be tested based on the test script file, the processor 701 specifically executes:
[0104] If a test instruction is received, determining the interface element to be tested in at least one display screen to be tested by using the element positioning information in the test script file;
[0105] Allocating 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 executing in the test execution unit corresponding to each display screen to be tested, the processor 701 specifically performs:
[0108] In the test execution unit corresponding to each display screen to be tested, the operation record corresponding to the interface element to be tested in the display screen to be tested is obtained;
[0109] Call the operation function of the interactive operation in the operation record, interact with the interface element to be tested through the operation function, and obtain the interaction result;
[0110] Determine whether the interface element to be tested passes the test based on the interaction results.
[0111] Optionally, after adding the target element location information and the target operation record of the target interface element to the test script file, the processor 701 further executes:
[0112] Determine a target assertion statement based on the target interface element and the target expected result corresponding to the target interactive operation;
[0113] The target interface element is determined as the target assertion point, and the target assertion statement is inserted at the target assertion point.
[0114] Optionally, when the processor 701 determines whether the interface element to be tested passes the test based on the interaction result, it specifically performs:
[0115] Compare the expected result of the assertion statement corresponding to the interface element to be tested with the interaction result to obtain a comparison result;
[0116] If the comparison result indicates that the expected result is the same as the interaction result, it is determined that the interface element to be tested has 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 to be tested has failed the test, and a repair prompt for the interface element to be tested is output.
[0118] In an embodiment of the present application, a computer device obtains display screen information of multiple display screens of a terminal device connected thereto to create a test execution unit based on the number of display screens. When an off-screen operation event of a user on a display screen is received, the interface element layout information of the display screen is obtained. When an interactive operation on an interface element is detected, 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 record of the interface element are added to the test script file, and an assertion statement is added to the execution logic of the interface element in the test script file. If a test instruction is received, the interface element to be tested in at least one display screen is tested according to the test script file, the test result is determined according to the assertion statement, and a test report is output. The above method realizes the simultaneous interface automation testing of multiple display screens, reduces labor costs, and improves test efficiency. The display screen identifier is added to the element positioning information to realize multi-screen element positioning, which improves the accuracy of element positioning. Through the test execution unit, synchronous testing of multiple display screens is realized.
[0119] It should be understood that the device provided in the embodiment of the present application is used to execute the above-mentioned interface testing method, and thus can achieve the same effect as the above-mentioned implementation method.
[0120] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to a computer device, the processing module may be used to control and manage the actions of the computer device. The storage module may be used to support the computer device in executing related program codes, etc.
[0121] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0122] In addition, the device provided in the embodiment of the present application can specifically be a chip, component or module, and the chip may include a connected processor and memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute an interface testing method provided in the above embodiment.
[0123] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement an interface testing method provided in the above-mentioned embodiment.
[0124] This embodiment also provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps to implement an interface testing method provided by the above embodiment.
[0125] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0126] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned 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 the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An interface testing method, characterized in that: The method comprises: In response to an off-screen operation event for a target display screen, acquiring interface element layout information of the target display screen; When a target interaction operation on a target interface element in the target display screen is detected, determining target element positioning information of the target interface element based on the interface element layout information and a target display screen identifier of the target display screen; Add the target element location information and the target operation record of the target interface element in the test script file, wherein the target operation record includes the target interface element and the target interactive operation; If a test instruction is received, the interface element to be tested in at least one 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, in response to an off-screen operation event for a target display screen, interface element layout information of the target display screen includes: In response to an off-screen operation event for a target display screen, acquiring interface element label information of the target display screen; The interface element label information is parsed to construct interface element layout information in a tree structure.
3. The method according to claim 1, characterized in that Before the step of obtaining the interface element layout information of the target display screen in response to the off-screen operation event for the target display screen, the step further includes: Get display information of multiple display screens; Based on the number of display screens of the multiple display screens, 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, testing the interface element to be tested in at least one display screen to be tested based on the test script file includes: If a test instruction is received, determining the interface element to be tested in at least one display screen to be tested according to the element positioning information in the test script file; Allocating a test execution unit to each of the display screens to be tested; In the test execution unit corresponding to each of the display screens to be tested, the interface elements to be tested in the display screens 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 the display screen to be tested in the test execution unit corresponding to each display screen to be tested comprises: In the test execution unit corresponding to each of the display screens to be tested, obtaining the operation record corresponding to the interface element to be tested in the display screens to be tested; Calling the operation function of the interactive operation in the operation record, interacting with the interface element to be tested through the operation function, and obtaining an interaction result; Determine whether the interface element to be tested passes the test based on the interaction result.
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: Determine a target assertion statement based on the target interface element and the target expected result corresponding to the target interactive operation; The target interface element is determined as a 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 determining whether the interface element to be tested passes the test based on the interaction result includes: Compare the expected result of the assertion statement corresponding to the interface element to be tested 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, determining that the interface element to be tested passes the test; If the comparison result indicates that the expected result is different from the interaction result, it is determined that the interface element to be tested has failed the test, and a repair prompt for the interface element to be tested is output.
8. An interface testing device, characterized in that: The device comprises: An interface element acquisition unit, configured to acquire interface element layout information of a target display screen in response to an off-screen operation event on the target display screen; an element positioning unit, configured to determine 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 interaction operation on a target interface element in the target display screen is detected; A script generation unit, used to add the target element location information and the target operation record of the target interface element in the test script file, wherein the target operation record includes the target interface element and the target interactive operation; The testing unit is used to test the interface elements to be tested in at least one 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 comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the computer device executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program code, and when the computer program code is executed, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Software test method and system
CN103365779A
Automatic testing method and device for software in Android system
CN107357724A
Application program testing method and device, terminal equipment and storage medium
CN111309622A
Automatic test method of application program, computer equipment and storage medium
CN111414309A
Automatic testing method and system based on interconnection
CN113419945A