CN112148579B - User interface testing method and device - Google Patents

User interface testing method and device Download PDF

Info

Publication number
CN112148579B
CN112148579B CN201910561034.0A CN201910561034A CN112148579B CN 112148579 B CN112148579 B CN 112148579B CN 201910561034 A CN201910561034 A CN 201910561034A CN 112148579 B CN112148579 B CN 112148579B
Authority
CN
China
Prior art keywords
determined
user interface
data state
document object
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.)
Active
Application number
CN201910561034.0A
Other languages
Chinese (zh)
Other versions
CN112148579A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910561034.0A priority Critical patent/CN112148579B/en
Publication of CN112148579A publication Critical patent/CN112148579A/en
Application granted granted Critical
Publication of CN112148579B publication Critical patent/CN112148579B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Abstract

The embodiment of the application discloses a method and a device for testing a user interface, which are used for generating a test case according to the recording of a user interface test process of a target service, wherein the test case is used for identifying an action event generated in the user interface test process, and the target service responds to the corresponding relation between a data state obtained by the action event and a virtual document object model. If the user interface of the target service is tested, a test case is obtained; triggering an action event identified by a test case on a user interface of a target service to acquire a corresponding data state to be determined and a corresponding virtual document object model to be determined; and determining a test result according to the data state to be determined and the comparison result of the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation. The method reduces the technical requirements on testers, does not need to embed points in target business, and further reduces the test cost.

Description

User interface testing method and device
Technical Field
The present application relates to the field of data processing, and in particular, to a method and apparatus for testing a user interface.
Background
The intelligent terminal can provide various business services for the user through the browser. When providing the business service, a browser can display a User Interface (UI) corresponding to the business, and a User can acquire the business service through interaction with actions of the UI.
To ensure stability of business services, the UI of the business needs to be tested. The current automatic test mode needs to write corresponding test codes aiming at different businesses so as to generate test cases, and test points need to be buried in the businesses so as to realize UI test by running the test cases.
Therefore, a tester needs to have a certain programming basis to complete writing and maintenance work of test cases, the maintenance cost of service burial points is high, and the test cost and the threshold are improved.
Disclosure of Invention
In order to solve the technical problems, the application provides a method and a device for testing a user interface, which reduce the technical requirements on testers, and further reduce the testing cost without burying points in a target service.
The embodiment of the application discloses the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for testing a user interface, where the method includes:
Generating a test case according to the recording of the user interface test process of the target service, wherein the test case is used for identifying the corresponding relation among the action event, the data state and the virtual document object model; the action event is generated in the user interface test process, and the data state is obtained by responding to the action event for the target service;
when the user interface of the target service is tested, the test case is obtained;
triggering an action event identified by the test case on a user interface of the target service to acquire a corresponding data state to be determined and a corresponding virtual document object model to be determined;
and determining a test result according to the comparison result of the data state to be determined and the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
In a second aspect, an embodiment of the present application provides a testing apparatus for a user interface, where the apparatus includes a generating unit, a first acquiring unit, a second acquiring unit, and a determining unit:
the generating unit is used for generating a test case according to the recording of the user interface test process of the target service, wherein the test case is used for identifying the corresponding relation among the action event, the data state and the virtual document object model; the action event is generated in the user interface test process, and the data state is obtained by responding to the action event for the target service;
The first obtaining unit is used for obtaining the test case when the user interface of the target service is tested;
the second obtaining unit is used for triggering the action event identified by the test case for the user interface of the target service to obtain a corresponding data state to be determined and a corresponding virtual document object model to be determined;
and the determining unit is used for determining a test result according to the data state to be determined and the comparison result of the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
In a third aspect, embodiments of the present application provide a test apparatus for a user interface, the apparatus comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the method of testing the user interface according to the first aspect according to instructions in the program code.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing program code for performing the method of testing a user interface according to the first aspect.
According to the technical scheme, according to the recording of the user interface test process of the target service, the test case is generated and used for identifying the corresponding relation among the action event, the data state and the virtual document object model; the action event is generated in the user interface test process, and the data state is obtained by responding to the action event for the target service. By means of recording, the problem that additional programming is needed to generate test cases for different services is avoided, and technical requirements on testers are reduced. If the user interface of the target service needs to be tested, triggering can be performed on the user interface of the target service according to the action event identified by the test case, so that the data state to be determined and the virtual document object model to be determined, which are obtained by the user interface of the target service in response to the action event, are obtained. The user interface of the target service can be searched according to the test case to obtain what data state and virtual document object model corresponding to the action event, so that the test result can be determined according to the data state to be determined and the virtual document object model to be determined. The test does not need to embed points in the target service, and the test cost is further reduced.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the application, and that other drawings can be obtained according to these drawings without inventive faculty for a person skilled in the art.
FIG. 1 is a schematic diagram of a data flow in a reaction page of a system in response to a user operation on a UI;
fig. 2 is an application scenario schematic diagram of a testing method of a user interface according to an embodiment of the present application;
FIG. 3a is a schematic diagram of a generated action event and corresponding data states and virtual DOM according to an embodiment of the present application;
FIG. 3b is a schematic diagram of a generated action event and corresponding data states and virtual DOM according to an embodiment of the present application;
FIG. 4 is a flowchart of a testing method for a user interface according to an embodiment of the present application;
FIG. 5a is a schematic diagram of a browser plug-in interface after a browser plug-in is opened according to an embodiment of the present application;
fig. 5b is a schematic diagram of a browser plug-in interface in a recording process according to an embodiment of the present application;
FIG. 5c is a schematic diagram of a browser plug-in interface when saving test cases according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a testing method for a user interface according to an embodiment of the present application;
FIG. 7a is a block diagram of a testing device for a user interface according to an embodiment of the present application;
FIG. 7b is a block diagram of a testing device for a user interface according to an embodiment of the present application;
fig. 8 is a block diagram of an apparatus for volume adjustment according to an embodiment of the present application;
fig. 9 is a block diagram of a server according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the accompanying drawings.
At present, for the testing method of the user interface, the testing case of the user interface is mainly generated in a coding mode, then the testing point is buried in the service, and therefore the testing of the user interface is achieved through the operation of the testing case. The method requires a tester to have a certain programming basis, and has high maintenance cost for service burial points, thereby improving the test cost and threshold.
Therefore, the embodiment of the application provides a testing method of a user interface. Before describing the user interface testing method provided by the embodiment of the application, it is required to explain that when a user performs an operation on a UI, the response of the system to the user operation is usually implemented based on a unidirectional data stream. Wherein for unidirectional data streams, it can be understood as: when an upload data stream and a download data stream are used for bidirectional data communication, the two data streams are independent from each other. Such as: referring to FIG. 1, a diagram of the data flow in the reaction page of the system in response to user operation of the UI is shown, as shown in FIG. 1, where the data flow occurring within the reaction page is unidirectional in response to user operation.
In practice, unidirectional data flow corresponds to a fixed data transfer process. Illustrating: after the parameters are input into the system, they may undergo a fixed data transfer process (e.g., processing by function 1, function 2, and function 3, respectively) and output the corresponding data.
Thus, since the system is typically implemented based on unidirectional data flow in response to a user's operation on the UI, when the user performs the same operation on the UI, the same parameters are input to the system accordingly, so that, in response to the user's operation on the UI, the system may pass through a data transfer process corresponding to a data processing process of a pure function. Wherein the pure function may be a function that outputs the same data when the same parameter is called. Based on such invariance characteristics, then, after a fixed data transfer process, certain output data can be obtained to cause certain response changes to the UI interface. In addition, in response to the user's operation on the UI, if variable data such as a time stamp or a random number is generated in the data transfer process, that is, the data transfer process passed corresponds to the data processing process of the non-pure function. In this way, after a fixed data transfer process, the determined output data cannot be obtained, and certainly, the response change corresponding to the UI interface cannot be determined.
In the case that the data transfer process corresponds to the data processing process of the non-pure function, variable data (time stamp, random number, etc.) in the data transfer process can be recorded, and then, when the user operation is responded, the variable data is recovered in the data transfer process according to the pre-recorded variable data, so that the determined output data can still be obtained, and the determined response change of the UI interface can be caused, thereby ensuring the characteristic of invariance.
It can be seen that, because the system is generally implemented based on unidirectional data flow when responding to the user operation on the UI, when the user performs the same operation on the UI, the UI interface can be enabled to generate certain response changes based on the characteristics of invariance.
Based on the above, the embodiment of the application provides a testing method of a user interface, which comprises the following steps: and generating a test case by recording the user interface test process of the target service, wherein the test case comprises an action event generated in the user interface test process, a data state corresponding to the action event and a virtual document object model (Document Object Model, DOM), so that the user interface test of the target service can be realized based on the test case generated by a recording mode. The method can avoid generating test cases by additional programming aiming at different services, and reduces the technical requirements on testers. In addition, when the user interface of the target service is tested, the action event in the test case is triggered to obtain the data state to be determined and the virtual DOM to be determined corresponding to the action event, and the data state and the virtual DOM corresponding to the action event in the test case are compared, so that a test result is obtained, and embedding points in the target service are not needed, so that the test cost is further reduced.
First, an application scenario of the embodiment of the present application is described. The method can be applied to terminal equipment, and the terminal equipment can be, for example, intelligent terminals, computers, personal digital assistants (Personal Digital Assistant, PDA for short), tablet computers and the like.
The method for testing the user interface can also be applied to a server, wherein the server can be a special server only used for testing the user interface, and the server can also be a public server also comprising other data processing functions, and the embodiment of the application is not limited.
In order to facilitate understanding of the technical scheme of the present application, a method for testing a user interface provided by the embodiment of the present application is described below by taking a server as an example in conjunction with an actual application scenario.
Referring to fig. 2, fig. 2 is an application scenario schematic diagram of a testing method of a user interface according to an embodiment of the present application. The application scene comprises a server 201, and the server 201 can record the user interface test process of the target service. The target service can be any service realized by a user through a user interface. For example, the target service may be a service that a user makes a query through a user interface of a browser.
It will be appreciated that during the user interface testing of the target service, the user may perform a corresponding operation on the UI to achieve the target task, and for each operation of the user, a corresponding machine-recognizable action event may be generated, and when the target service responds to the action event, a corresponding data state and virtual DOM may also be formed in the background of the system. Therefore, after the user interface test process of the target service is recorded, the action event, the corresponding data state and the virtual DOM can be saved.
Wherein, the action event can correspond to any operation implemented by a user on the UI for realizing the target task; the data state may be a state of data obtained when the target service responds to the action event, for example, the data state is a state of data on the react page. The virtual DOM may be a tree-based standard programming interface document that requires that the entire document in the process be represented in memory.
For example, referring to fig. 3a, which is a schematic diagram illustrating a generated action event and a corresponding data state and virtual DOM according to an embodiment of the present application, as shown in fig. 3a, for an operation of opening a user interface performed by a user, a corresponding "INIT" action event is generated, and then a target service may respond to the "INIT" action event: for an INIT action event, page data can be triggered to change, so that the data state of a current reaction page is formed, the data state of the current reaction page automatically influences the data change in the virtual DOM, the current virtual DOM is formed, and the rendering of a user interface is controlled by the current virtual DOM. Similarly, referring to fig. 3b, a schematic diagram of a generated action event, a corresponding data state and a virtual DOM according to an embodiment of the present application is shown, as shown in fig. 3b, when a user performs an operation of inputting a "send week report" into a text box of a UI, a corresponding "INPUT (text= 'send week report')" action event is generated, and then a target service responds to the "INPUT (text= 'send week report')" action event, so as to form a data state of a current compact page, further form a current virtual DOM, and finally control rendering of a user interface.
Then, the target use case can be generated according to the user interface test process of the recorded target service. The target use case can be used for identifying a corresponding relation among an action event generated in the user interface test process, a data state obtained by the target service through responding to the action event and a virtual DOM. Briefly, namely: the test case is identified with a corresponding relationship between an action event and a data state and virtual DOM formed based on the action event. For example: the test case identifies that an action event "X" corresponds to a data state "X" and a virtual DOM "X1", wherein the data state "X" and the virtual DOM "X1" are both formed in response to the action event "X".
It should be noted that, in the process of testing the user interface of the target service, the action event generated in the process, and the data state and virtual DOM formed in response to the action event are both generated in the normal case of the user interface of the target service. That is, for the action events and corresponding data states and virtual DOM in the test case, they are all normally generated by the user interface of the target service.
Therefore, after the test case corresponding to the target service is obtained, if the user interface of the target service needs to be tested, the test case generated before the user interface of the target service can be obtained. And triggering action events identified by the test cases on a user interface of the target service in the test process, acquiring the data state and the virtual DOM generated by the action events, and taking the data state and the virtual DOM as the data state to be determined and the virtual DOM to be determined.
Therefore, for the data state to be determined and the virtual DOM to be determined, which are obtained based on the action event, the data state and the virtual DOM corresponding to the action event in the test case can be compared, and the test result is determined according to the comparison result.
Therefore, according to the test method of the user interface, provided by the embodiment of the application, the test case is generated by recording the user interface test process of the target service, so that the test case is prevented from being generated by additional programming aiming at different services, and the technical requirements on testers are reduced. In addition, when the user interface of the target service is tested, a test result is obtained in a mode of comparing the data state with the virtual DOM, so that the point embedding in the target service is not needed, and the test cost is further reduced.
Next, a method for testing a user interface provided by an embodiment of the present application will be described with reference to the accompanying drawings.
Referring to fig. 4, a flowchart of a testing method of a user interface provided by an embodiment of the present application is shown, where the method includes:
s401: and generating a test case according to the recording of the user interface test process of the target service.
In the embodiment of the application, aiming at the target service, the test case can be generated by recording the user interface test process of the target service. The generated test cases can be used for identifying corresponding relations among action events, data states and virtual DOMs. The action events described herein may be generated during testing of a user interface of a target task; the data state and virtual DOM may both be obtained by the target service in response to the action event.
In a possible implementation manner, the browser plug-in may be used to record the user interface test procedure of the target service, so as to generate a test case, for the manner of recording the user interface test procedure of the target service in S401. In a specific implementation, a browser plug-in may be installed on a terminal device or a server, where the browser plug-in may inject a test script into a corresponding page (such as a reaction page) of the background when the corresponding page is initialized, so as to further implement recording of a user interface test process.
Next, a recording method of the user interface test procedure through the browser plug-in will be described. Referring to fig. 5a, a schematic diagram of a browser plug-in interface after opening a browser plug-in according to an embodiment of the present application is shown. When the user interface test for the target service is started, the start recording button in fig. 5a may be clicked to perform recording.
In the recording process, when a user operates the UI, the browser plug-in can capture action events generated under the operation, corresponding data states and snapshots of the virtual DOM. Referring to fig. 5b, a schematic diagram of a browser plug-in interface in a recording process according to an embodiment of the present application is shown in fig. 5b, where each row of content may correspond to an action event and a corresponding data state and snapshot of the virtual DOM.
It will be appreciated that action events in a snapshot correspond to the data states and virtual DOM in the snapshot. Therefore, after the recording of the user interface test process of the target service is completed, the obtained snapshot can be used as a test case and stored. Referring to fig. 5c, a schematic diagram of a browser plug-in interface when saving a test case according to an embodiment of the present application is shown. As shown in fig. 5c, when the test case is stored, a corresponding name and category may be set for the test case, so as to facilitate later acquisition of the test case.
It can be appreciated that if the target service is simpler, the test case corresponding to the target service may correspond to an action event and to the corresponding data state and virtual DOM. If a target service is complex, in a possible implementation manner, the test case corresponding to the target service may include a plurality of action events, and the test case may also record the time sequence between the action events. Wherein the timing between the action events may be a time sequence of generating the action events, and different action events may correspond to different data states and virtual DOMs. In a specific implementation, each action event may be arranged in accordance with its timing sequence, thereby generating test cases.
For example, during the user interface test process of recording the target service, the user sequentially performs operation 1, operation 2 and operation 3 on the user interface. Then, after the recording is completed, the generated test case includes an action event "H", an action event "I" and an action event "J" (corresponding to operation 1, operation 2 and operation 3, respectively). Moreover, action event "H" corresponds to data state "H" and virtual DOM "H1"; action event "I" corresponds to data state "I" and virtual DOM "I1"; the action event "J" corresponds to the data state "J" and the virtual DOM "J1", i.e., different action events may correspond to different data states and virtual DOMs. In addition, the test case further includes a time sequence of an action event H, an action event I and an action event J, that is, the sequence of the generation times of the three action events is: action event H is generated prior to action event I, which is generated prior to action event J.
S402: and when the user interface is tested on the target service, acquiring the test case.
When the user interface test is required to be performed on the target service, the test case generated in S401 may be obtained.
S403: and triggering the action event identified by the test case on the user interface of the target service to acquire a corresponding data state to be determined and a corresponding virtual document object model to be determined.
After the test case is obtained, the identified action event in the test case can be triggered on the user interface of the target service according to the identified action event in the test case, and the data state and the virtual DOM corresponding to the action event are obtained and used as the data state to be determined and the virtual DOM to be determined corresponding to the action event.
It should be noted that if the test case includes a plurality of action events, each action event in the test case may be triggered in turn for the user interface of the target service according to the time sequence of the action event in the test case.
S404: and determining a test result according to the comparison result of the data state to be determined and the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
Therefore, aiming at the data state to be determined and the virtual DOM to be determined, which correspond to the action event in the test process, the data state and the virtual DOM, which correspond to the action event in the test case, can be compared, so that a comparison result is obtained, and the test result is determined according to the comparison result.
According to the technical scheme, according to the recording of the user interface test process of the target service, the test case is generated and used for identifying the action event generated in the user interface test process, and the target service responds to the corresponding relation between the data state obtained by the action event and the virtual document object model. By means of recording, the problem that additional programming is needed to generate test cases for different services is avoided, and technical requirements on testers are reduced. If the user interface of the target service needs to be tested, triggering can be performed on the user interface of the target service according to the action event identified by the test case, so that the data state to be determined and the virtual document object model to be determined, which are obtained by the user interface of the target service in response to the action event, are obtained. The user interface of the target service can be searched according to the test case to obtain what data state and virtual document object model corresponding to the action event, so that the test result can be determined according to the data state to be determined and the virtual document object model to be determined. The test does not need to embed points in the target service, and the test cost is further reduced.
In order to reduce the capability requirement on the tester and facilitate the tester to more intuitively obtain the data state to be determined and the comparison result of the virtual DOM to be determined and the corresponding data state and virtual DOM in the test case, for the method of S404, in one possible implementation manner, the method of S404 may include:
s501: and comparing the text content with the data state and the virtual document object model determined according to the corresponding relation according to the data state and the virtual document object model to be determined. And if the data state to be determined and the virtual document object model to be determined are inconsistent with the text contents of the data state and the virtual document object model determined according to the corresponding relation, executing S502, and if the data state to be determined and the virtual document object model to be determined are consistent with the text contents of the data state and the virtual document object model determined according to the corresponding relation, executing S503.
S502: and determining that the test result is abnormal.
S503: and determining that the test result is normal.
In the embodiment of the present application, referring to fig. 3a and 3b, it can be seen that the data state of the page and the text content in the virtual DOM are relatively intuitive, so that, for the data state to be determined and the virtual DOM to be determined, a tester can compare the data state and the text content of the virtual DOM determined according to the corresponding relationship in the test case.
It can be appreciated that the action events in the test case and the corresponding data states and virtual DOM, which are normally generated by the user interface of the target service. Thus, for the data state to be determined and the virtual DOM to be determined, after the data state to be determined and the text content of the virtual DOM to be determined are compared with the data state determined according to the corresponding relation in the test case, if the text content of the data state to be determined and the text content of the virtual DOM are determined to be inconsistent, the test result can be determined to be abnormal. If they are determined to be consistent in text content, the test results may be determined to be normal.
Therefore, for the data state to be determined and the corresponding data state and virtual DOM in the virtual DOM to be determined and the test case, the system can directly compare the text contents of the data state and the virtual DOM to be determined with the corresponding data state and virtual DOM in the test case, so that the capability requirement of the tester is low, in addition, the tester can obtain a comparison result more intuitively through the text content comparison mode, and the test efficiency is improved.
In an embodiment of the present application, in order to ensure accuracy of the generated test case, in a possible implementation manner, the method further includes:
s601: and acquiring a playback request aiming at the test case.
S602: and playing back the test cases according to the recorded time sequence.
In the embodiment of the application, for example, a recording person can send a playback request for the test case to a server or a terminal device, wherein the recording person can be a person responsible for a user interface test process of recording the target service. Then, the server or the terminal equipment can acquire the playback request for the test case and play back the test case according to the recorded time sequence, so that whether the test case has errors or not can be determined according to the playback content, and the accuracy of the generated test case is ensured.
Next, a method for testing a user interface provided by the embodiment of the present application will be described with reference to an actual application scenario. Referring to fig. 6, a schematic diagram of a testing method of a user interface according to an embodiment of the present application is shown.
As shown in fig. 6, the user interface test method of the target task may include three parts: recording process, test case management and regression process:
and recording a testing process of a user interface of the target task through a browser plug-in, recording action events generated based on user operation, data states corresponding to the action events and snapshots of the virtual DOM by the plug-in, and generating a testing case corresponding to the target task after the user interface testing process of the target service is recorded. By the method, non-developers can record to generate the test cases, labor cost is reduced, and generation efficiency of the test cases can be improved.
After the test case is generated in the browser plug-in, the browser plug-in can send a request packet for requesting to manage the test case to the test case management system, the test case management system stores and manages the test case after receiving the request packet, and when the user interface test is required to be performed on the target task, the test case management system can be responsible for scheduling the test case and sending the test case to the regression environment so as to perform the test on the user interface of the target task. The maintainability of the test cases is improved by sending the test cases to the test case management system for unified management.
The test case management system can trigger two modes through a timing task or a programming interface (Application Programming Interface, API) to start the user interface test of the target service based on the test case. The regression environment may be a virtual environment created by a regression server to import code and test scripts for the target business into the regression environment.
When testing the user interface of the target task, the test cases can be quickly initialized in the regression environment. Then, action events in the test cases can be triggered one by one, and a snapshot is obtained, wherein the obtained snapshot comprises the action events, corresponding data states to be determined and virtual DOMs to be determined, the corresponding data states to be determined and the corresponding virtual DOMs to be determined of the action events are compared with the corresponding data states and the corresponding virtual DOMs in the test cases, if the text contents of the data states and the virtual DOMs are the same, the test results are normal, and if the text contents of the text contents are different, a test report can be generated based on different parts among the data states and the virtual DOMs. Thus, the developer can analyze the abnormal position of the code through the test report and perform BUG fixes.
Based on the method for testing a user interface provided in the foregoing embodiment, the embodiment of the present application further provides a device for testing a user interface, referring to fig. 7a, which shows a schematic structural diagram of the device for testing a user interface provided in the embodiment of the present application, where the device 700 includes a generating unit 701, a first acquiring unit 702, a second acquiring unit 703, and a determining unit 704:
the generating unit 701 is configured to generate a test case according to a record of a user interface test procedure of a target service, where the test case is used to identify a correspondence between an action event, a data state and a virtual document object model; the action event is generated in the user interface test process, and the data state is obtained by responding to the action event for the target service;
the first obtaining unit 702 is configured to obtain the test case when performing a user interface test on the target service;
the second obtaining unit 703 is configured to trigger, for the user interface of the target service, an action event identified by the test case, to obtain a corresponding data state to be determined and a virtual document object model to be determined;
The determining unit 704 is configured to determine a test result according to the data state to be determined and the comparison result of the virtual document object model to be determined and the data state and the virtual document object model determined according to the correspondence.
Optionally, the determining unit 704 is specifically configured to:
comparing text contents according to the data state to be determined and the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation;
if the data state to be determined and the virtual document object model to be determined are inconsistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is abnormal;
and if the data state to be determined and the virtual document object model to be determined are consistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is normal.
Optionally, the test case includes a plurality of action events, and a time sequence among the action events is recorded; different action events correspond to different data states and virtual document object models.
In a possible implementation manner, referring to fig. 7b, which shows a schematic structural diagram of a testing device of a user interface according to an embodiment of the present application, the device 700 further includes a playback unit 705, where the playback unit 705 is specifically configured to:
acquiring a playback request aiming at the test case;
and playing back the test cases according to the recorded time sequence.
Optionally, the generating unit 701 is specifically configured to:
recording a user interface test process of the target service through the browser plug-in, and generating a test case.
According to the technical scheme, according to the recording of the user interface test process of the target service, the test case is generated and used for identifying the action event generated in the user interface test process, and the target service responds to the corresponding relation between the data state obtained by the action event and the virtual document object model. By means of recording, the problem that additional programming is needed to generate test cases for different services is avoided, and technical requirements on testers are reduced. If the user interface of the target service needs to be tested, triggering can be performed on the user interface of the target service according to the action event identified by the test case, so that the data state to be determined and the virtual document object model to be determined, which are obtained by the user interface of the target service in response to the action event, are obtained. The user interface of the target service can be searched according to the test case to obtain what data state and virtual document object model corresponding to the action event, so that the test result can be determined according to the data state to be determined and the virtual document object model to be determined. The test does not need to embed points in the target service, and the test cost is further reduced.
The embodiment of the application also provides test equipment for the user interface, and the test equipment for the user interface is described below with reference to the accompanying drawings. Referring to fig. 8, an embodiment of the present application provides a test device 800 for a user interface, where the device 800 may also be a terminal device, and the terminal device may be any intelligent terminal including a mobile phone, a tablet computer, a personal digital assistant (Personal DigitalAssistant, PDA for short), a Point of sales (POS for short), a vehicle-mounted computer, and the like, taking the terminal device as an example of the mobile phone:
fig. 8 is a block diagram showing a part of the structure of a mobile phone related to a terminal device provided by an embodiment of the present application. Referring to fig. 8, the mobile phone includes: radio Frequency (RF) circuitry 810, memory 820, input unit 830, display unit 840, sensor 850, audio circuitry 860, wireless fidelity (wireless fidelity, wiFi) module 870, processor 880, and power supply 890. Those skilled in the art will appreciate that the handset configuration shown in fig. 8 is not limiting of the handset and may include more or fewer components than shown, or may combine certain components, or may be arranged in a different arrangement of components.
The following describes the components of the mobile phone in detail with reference to fig. 8:
the RF circuit 810 may be used for receiving and transmitting signals during a message or a call, and in particular, after receiving downlink information of a base station, it is processed by the processor 880; in addition, the data of the design uplink is sent to the base station. In general, RF circuitry 810 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuitry 810 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to global system for mobile communications (Global System ofMobile communication, GSM for short), general packet radio service (General Packet Radio Service, GPRS for short), code division multiple access (Code DivisionMultipleAccess, CDMA for short), wideband code division multiple access (Wideband Code DivisionMultipleAccess, WCDMA for short), long term evolution (Long Term Evolution, LTE for short), email, short message service (ShortMessaging Service, SMS for short), and the like.
The memory 820 may be used to store software programs and modules, and the processor 880 performs various functional applications and data processing of the cellular phone by executing the software programs and modules stored in the memory 820. The memory 820 may mainly include a storage program area that may store an operating system, application programs required for at least one function (such as a sound playing function, an image playing function, etc.), and a storage data area; the storage data area may store data (such as audio data, phonebook, etc.) created according to the use of the handset, etc. In addition, memory 820 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.
The input unit 830 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function controls of the handset. In particular, the input unit 830 may include a touch panel 831 and other input devices 832. The touch panel 831, also referred to as a touch screen, may collect touch operations thereon or thereabout by a user (e.g., operations of the user on the touch panel 831 or thereabout using any suitable object or accessory such as a finger, stylus, etc.), and actuate the corresponding connection device according to a predetermined program. Alternatively, the touch panel 831 may include two portions of a touch detection device and a touch controller. The touch detection device detects the touch azimuth of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 880 and can receive commands from the processor 880 and execute them. In addition, the touch panel 831 may be implemented in various types of resistive, capacitive, infrared, surface acoustic wave, and the like. The input unit 830 may include other input devices 832 in addition to the touch panel 831. In particular, other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, mouse, joystick, etc.
The display unit 840 may be used to display information input by a user or information provided to the user and various menus of the mobile phone. The display unit 840 may include a display panel 841, and optionally, the display panel 841 may be configured in the form of a liquid crystal display (Liquid Crystal Display, LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch panel 831 may overlay the display panel 841, and when the touch panel 831 detects a touch operation thereon or thereabout, the touch operation is transferred to the processor 880 to determine the type of touch event, and the processor 880 then provides a corresponding visual output on the display panel 841 according to the type of touch event. Although in fig. 8, the touch panel 831 and the display panel 841 are implemented as two separate components to implement the input and input functions of the mobile phone, in some embodiments, the touch panel 831 and the display panel 841 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 850, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 841 according to the brightness of ambient light, and the proximity sensor may turn off the display panel 841 and/or the backlight when the mobile phone moves to the ear. As one of the motion sensors, the accelerometer sensor can detect the acceleration in all directions (generally three axes), and can detect the gravity and direction when stationary, and can be used for applications of recognizing the gesture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and knocking), and the like; other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that may also be configured with the handset are not described in detail herein.
Audio circuitry 860, speaker 861, microphone 862 may provide an audio interface between the user and the handset. The audio circuit 860 may transmit the received electrical signal converted from audio data to the speaker 861, and the electrical signal is converted into a sound signal by the speaker 861 to be output; on the other hand, microphone 862 converts the collected sound signals into electrical signals, which are received by audio circuit 860 and converted into audio data, which are processed by audio data output processor 880 for transmission to, for example, another cell phone via RF circuit 810, or which are output to memory 820 for further processing.
WiFi belongs to a short-distance wireless transmission technology, and a mobile phone can help a user to send and receive emails, browse webpages, access streaming media and the like through a WiFi module 870, so that wireless broadband Internet access is provided for the user. Although fig. 8 shows a WiFi module 870, it is understood that it does not belong to the necessary constitution of the handset, and can be omitted entirely as needed within the scope of not changing the essence of the invention.
The processor 880 is a control center of the mobile phone, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the mobile phone and processes data by running or executing software programs and/or modules stored in the memory 820, and calling data stored in the memory 820. In the alternative, processor 880 may include one or more processing units; preferably, the processor 880 may integrate an application processor that primarily handles operating systems, user interfaces, applications, etc., with a modem processor that primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 880.
The handset further includes a power supply 890 (e.g., a battery) for powering the various components, which may be logically connected to the processor 880 through a power management system, as well as performing functions such as managing charge, discharge, and power consumption by the power management system.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which will not be described herein.
In this embodiment, the processor 880 included in the terminal device further has the following functions:
acquiring an object to be clipped;
determining a content element for video clip in the object to be clipped, wherein the content element has a corresponding content type identifier;
determining a video clip material set corresponding to the content type identifier according to a first behavior tree logic;
and synthesizing the video clip material set according to the content elements to obtain the clip video.
The test device for user interface provided in the embodiment of the present application may be a server, as shown in fig. 9, fig. 9 is a block diagram of a server 900 provided in the embodiment of the present application, where the server 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (Central Processing Units, abbreviated as CPUs) 922 (e.g. one or more processors) and a memory 932, and one or more storage media 930 (e.g. one or more mass storage devices) storing application programs 942 or data 944. Wherein the memory 932 and the storage medium 930 may be transitory or persistent. The program stored in the storage medium 930 may include one or more modules (not shown), each of which may include a series of instruction operations on a server. Still further, the central processor 922 may be arranged to communicate with a storage medium 930 to execute a series of instruction operations in the storage medium 930 on the server 900.
The server 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input/output interfaces 958, and/or one or more operating systems 941, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, etc.
The steps performed by the server in the above embodiments may be based on the server structure shown in fig. 9.
Wherein, CPU 922 is configured to perform the steps of:
generating a test case according to the record of a user interface test process of a target service, wherein the test case is used for identifying an action event generated in the user interface test process, and the target service responds to the corresponding relationship between the data state obtained by the action event and a virtual document object model;
if the user interface of the target service is tested, acquiring the test case;
triggering an action event identified by the test case on a user interface of the target service to acquire a corresponding data state to be determined and a corresponding virtual document object model to be determined;
and determining a test result according to the comparison result of the data state to be determined and the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
The terms "first," "second," "third," "fourth," and the like in the description of the application and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented, for example, in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the 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 system, 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 units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RandomAccess Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (12)

1. A method of testing a user interface, the method comprising:
generating a test case according to the recording of the user interface test process of the target service, wherein the test case is used for identifying the corresponding relation among the action event, the data state and the virtual document object model; the action event is generated in the user interface test process, and the data state and the virtual document object model are obtained by responding to the action event for the target service;
when the user interface of the target service is tested, the test case is obtained;
triggering an action event identified by the test case on a user interface of the target service to acquire a corresponding data state to be determined and a corresponding virtual document object model to be determined;
and determining a test result according to the comparison result of the data state to be determined and the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
2. The method according to claim 1, wherein the determining a test result according to the comparison result of the data state to be determined and the virtual document object model to be determined and the data state to be determined and the virtual document object model determined according to the correspondence relation comprises:
According to the data state to be determined and the virtual document object model to be determined, comparing text contents with the data state and the virtual document object model determined according to the corresponding relation;
if the data state to be determined and the virtual document object model to be determined are inconsistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is abnormal;
and if the data state to be determined and the virtual document object model to be determined are consistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is normal.
3. The method of claim 1, wherein the test case comprises a plurality of action events and a timing between the plurality of action events is recorded; different action events correspond to different data states and virtual document object models.
4. The method according to claim 1, wherein the method further comprises:
acquiring a playback request aiming at the test case;
and playing back the test cases according to the recorded time sequence.
5. The method of claim 1, wherein generating test cases based on the recording of the user interface test procedure for the target service comprises:
Recording a user interface test process of the target service through the browser plug-in, and generating a test case.
6. A testing device for a user interface, the device comprising a generating unit, a first obtaining unit, a second obtaining unit and a determining unit:
the generating unit is used for generating a test case according to the recording of the user interface test process of the target service, wherein the test case is used for identifying the corresponding relation among the action event, the data state and the virtual document object model; the action event is generated in the user interface test process, and the data state and the virtual document object model are obtained by responding to the action event for the target service;
the first obtaining unit is used for obtaining the test case when the user interface of the target service is tested;
the second obtaining unit is used for triggering the action event identified by the test case for the user interface of the target service to obtain a corresponding data state to be determined and a corresponding virtual document object model to be determined;
and the determining unit is used for determining a test result according to the data state to be determined and the comparison result of the virtual document object model to be determined and the data state and the virtual document object model determined according to the corresponding relation.
7. The apparatus according to claim 6, wherein the determining unit is specifically configured to:
according to the data state to be determined and the virtual document object model to be determined, comparing text contents with the data state and the virtual document object model determined according to the corresponding relation;
if the data state to be determined and the virtual document object model to be determined are inconsistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is abnormal;
and if the data state to be determined and the virtual document object model to be determined are consistent with the text content of the data state and the virtual document object model determined according to the corresponding relation, determining that the test result is normal.
8. The apparatus of claim 6, wherein the test case comprises a plurality of action events and a timing between the plurality of action events is recorded; different action events correspond to different data states and virtual document object models.
9. The apparatus according to claim 6, further comprising a playback unit, in particular for:
Acquiring a playback request aiming at the test case;
and playing back the test cases according to the recorded time sequence.
10. The apparatus according to claim 6, wherein the generating unit is specifically configured to:
recording a user interface test process of the target service through the browser plug-in, and generating a test case.
11. A readable storage medium, having stored thereon a computer program, the computer program being loaded and executed by a processor, implementing the steps of the method of testing a user interface according to any of claims 1 to 5.
12. A server, comprising:
a central processing unit and a memory;
a memory for storing a program for implementing the test method of the user interface according to any one of claims 1 to 5;
a processor for invoking and executing the program of the memory to perform the steps of the method for testing a user interface as claimed in any one of claims 1 to 5.
CN201910561034.0A 2019-06-26 2019-06-26 User interface testing method and device Active CN112148579B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910561034.0A CN112148579B (en) 2019-06-26 2019-06-26 User interface testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910561034.0A CN112148579B (en) 2019-06-26 2019-06-26 User interface testing method and device

Publications (2)

Publication Number Publication Date
CN112148579A CN112148579A (en) 2020-12-29
CN112148579B true CN112148579B (en) 2023-10-03

Family

ID=73869790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910561034.0A Active CN112148579B (en) 2019-06-26 2019-06-26 User interface testing method and device

Country Status (1)

Country Link
CN (1) CN112148579B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882930B (en) * 2021-02-04 2023-09-26 网易(杭州)网络有限公司 Automatic test method and device, storage medium and electronic equipment
CN113505082B (en) * 2021-09-09 2021-12-14 腾讯科技(深圳)有限公司 Application program testing method and device
US11487931B1 (en) * 2021-10-18 2022-11-01 International Business Machines Corporation Replaying a webpage based on virtual document object model
CN114490315B (en) * 2021-12-16 2022-09-13 北京志凌海纳科技有限公司 Automatic testing method and device for Web application program
CN114706796A (en) * 2022-06-07 2022-07-05 广州易方信息科技股份有限公司 UI (user interface) automatic diff assertion method and device based on DOM (document object model) tree structure

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294107A (en) * 2015-05-27 2017-01-04 富士通株式会社 The method and apparatus generating the test case of Webpage
CN106959921A (en) * 2017-02-20 2017-07-18 百度在线网络技术(北京)有限公司 Automatic test approach, terminal, platform and system
CN108459967A (en) * 2018-03-21 2018-08-28 东南大学 Web application method for generating test case based on user interface state flow-chart

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294107A (en) * 2015-05-27 2017-01-04 富士通株式会社 The method and apparatus generating the test case of Webpage
CN106959921A (en) * 2017-02-20 2017-07-18 百度在线网络技术(北京)有限公司 Automatic test approach, terminal, platform and system
CN108459967A (en) * 2018-03-21 2018-08-28 东南大学 Web application method for generating test case based on user interface state flow-chart

Also Published As

Publication number Publication date
CN112148579A (en) 2020-12-29

Similar Documents

Publication Publication Date Title
CN112148579B (en) User interface testing method and device
US11355157B2 (en) Special effect synchronization method and apparatus, and mobile terminal
CN107329985B (en) Page collection method and device and mobile terminal
CN108156508B (en) Barrage information processing method and device, mobile terminal, server and system
CN108572908B (en) Information feedback method and device
CN104298686B (en) The method and apparatus for modifying server profile
US10298590B2 (en) Application-based service providing method, apparatus, and system
CN111966491B (en) Method for counting occupied memory and terminal equipment
CN104809055B (en) Application program testing method and device based on cloud platform
CN112749074B (en) Test case recommending method and device
JP6915074B2 (en) Message notification method and terminal
CN106020945B (en) Shortcut item adding method and device
CN104133752A (en) Monitoring method and monitoring device of operating platform
CN111104380A (en) Application file management method and device, mobile terminal and storage medium
CN107102913B (en) Data back up method, device and computer equipment
CN107770449A (en) continuous shooting method, electronic equipment and storage medium
CN116303085A (en) Test reason analysis method, device, equipment and storage medium
CN107688498B (en) Application program processing method and device, computer equipment and storage medium
CN104166652B (en) Browse information synchronization method and device
CN106371948B (en) A kind of data back up method and terminal device
CN106851023B (en) Method and equipment for quickly making call and mobile terminal
CN106230919B (en) File uploading method and device
CN109325003B (en) Application program classification method and system based on terminal equipment
CN109902484B (en) Processing method of associated application and terminal
CN107533431A (en) Method, apparatus, user interface and the storage medium of display 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
GR01 Patent grant
GR01 Patent grant