[go: up one dir, main page]

CN119883897A - Interface testing method and device, computer equipment and storage medium - Google Patents

Interface testing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN119883897A
CN119883897A CN202411911729.4A CN202411911729A CN119883897A CN 119883897 A CN119883897 A CN 119883897A CN 202411911729 A CN202411911729 A CN 202411911729A CN 119883897 A CN119883897 A CN 119883897A
Authority
CN
China
Prior art keywords
target
interface element
display screen
tested
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411911729.4A
Other languages
Chinese (zh)
Inventor
胡祾
涂慧勋
刘林
张煜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Great Wall Motors R&d Co ltd
Original Assignee
Chengdu Great Wall Motors R&d Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Great Wall Motors R&d Co ltd filed Critical Chengdu Great Wall Motors R&d Co ltd
Priority to CN202411911729.4A priority Critical patent/CN119883897A/en
Publication of CN119883897A publication Critical patent/CN119883897A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请提供了一种界面测试方法、装置、计算机设备和存储介质,该方法应用于计算机领域,该方法包括:计算机设备通过接收用户针对显示屏的屏外操作事件,获取该显示屏的界面元素布局信息。在检测到针对界面元素的交互操作时,基于界面元素布局信息和显示屏标识确定界面元素的元素定位信息。将界面元素的元素定位信息和操作记录添加至测试脚本文件中,在接收到测试指令时,根据测试脚本文件对至少一个显示屏进行测试。通过上述方法实现了对多个显示屏同时进行界面自动化测试,降低了人工成本,提升了测试效率。

The present application provides an interface testing method, apparatus, computer equipment and storage medium, which is applied to the computer field, and includes: the computer equipment obtains the interface element layout information of the display screen by receiving the user's off-screen operation event on 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.

Description

Interface testing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computers, and more particularly, to an interface test method, apparatus, computer device, and storage medium in the field of computers.
Background
With the development of science and technology, the interface automation test technology provides reliable guarantee for software development. However, the existing interface testing tools are all designed based on a single display screen, and when the terminal equipment is provided with a plurality of display screens, the existing interface testing tools do not support the plurality of display screens to simultaneously perform the automatic interface test, so that the testing efficiency of the multi-screen terminal equipment is greatly reduced.
Disclosure of Invention
The application provides an interface test method, an interface test device, computer equipment and a storage medium, the method can realize the simultaneous interface automatic test of a plurality of display screens, reduces the labor cost and improves the test efficiency.
According to the interface testing method, an interface element layout information of a target display screen is obtained in response to an off-screen operation event aiming at the target display screen, when target interactive operation aiming at the target interface element in the target display screen is detected, target element positioning information of the target interface element is determined based on the interface element layout information and a target display screen identification of the target display screen, the target element positioning information and a target operation record of the target interface element are added in a test script file, the target operation record comprises the target interface element and the target interactive operation, and 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.
Through the technical scheme, the interface element layout information of the display screen is obtained through aiming at the off-screen operation event of the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding element positioning information and operation records of the interface elements into a test script file, and testing at least one display screen according to the test script file when a test instruction is received. By the method, the interface automation test is simultaneously carried out on a plurality of display screens, the labor cost is reduced, and the test efficiency is improved.
With reference to 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 tag information of the target display screen in response to the off-screen operation event for the target display screen, and analyzing the interface element tag information to construct interface element layout information of a tree structure.
With reference to the first aspect and the foregoing implementation manner, in some possible implementation manners, before the step of obtaining the layout information of the interface element of the target display screen in response to the off-screen operation event for the target display screen, the method further includes obtaining display screen information of a plurality of display screens, and creating a plurality of test execution units in the test script file based on the display screen numbers of the plurality of display screens.
With reference to the first aspect and the foregoing implementation manner, in some possible implementation manners, the step of testing the interface element to be tested in the at least one display screen to be tested based on the test script file if the test instruction is received includes determining the interface element to be tested in the at least one display screen to be tested according to element positioning information in the test script file if the test instruction is received, allocating a test execution unit for each display screen to be tested, and testing the interface element to be tested in the display screen to be tested in the test execution unit corresponding to each display screen to be tested.
With reference to the first aspect and the implementation manner, in some possible implementation manners, the step of testing the interface element to be tested in the display screen to be tested in the test execution unit corresponding to each display screen to be tested includes the steps of obtaining an operation record corresponding to the interface element to be tested in the display screen to be tested in the test execution unit corresponding to each display screen to be tested, calling an operation function of interactive operation in the operation record, interacting with the interface element to be tested through the operation function to obtain an interaction result, and judging whether the interface element to be tested passes the test or not based on the interaction result.
With reference to the first aspect and the foregoing implementation manner, in some possible implementation manners, after the step of adding the target element positioning information and the target operation recording step of the target interface element in the test script file, the method further includes determining a target assertion statement based on the target interface element and a target expected result corresponding to the target interaction operation, determining the target interface element as a target assertion point, and inserting the target assertion statement at the target assertion point.
With reference to the first aspect and the foregoing implementation manner, in some possible implementation manners, the determining whether the interface element to be tested passes the test step based on the interaction result includes comparing an expected result of an assertion statement corresponding to the interface element to be tested with the interaction result to obtain a comparison result, determining that the interface element to be tested passes the test if the comparison result indicates that the expected result is the same as the interaction result, determining that the interface element to be tested fails the test if the comparison result indicates that the expected result is different from the interaction result, and outputting a repair prompt for the interface element to be tested.
In a second aspect, there is provided an interface testing apparatus, the apparatus comprising:
The interface element acquisition unit is used for responding to an off-screen operation event aiming at the target display screen and acquiring interface element layout information of the target display screen;
the element positioning unit is used for determining target element positioning information of the target interface element based on the interface element layout information and the target display screen identification of the target display screen when the target interaction operation aiming at the target interface element in the target display screen is detected;
The script generation unit is used for adding target element positioning information and target operation records of target interface elements in the test script file, wherein the target operation records comprise the target interface elements and target interaction operations;
and the test unit is used for testing the interface elements to be tested in at least one display screen to be tested based on the test script file if the test instruction is received.
In a third aspect, a computer device is provided that includes a memory for storing executable program code;
A processor for calling and running executable program code from memory to perform the method of the first aspect or any one of the possible implementation manners of the first aspect.
In a fourth aspect, there is provided a computer program product comprising computer program code which, when run on a computer, causes the computer to perform the method of the first aspect or any one of the possible implementations of the first aspect.
In a fifth aspect, a computer readable storage medium is provided, the computer readable storage medium storing computer program code which, when run on a computer, causes the computer to perform the method of the first aspect or any one of the possible implementations of the first aspect.
Drawings
FIG. 1 is a system architecture diagram of an interface testing method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of an interface testing method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart of an interface testing method according to an embodiment of the present application;
FIG. 4 is a flow chart of an assertion check provided by an embodiment of the present application;
FIG. 5 is a schematic flow chart of an interface test according to an embodiment of the present application;
FIG. 6 is a schematic structural diagram of an interface testing device according to an embodiment of the present application;
Fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical scheme of the application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiment of the present application, unless otherwise indicated, "/" means or, for example, a/B may mean a or B, "and/or" in the text is only one association relationship describing the association object, and it means that there may be three relationships, for example, a and/or B, three cases where a exists alone, a and B exist together, and B exists alone, and further, "a plurality" means two or more in the description of the embodiment of the present application.
The terms "first," "second," and the like, are used below for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature.
Referring to fig. 1, fig. 1 is a system architecture diagram of an interface testing method according to an embodiment of the present application. As shown in fig. 1, the interface testing method provided by the embodiment of the application can be applied to a computer device 10. The computer device 10 is connected with a terminal device 20 with a plurality of display screens, and performs interface test on the display screens of the terminal device 20, wherein the terminal device 20 can be a vehicle, a multi-screen computer, a multi-screen medical device, a multi-screen industrial device and the like. The test script file according to which the computer device 10 performs the interface test method can be generated by an interface test tool, the display screen information of the terminal device 20 is obtained through the connection between the computer device 10 and the terminal device 20, meanwhile, the interactive operation of the user on the interface element in the display screen is monitored, the script code is automatically generated according to the interactive operation of the user on the interface element, and then the test script file is obtained. However, in the related art, the computer device 10 can monitor only one display screen of the terminal device 20, and the generated test script file can also be tested only for one display screen.
Based on the above problems, the embodiment of the application provides an interface testing method. The computer device obtains interface element layout information for a display screen by receiving an off-screen operation event for the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding element positioning information and operation records of the interface elements into a test script file, and testing at least one display screen according to the test script file when a test instruction is received. By the method, when other display screens are operated outside the screen, the monitoring view angle of the computer equipment can be switched, so that an interface testing tool in the computer equipment can acquire the layout information of the interface elements of the plurality of display screens, and the interactive operation of a user on the interface elements in the plurality of display screens can be monitored. The interface automatic test is carried out on a plurality of display screens simultaneously, so that the labor cost is reduced, and the test efficiency is improved.
Based on the system architecture diagram shown in fig. 1, the following describes in detail the interface testing method provided by the embodiment of the present application with reference to fig. 2 to 5.
Referring to fig. 2, fig. 2 is a flow chart of an interface testing method according to an embodiment of the application. As shown in fig. 2, the method according to the embodiment of the present application may include the following steps S101 to S104.
S101, the computer equipment responds to an off-screen operation event aiming at the target display screen, and acquires interface element layout information of the target display screen.
Specifically, the computer equipment responds to an off-screen operation event of a user aiming at a target display screen in the terminal equipment, and acquires interface element layout information of the target display screen. The computer equipment is internally provided with an interface testing tool, and a display screen of the terminal equipment is monitored through the recording function of the interface testing tool. When the computer equipment captures an off-screen operation event of a user 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 acquire the layout information of the interface elements 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. Interface elements include, but are not limited to, buttons, sliders, input boxes, and the like, controls in the display screen. The interface element layout information is represented in a tree structure, and the tree structure clearly shows the nesting relationship among the interface elements. Each node of the tree structure is an interface element, and each node contains element attributes of the interface element, wherein the element attributes include, but are not limited to, attribute information such as element Identifier (ID), element positioning mode, element coordinates, element margin and the like.
S102, when the computer equipment detects target interaction operation aiming at target interface elements in the target display screen, determining target element positioning information of the target interface elements based on the interface element layout information and target display screen identification of the target display screen.
Specifically, when the computer device captures the target interaction operation of the user on the target interface element in the target display screen under the recording function of the interface test 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 identification of the target display screen. The interactive operation is operations such as single click, double click, long press, sliding, text input and the like. The element positioning information comprises unique identifiers such as element attributes or information of the combined identifier interface elements, and the interface test method provided by the embodiment of the application can carry out interface test on the terminal equipment with a plurality of display screens, so that in order to prevent the element positioning information of the interface elements from being repeated, the display screen identifiers are added into the existing element positioning information, so that the accuracy of element positioning is improved.
S103, adding target element positioning information and target operation records of target interface elements in the test script file by the computer equipment.
Specifically, after determining the target element positioning information, the computer device adds the target element positioning 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 test tool in the recording process and is used for subsequent automatic interface test. When the target element positioning information is determined, the interface test tool adds the target element positioning information to the test script file. Meanwhile, since one interface element can perform various interactive operations, for example, a single click operation, a double click operation and a long press operation can be performed for a button element, a target operation record of a target interface element needs to be added in the test script file. The target operation record comprises a target interface element and target interaction operation, so that when the automatic test is carried out based on the test script file, the interaction operation for the interface element can be accurately determined according to the operation record, and a corresponding operation function is further called. The operation function is an operation method pre-packaged in the test script file.
And S104, if the computer equipment receives the test instruction, testing the interface elements to be tested in at least one display screen to be tested based on the test script file.
Specifically, when the computer equipment receives a test instruction, the interface elements to be tested in at least one display screen to be tested of the terminal equipment are tested based on a test script file generated by the interface test tool. And during testing, analyzing element positioning information in the test script file, and positioning the element positioning information to interface elements to be tested in the display screen to be tested. And acquiring an operation record of each interface element to be tested in the test script file, calling a corresponding operation function according to the interaction operation in the operation record, and realizing interaction with the interface element to be tested to obtain an interaction result. And determining a test result according to the interaction result.
In the embodiment of the application, the computer equipment acquires the interface element layout information of the display screen by receiving an off-screen operation event of a user aiming at the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding element positioning information and operation records of the interface elements into a test script file, and testing at least one display screen according to the test script file when a test instruction is received. By the method, the interface automation test is simultaneously carried out on a plurality of display screens, the labor cost is reduced, and the test efficiency is improved.
Referring to fig. 3, a flow chart of an interface testing method is provided in an embodiment of the application. As shown in fig. 3, the method according to the embodiment of the present application may include the following steps S201 to S209.
S201, the computer equipment acquires display screen information of a plurality of display screens of the terminal equipment, and a plurality of test execution units are created in the test script file based on the display screen number of the plurality of display screens.
Specifically, the computer device is connected with a terminal device with a plurality of display screens, the computer device obtains display screen information of all the display screens of the terminal device through an installed interface test tool, and based on the number of the display screens, a test execution unit corresponding to the number of the display screens is created in a test script file. The display information includes, but is not limited to, display identification, display resolution, display frame rate and the like. The display screen identification is the unique identification of a plurality of display screens, the resolution of the display screen is used for determining the position and the margin size of the interface element when the element positioning is carried out subsequently, and the frame rate of the display screen is used for determining the performance and the response speed of the display screen interface. The interface test tool has a recording function, and monitors a plurality of display screens of terminal equipment connected with the computer equipment through the recording function. The test script file is a code file written in the recording process of the interface test tool and is used for subsequent automatic interface test. The test execution unit is used for realizing parallel test of a plurality of display screens, and the test execution unit can be in the form of threads or processes.
S202, the computer equipment responds to an off-screen operation event aiming at the target display screen, and acquires interface element label information of the target display screen.
Specifically, the computer device responds to an off-screen operation event aiming at a target display screen in the terminal device, and acquires interface element tag information of the target display screen. Under the recording function of the interface testing tool, the computer equipment can capture an off-screen operation event of a user on the target display screen, and further switch the focus of the recording function to the target display screen so as to acquire interface label information of an interface currently displayed by 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, buttons, sliders, input boxes and other controls in the display screen, the interface element label information is interface source code of the display screen, and 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 (HyperText Markup Language, HTML) or extensible markup language (Extensible Markup Language, XML), including the color, font, margin, alignment mode and the like of the interface elements.
S203, the computer equipment analyzes the interface element label information based on the interface test tool to construct the interface element layout information of the tree structure.
Specifically, the computer device analyzes the interface element tag information through an HTML parser or an XML parser in the interface test tool, and further builds the interface element layout information of the tree structure. The interface element layout information of the tree structure clearly shows the nesting relation among elements in the display screen interface, the nodes are basic units of the tree structure, and the tree structure is gradually unfolded from the root node to the interface elements at the sub-positions and deeper layers. Each node of the tree structure is an interface element, and each node contains the element attribute of the interface element. The element attributes include, but are not limited to, element ID, element positioning, element coordinates, element margins, etc. attribute information. The element identifier is an element ID and is used for uniquely identifying an interface element, the element coordinates and the element margin are determined based on the acquired display screen resolution, and the element positioning modes include, but are not limited to, positioning modes such as positioning according to the nesting relation of the interface element and positioning according to the element ID. It should be noted that, the element positioning manner in the layout information of the interface element can only position the interface element in a single display screen.
S204, when the computer equipment detects target interaction operation aiming at target interface elements in the target display screen, determining target element positioning information of the target interface elements based on the interface element layout information and target display screen identification of the target display screen.
Specifically, when the computer device captures the target interaction operation of the user on the target interface element in the target display screen under the recording function of the interface test 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 identification of the target display screen. The interactive operation is operations such as single click, double click, long press, sliding, text input and the like. The element positioning information comprises unique identifiers such as element attributes or information of the combined identifier interface elements, and the interface test method provided by the embodiment of the application can carry out interface test on the terminal equipment with a plurality of display screens, so that in order to prevent the element positioning information of the interface elements from being repeated, the display screen identifiers are added into the existing element positioning information, namely, the display screen identifiers are added into the element positioning mode in the step S203, so that target element positioning information is obtained, multi-screen logic of element positioning is realized, and the accuracy of element positioning is improved in the multi-screen interface test.
S205, adding target element positioning information and a target operation record of the target interface element in the test script file by the computer equipment, wherein the target operation record comprises the target interface element and target interaction operation.
Specifically, after determining the target element positioning information, the computer device adds the target element positioning information and the target operation record of the target interface element to the test script file. And after the target element positioning information is determined, the interface testing tool adds the target element positioning information into the test script file. Meanwhile, since one interface element can perform various interactive operations, for example, a single click operation, a double click operation and a long press operation can be performed for a button element, a target operation record of a target interface element needs to be added in the test script file. The target operation record comprises a target interface element and target interaction operation, so that when the automatic test is carried out based on the test script file, the interaction operation for the interface element can be accurately determined according to the operation record, and a corresponding operation function is further called. The operation function is an operation method pre-packaged in the test script file.
S206, the computer equipment determines a target assertion statement based on the target interface element and a target expected result corresponding to the target interaction operation.
Specifically, to implement an automated test, an interface test tool in the computer device can determine a target assertion statement based on the target interface element and a target expected result corresponding to the target interaction operation. The target interface element may correspond to a plurality of interactions, each interaction resulting in a different interaction result, determining a target expected result based on the target interaction with respect to the target interface element, and generating a target assertion statement based on the target expected result. The assertion statement is a Boolean expression containing an expected result, the expression is true when the interaction result is the same as the expected result, the script can continue to run, and the expression is false when the interaction result is different from the expected result, the script throws out an abnormal prompt, and the operation is interrupted.
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.
Specifically, an interface test tool in the computer device determines a target interface element as a target predicate point at which a target predicate statement is inserted. The predicate is a checkpoint set in the code of the test script file, which typically operates on the target interface element after invoking an operating function to obtain an interaction result, so as to compare the interaction result with an expected result.
S208, if the computer equipment receives the test instruction, determining interface elements to be tested in at least one display screen to be tested according to the element positioning information in the test script file.
Specifically, when the computer equipment receives a test instruction, the computer equipment automatically runs a test script file and analyzes element positioning information in the test script file. The test script file comprises at least one piece of element positioning information, all the element positioning information is analyzed, and interface elements to be tested in at least one display screen to be tested are positioned according to display screen identifiers in the element positioning information.
S209, the computer equipment distributes test execution units for each display screen to be tested, and tests interface elements to be tested in the display screen to be tested in the test execution units corresponding to each display screen to be tested.
Specifically, the computer equipment allocates a test execution unit for each display screen to be tested in a plurality of test execution units which are created in advance, and tests interface elements to be tested in the display screen to be tested in the test execution units corresponding to each display screen to be tested. Synchronous testing of a plurality of display screens to be tested is achieved through a plurality of test execution units, and it is to be noted that each display screen to be tested can comprise 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.
During testing, an operation record corresponding to the interface element to be tested in each display screen to be tested is obtained in the test execution unit corresponding to each display screen to be tested, an operation function of interactive operation in the operation record is called, and interaction is carried out with the interface element to be tested through the operation function, so that an interaction result is obtained. And judging whether the interface element to be tested passes the test or not based on the interaction result, wherein the interaction result is obtained in an interface screenshot form so as to be compared with an expected result. The specific judging 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 different from the interaction result, determining that the interface element to be tested fails the test, and outputting a repair prompt for the interface element to be tested. Referring to fig. 4, fig. 4 is a schematic flow chart of an assertion check according to an embodiment of the present application. As shown in fig. 4, an interface screenshot is performed on at least one display screen to be tested, and a plurality of interaction results are obtained. And when the interaction result is compared with the expected result, the target area segmentation is carried out on the interface screenshot so as to reduce the comparison range and improve the comparison efficiency. The elements in the interface may be compared, or the interface images may be compared. If the interface elements are compared, detecting whether the expected interface elements indicated by the expected results appear in the interaction results through an element detection algorithm, if so, testing is passed, if not, testing is failed, if the interface images are compared, judging whether the interface images of the interaction results are identical to the expected interface images of the expected results through an image comparison algorithm, if so, testing is passed, and if not, testing is failed. And obtaining a test result according to the comparison result.
It should be noted that, if the stability test is performed on the interface element to be tested, the threshold value of the test times is preset. And when the test is started, recording the test times of the interface element to be tested in real time, and after the interface element to be tested passes the test, repeating the test on the interface element to be tested until the test times reach a test time 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, outputting a repair prompt for the interface element to be tested so as to prompt a user to repair the vulnerability of the interface element to be tested, and generating a vulnerability log in the test report. Optionally, if the user is not detected to perform bug repair on the interface element to be tested within the preset time, the interface element to be tested can be skipped, and a subsequent test operation is automatically performed. Referring to fig. 5, fig. 5 is a schematic flow chart of an interface test according to an embodiment of the application.
In the embodiment of the application, the computer equipment acquires display screen information of a plurality of display screens of the terminal equipment connected with the computer equipment so as to create a test execution unit based on the number of the display screens. And when receiving an off-screen operation event aiming at the display screen by a user, acquiring interface element layout information of the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding the element positioning information and the operation record of the interface element into the test script file, and adding an assertion statement at the execution logic of the interface element in the test script file. And if the test instruction is received, testing interface elements to be tested in at least one display screen according to the test script file, determining a test result according to the assertion statement, and outputting a test report. By the method, the interface automation test is simultaneously carried out on a plurality of display screens, the labor cost is reduced, and the test efficiency is improved. Display screen identifiers are added into the element positioning information, so that multi-screen element positioning is realized, and the accuracy of element positioning is improved. And through the test execution unit, synchronous test of a plurality of display screens is realized.
Based on the system architecture diagram of fig. 1, an interface testing apparatus provided in an embodiment of the present application will be described in detail below with reference to fig. 6. It should be noted that, the interface testing apparatus in fig. 6 is used to execute the method of the embodiment of fig. 2-5, and for convenience of explanation, only the relevant parts of the embodiment of the present application are shown, and specific technical details are not disclosed, please refer to the embodiment of fig. 2-5.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an interface testing device according to an embodiment of the application. As shown in fig. 6, the interface test apparatus 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 test unit 14.
An interface element obtaining unit 11, configured to obtain interface element layout information of a target display screen in response to an off-screen operation event for the target display screen;
An element positioning unit 12 for determining target element positioning information of a target interface element based on interface element layout information and a target display screen identification of the target display screen when a target interactive operation for the target interface element in the target display screen is detected;
A script generating unit 13, configured to add target element positioning information and a target operation record of a target interface element in a test script file, where the target operation record includes the target interface element and a target interaction operation;
And the testing unit 14 is configured to test the interface element to be tested in the at least one display screen to be tested based on the test script file if the test instruction is received.
Optionally, the interface element obtaining unit 11 is specifically configured to obtain interface element tag information of the target display screen in response to an off-screen operation event for the target display screen;
and analyzing the interface element label information to construct the interface element layout information of the tree structure.
Optionally, the interface test device 1 is specifically configured to obtain display screen information of a plurality of display screens;
A plurality of test execution units are created in the test script file based on the number of display screens of the plurality of display screens.
Optionally, the test unit 14 is specifically configured to determine, if a test instruction is received, an interface element to be tested in at least one display screen to be tested according to element positioning information in the test script file;
distributing a test execution unit for 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 units corresponding to each display screen to be tested.
Optionally, the test unit 14 is specifically configured to obtain, in a test execution unit corresponding to each display screen to be tested, an operation record corresponding to an interface element to be tested in the display screen to be tested;
Calling an operation function of interactive operation in the operation record, and interacting with the interface element to be tested through the operation function to obtain an interaction result;
And judging whether the interface element to be tested passes the test or not based on the interaction result.
Optionally, the interface testing device 1 is specifically configured to determine a target assertion statement based on a target interface element and a target expected result corresponding to the target interaction operation;
And determining the target interface element as a target assertion point, and inserting a target assertion statement at the target assertion point.
Optionally, the test unit 14 is specifically configured to compare an 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, determining that the interface element to be tested fails the test, and outputting a repair prompt for the interface element to be tested.
In the embodiment of the application, the computer equipment acquires display screen information of a plurality of display screens of the terminal equipment connected with the computer equipment so as to create a test execution unit based on the number of the display screens. And when receiving an off-screen operation event aiming at the display screen by a user, acquiring interface element layout information of the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding the element positioning information and the operation record of the interface element into the test script file, and adding an assertion statement at the execution logic of the interface element in the test script file. And if the test instruction is received, testing interface elements to be tested in at least one display screen according to the test script file, determining a test result according to the assertion statement, and outputting a test report. By the method, the interface automation test is simultaneously carried out on a plurality of display screens, the labor cost is reduced, and the test efficiency is improved. Display screen identifiers are added into the element positioning information, so that multi-screen element positioning is realized, and the accuracy of element positioning is improved. And through the test execution unit, synchronous test of a plurality of display screens is realized.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the application.
By way of example, and as shown in FIG. 7, the computer device 700 includes a processor 701 and a memory 702, wherein the processor 701 is electrically connected to the memory 702.
Processor 701 is a control center of computer device 700 and may include one or more processing cores. The processor 701 utilizes various interfaces and lines to connect the various portions of the overall computer device, and performs various functions of the computer device and processes data by running or invoking computer programs stored in the memory 702, and invoking data stored in the memory 702, thereby overall controlling the computer device 700. Optionally, the processor 701 may be implemented in at least one hardware form of digital signal Processing (DIGITAL SIGNAL Processing, DSP), field programmable gate array (Field Programmable GATE ARRAY, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 701 may integrate one or a combination of several of a CPU, an image processor (Graphics Processing Unit, GPU), a modem, etc. The CPU mainly processes an operating system, a user page, an application program and the like, the GPU is used for rendering and drawing display contents, and the modem is used for processing wireless communication. It will be appreciated that the modem may not be integrated into the processor 701 and may be implemented solely by a single communication chip.
The memory 702 may be used to store software programs and modules, and the processor 701 performs various functional applications and data processing by executing the computer programs and modules stored in the memory 702. The memory 702 may mainly include a storage program area that may store an operating system, computer programs required for at least one function, and the like, and a storage data area that may store data created according to the use of the computer device 700, and the like.
In addition, the memory 702 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 702 may also include a memory controller to provide access to the memory 702 by the processor 701.
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 executes the computer programs stored in the memory 702, so as to implement various functions, as follows:
acquiring interface element layout information of a target display screen in response to an off-screen operation event aiming at the target display screen;
When target interactive operation aiming at a target interface element in a target display screen is detected, determining target element positioning information of the target interface element based on interface element layout information and a target display screen identifier of the target display screen;
adding target element positioning information and target operation records of target interface elements in a test script file, wherein the target operation records comprise the target interface elements and target interaction operations;
And if the test instruction is received, testing the interface elements to be tested in at least one display screen to be tested based on the test script file.
Optionally, the processor 701, when executing the obtaining the interface element layout information of the target display screen in response to the off-screen operation event for the target display screen, specifically performs:
Acquiring interface element tag information of a target display screen in response to an off-screen operation event aiming at the target display screen;
and analyzing the interface element label information to construct the interface element layout information of the tree structure.
Optionally, before executing the obtaining 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:
acquiring display screen information of a plurality of display screens;
A plurality of test execution units are created in the test script file based on the number of display screens of the plurality of display screens.
Optionally, when executing the test instruction, if the processor 701 tests the interface element to be tested in the at least one display screen to be tested based on the test script file, the specific implementation is that:
If a test instruction is received, determining interface elements to be tested in at least one display screen to be tested according to element positioning information in a test script file;
distributing a test execution unit for 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 units corresponding to each display screen to be tested.
Optionally, when executing the test execution unit corresponding to each display screen to be tested, the processor 701 specifically executes:
Acquiring operation records corresponding to interface elements to be tested in the display screen to be tested in a test execution unit corresponding to each display screen to be tested;
Calling an operation function of interactive operation in the operation record, and interacting with the interface element to be tested through the operation function to obtain an interaction result;
And judging whether the interface element to be tested passes the test or not based on the interaction result.
Optionally, after executing the target element positioning information added in the test script file and the target operation record of the target interface element, the processor 701 further executes:
determining a target assertion statement based on the target interface element and a target expected result corresponding to the target interaction operation;
And determining the target interface element as a target assertion point, and inserting a target assertion statement at the target assertion point.
Optionally, when executing the determination of whether the interface element to be tested passes the test based on the interaction result, the processor 701 specifically executes:
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, 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, determining that the interface element to be tested fails the test, and outputting a repair prompt for the interface element to be tested.
In the embodiment of the application, the computer equipment acquires display screen information of a plurality of display screens of the terminal equipment connected with the computer equipment so as to create a test execution unit based on the number of the display screens. And when receiving an off-screen operation event aiming at the display screen by a user, acquiring interface element layout information of the display screen. Upon detecting an interactive operation for the interface element, element positioning information for the interface element is determined based on the interface element layout information and the display screen identification. And adding the element positioning information and the operation record of the interface element into the test script file, and adding an assertion statement at the execution logic of the interface element in the test script file. And if the test instruction is received, testing interface elements to be tested in at least one display screen according to the test script file, determining a test result according to the assertion statement, and outputting a test report. By the method, the interface automation test is simultaneously carried out on a plurality of display screens, the labor cost is reduced, and the test efficiency is improved. Display screen identifiers are added into the element positioning information, so that multi-screen element positioning is realized, and the accuracy of element positioning is improved. And through the test execution unit, synchronous test of a plurality of display screens is realized.
It should be understood that, the apparatus provided in the embodiment of the present application is used to perform the above-mentioned interface testing method, so that the same effect as that of the above-mentioned implementation method can be achieved.
In case of an integrated unit, the apparatus may comprise a processing module, a memory module. When the device is applied to computer equipment, the processing module can be used for controlling and managing the actions of the computer equipment. The memory module may be used to support computer devices in executing associated program code and the like.
Wherein the processing module may be a processor or controller that may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. A processor may also be a combination of computing functions, including for example one or more microprocessors, digital Signal Processing (DSP) and microprocessor combinations, etc., and a memory module may be a memory.
In addition, the device provided by the embodiment of the application can be a chip, a component or a module, and the chip can comprise a processor and a memory which are connected, wherein the memory is used for storing instructions, and when the processor calls and executes the instructions, the chip can be made to execute the interface test method provided by the embodiment.
The embodiment of the application also provides a computer readable storage medium, in which computer program code is stored, which when run on a computer, causes the computer to execute the related method steps to implement an interface testing method provided in the above embodiment.
The present embodiment also provides a computer program product, which when run on a computer, causes the computer to perform the above-mentioned related steps to implement an interface testing method provided in the above-mentioned embodiments.
The apparatus, the computer readable storage medium, the computer program product, or the chip provided in this embodiment are used to execute the corresponding method provided above, and therefore, the advantages achieved by the apparatus, the computer readable storage medium, the computer program product, or the chip can refer to the advantages of the corresponding method provided above, which are not described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (10)

1.一种界面测试方法,其特征在于,所述方法包括: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.根据权利要求1所述的方法,其特征在于,所述响应于针对目标显示屏的屏外操作事件,获取所述目标显示屏的界面元素布局信息,包括:2. The method according to claim 1, wherein the step of obtaining the interface element layout information of the target display screen in response to an off-screen operation event on the target display screen comprises: 响应于针对目标显示屏的屏外操作事件,获取所述目标显示屏的界面元素标签信息;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.根据权利要求1所述的方法,其特征在于,所述响应于针对目标显示屏的屏外操作事件,获取所述目标显示屏的界面元素布局信息之前,还包括: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 method further comprises: 获取多个显示屏的显示屏信息;Get display screen 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.根据权利要求3所述的方法,其特征在于,所述若接收到测试指令,则基于所述测试脚本文件对至少一个待测试显示屏中的待测试界面元素进行测试,包括: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 comprises: 若接收到测试指令,则通过所述测试脚本文件中的元素定位信息确定至少一个待测试显示屏中的待测试界面元素;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.根据权利要求4所述的方法,其特征在于,所述在每一所述待测试显示屏对应的测试执行单元中,对所述待测试显示屏中的待测试界面元素进行测试,包括: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.根据权利要求5所述的方法,其特征在于,所述在测试脚本文件中添加所述目标元素定位信息,以及所述目标界面元素的目标操作记录之后,还包括: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, it also 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.根据权利要求6所述的方法,其特征在于,所述基于所述交互结果判断所述待测试界面元素是否通过测试,包括:7. The method according to claim 6, characterized in that judging whether the interface element to be tested passes the test based on the interaction result comprises: 将所述待测试界面元素对应的断言语句的预期结果与所述交互结果进行比较,得到比较结果;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.一种界面测试装置,其特征在于,所述装置包括: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.一种计算机设备,其特征在于,所述计算机设备包括:9. A computer device, characterized in that the computer device comprises: 存储器,用于存储可执行程序代码;A memory for storing executable program codes; 处理器,用于从所述存储器中调用并运行所述可执行程序代码,使得所述计算机设备执行如权利要求1至7中任意一项所述的方法。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.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序代码,当所述计算机程序代码被执行时,实现如权利要求1至7中任一项所述的方法。10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program code, and when the computer program code is executed, the method according to any one of claims 1 to 7 is implemented.
CN202411911729.4A 2024-12-24 2024-12-24 Interface testing method and device, computer equipment and storage medium Pending CN119883897A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411911729.4A CN119883897A (en) 2024-12-24 2024-12-24 Interface testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411911729.4A CN119883897A (en) 2024-12-24 2024-12-24 Interface testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN119883897A true CN119883897A (en) 2025-04-25

Family

ID=95422014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411911729.4A Pending CN119883897A (en) 2024-12-24 2024-12-24 Interface testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN119883897A (en)

Similar Documents

Publication Publication Date Title
US10621068B2 (en) Software code debugger for quick detection of error root causes
US9213625B1 (en) Method and apparatus for performing automated user-interface layout testing
EP2577463B1 (en) Static analysis using interactive and integration tools
CN111756575A (en) Performance analysis method and device for storage server, and electronic equipment
US20140359573A1 (en) Troubleshooting visuals and transient expressions in executing applications
US20120331449A1 (en) Device, method and computer program product for evaluating a debugger script
US20120054715A1 (en) System and method for use in replaying software application events
CN113868126A (en) Storage medium for application debugging method, device and equipment
CN110990411B (en) Data structure generation method and device, and calling method and device
US20130300744A1 (en) Creating dynamic interactive views from trace events for performing deterministic performance analysis
CN106529304A (en) Android application concurrent vulnerability detection system
CN113051171A (en) Interface test method, device, equipment and storage medium
CN115756934A (en) Application crash analysis method and device
US10083108B1 (en) Automated stack-based computerized application crawler
US20130346806A1 (en) Trace value correlation with data field declarations
CN111274143B (en) Buried point test method, buried point test device, buried point test equipment and storage medium
US8464103B2 (en) Generating a functional coverage model from a trace
US20140282414A1 (en) Method and system for debugging of a program
CN119883897A (en) Interface testing method and device, computer equipment and storage medium
WO2017107173A1 (en) Technologies for automated application testing coverage and results evaluation
CN111027073B (en) Vulnerability detection method, device, equipment and storage medium
US8191050B2 (en) Information processor, control method therefor, computer program and storage medium
WO2015062003A1 (en) User interface tester
US9244814B1 (en) Enriched log viewer
CN112860543A (en) Method and electronic equipment for detecting page operation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination