A user interface testing method, device, equipment and medium

By grouping user interface events to generate group test codes, the problem in the existing technology that user interface automated test codes are difficult to read and maintain is solved, the readability and maintainability of test codes are improved, and the workload of testers is reduced. .

CN112817874BActive Publication Date: 2024-08-27DOUYIN VISION CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202110231486.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-02
Publication Date
2024-08-27
Estimated Expiration
2041-03-02

AI Technical Summary

Technical Problem

The existing user interface automated test code is difficult to read and maintain, especially under the changing Web DOM structure, which increases the workload of testers.

Method used

By obtaining the event record information and request record information of the user interface, the events are grouped and the grouped test code is generated to facilitate testing of the user interface.

Benefits of technology

It improves the readability and maintainability of the test code, reduces the tester's workload, and simplifies the code update and maintenance process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112817874B
    Figure CN112817874B
Patent Text Reader

Abstract

The disclosed embodiments relate to a method, device, equipment and medium for testing a user interface, wherein the method comprises: obtaining event record information and request record information of a user interface, wherein the event record information comprises event information of at least two user interface events; grouping the user interface events according to the request record information to obtain event groups; generating a group test code for the user interface based on the event groups and the event record information, and testing the user interface using the group test code. By adopting the above technical solution, a group test code for the user interface can be automatically generated by grouping the user interface events, thereby implementing the testing of the user interface, improving the readability and maintainability of the test code, and reducing the workload of the tester.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, equipment and medium for testing a user interface. Background Art

[0002] The User Interface (UI) is the medium for interaction and information exchange between the system and the user. In order to ensure the performance of the user interface, the user interface needs to be tested.

[0003] Automated testing of user interfaces usually requires the generation of automated test code. However, in practice, the automatically generated test code is not only difficult to read but also difficult to maintain, which increases the workload of testers. Summary of the invention

[0004] In order to solve the above technical problem or at least partially solve the above technical problem, the present disclosure provides a method, device, equipment and medium for testing a user interface.

[0005] The present disclosure provides a method for testing a user interface, the method comprising:

[0006] Acquire event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events;

[0007] Grouping the user interface events according to the request record information to obtain event groups;

[0008] A group test code of the user interface is generated based on the event grouping and the event record information, and the user interface is tested using the group test code.

[0009] The present disclosure also provides a user interface testing device, the device comprising:

[0010] An information acquisition module, used to acquire event record information and request record information of a user interface, wherein the event record information includes event information of at least two user interface events;

[0011] An event grouping module, used for grouping the user interface events according to the request record information to obtain event groups;

[0012] A testing module is used to generate a group test code for the user interface based on the event grouping and the event record information, and use the group test code to test the user interface.

[0013] An embodiment of the present disclosure also provides an electronic device, which includes: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement a user interface testing method as provided in an embodiment of the present disclosure.

[0014] The embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the user interface testing method provided by the embodiment of the present disclosure.

[0015] Compared with the prior art, the technical solution provided by the embodiment of the present disclosure has the following advantages: the user interface testing solution provided by the embodiment of the present disclosure obtains the event record information and request record information of the user interface, wherein the event record information includes the event information of at least two user interface events; the user interface events are grouped according to the request record information to obtain event groups; based on the event groups and event record information, the user interface grouping test code is generated, and the user interface is tested using the grouping test code. By adopting the above technical solution, the user interface grouping test code can be automatically generated by grouping the user interface events, thereby realizing the testing of the user interface, improving the readability and maintainability of the test code, and reducing the workload of the tester. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0017] Figure 1 A flowchart of a method for testing a user interface provided by an embodiment of the present disclosure;

[0018] Figure 2 A flowchart of another method for testing a user interface provided by an embodiment of the present disclosure;

[0019] Figure 3 A schematic diagram of event grouping provided by an embodiment of the present disclosure;

[0020] Figure 4 A schematic diagram of another event grouping provided by an embodiment of the present disclosure;

[0021] Figure 5 A schematic diagram of the structure of a user interface testing device provided in an embodiment of the present disclosure;

[0022] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0024] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0025] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0026] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0027] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0028] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0029] Automated testing for user interfaces usually requires generating automated testing code. Code block [1] is an example of a UI test code. Code block [1] is:

[0030] 1.cy.get(".header-title:nth-child(2)").click();

[0031] 2.cy.get(".content-item:nth-child(2).form:nth-child(1).input:nth-child(1)").click();

[0032] 3.cy.get(".content-item:nth-child(2).form:nth-child(1).input:nth-child(1)").type("username");

[0033] 4.cy.get(".content-item:nth-child(2).select-view-value:nth-child(1)").click();

[0034] 5.cy.get(".select-option:nth-child(2)").click();

[0035] 6.cy.get(".wrapper-children>.input-clear-wrapper>.input").click();

[0036] 7.cy.get(".wrapper-children>.input-clear-wrapper>.input").type("password");

[0037] 8.cy.get(".col-24>.btn").click();

[0038] 9.cy.get("span:nth-child(2)").click();

[0039] 10.cy.get(".wrapper-children>.input").click();

[0040] 11.cy.get(".wrapper-children>.input").type("item_name");

[0041] 12.cy.get(".form-item:nth-child(3).select-view-placeholder").click();

[0042] 13.cy.get(".select-option:nth-child(1)").click();

[0043] 14.cy.get(".form-item:nth-child(4).select-view-placeholder").click();

[0044] 15.cy.get(".select-option:nth-child(1)").click();

[0045] 16.cy.get(".form-item:nth-child(5)label").click();

[0046] 17.cy.get(".form-item:nth-child(5).select-view-placeholder").click();

[0047] 18.cy.get(".select-option:nth-child(1)").click();

[0048] 19.cy.get(".form-item:nth-child(6)label").click();

[0049] 20.cy.get(".select-view-placeholder").click();

[0050] 21.cy.get(".select-option:nth-child(1)").click();

[0051] 22.cy.get(".select-option:nth-child(2)").click();

[0052] 23.cy.get(".form-item:nth-child(6)label").click();

[0053] 24.cy.get(".btn:nth-child(2)>span").click();

[0054] 25.cy.get(".btn:nth-child(2)>span").click();

[0055] 26.cy.get(".btn-primary").click();

[0056] 27.cy.get(".upload>input").attachFile("5.docx",{force:true});

[0057] 28.cy.get(".index__user-name-r_CWm").click();

[0058] The process represented by the above code block [1] may include logging in, adding an item, uploading a file "5.docx", and logging out. However, in practice, the above code is not only difficult to read, but also very difficult to maintain, especially for the ever-changing DOM structure of the Web. For example, when changing the login code, it is necessary to find the login code in the code block [1] and then modify it. This makes the code update process cumbersome and difficult to maintain, which increases the workload of testers.

[0059] In order to solve the above problems, the embodiments of the present disclosure provide a user interface testing method that can generate grouped test codes. Grouping the test codes for UI automation testing is an effective means. For example, for the above code block [1], after grouping, the code block [2] is as follows:

[0060]

[0061]

[0062] The above grouped test codes are not only clear at a glance, but also increase readability and maintainability. For example, if there is a code group corresponding to "login", then different test cases can call this code group (function) when they need to use the login code; and if the UI of the "login" module changes, only this code group needs to be changed. The method is specifically introduced in conjunction with a specific embodiment.

[0063] Figure 1 The present invention provides a flowchart of a method for testing a user interface, which can be performed by a user interface testing device, wherein the device can be implemented by software and / or hardware, and can generally be integrated in an electronic device. Figure 1 As shown, the method includes:

[0064] Step 101: Acquire event record information and request record information of a user interface, wherein the event record information includes event information of at least two user interface events.

[0065] Among them, the user interface can be understood as the user's operating interface. The embodiments of the present disclosure do not limit the specific user interface. For example, the user interface can be a web page on the Web end. Event record information refers to event information obtained by recording user interface events (UI events) occurring on the user interface. A user interface event can be a process in which an instruction sent by a user through a page element in the user interface is responded to. For example, a user interface event can include clicks, double-clicks, input, copy and paste, etc., without specific limitations. The event information of a user interface event may include various related information of the user interface event, such as at least one of the event location, event time, and event object information.

[0066] Request record information refers to request information obtained by recording network requests issued by users operating on the user interface, and the request record information may include request information of at least two network requests. The network request may be an HTTP request or an HTTPS request sent to the server, and the request information may include information such as a Uniform Resource Locator (URL), a request header, and a request number. There is no limit on the number of network requests.

[0067] In the disclosed embodiment, obtaining the event record information and request record information of the user interface may include: obtaining the event record information and request record information of the user interface through a preset request interface. The request interface refers to a functional interface for simultaneously recording the user interface events corresponding to the user's operations and the requests of the XHR (XMLHttpRequest) object. The record information of the user interface events and network requests can be obtained through the request interface. The above-mentioned XHR object is used to interact with the server for data. The network request can be recorded by monitoring the XHR object. The specific request interface is not limited in the disclosed embodiment. For example, the application programming interface (API) such as "A.webRequest.onBeforeRequest" and "A.webRequest.onSendHeaders" provided in the A browser can obtain the request information of the network request through the API. The above-mentioned A browser is a browser that can provide the API.

[0068] In addition, when obtaining the event record information of the user interface through the request interface, the request interface supports selecting the recorded user interface events by configuring the listening events, for example, only the event information of the modification event, click event and copy event can be obtained through configuration. Optionally, the request interface also supports the configuration of other related rules, such as the configuration of the regular expression for filtering URLs, etc. By configuring the request interface, more flexible information recording can be achieved, which improves the scalability of test code generation.

[0069] Optionally, the event object information is used to record the relevant information of the event object corresponding to the user interface event. In the embodiment of the present disclosure, the event object can be recorded in two ways. One way is to use a file management library (such as Finder) to record the positioning element (CSS selector) of the event object, and the other way is to record the absolute pixel position of the event object on the Hyper Text Markup Language (HTML), such as pageX / pageY / clientX / clientY. The above two ways can be used at the same time, or one can be used according to the actual situation.

[0070] Step 102: Group the user interface events according to the request record information to obtain event groups.

[0071] The event group refers to a group obtained by dividing multiple user interface events on the user interface. The number of event groups is not limited in the embodiments of the present disclosure.

[0072] In an embodiment of the present disclosure, grouping user interface events according to request record information to obtain event groups may include: dividing user interface events with the same network request into a group to obtain at least two event groups, wherein one event group includes multiple user interface events.

[0073] Since the purpose of a user's operation on the Web side is usually to issue a request, it is reasonable for the application of Create, Retrieve, Update, Delete, CRUD on the Web side, because the actual purpose of the user's operation is to modify the data. If no request is issued, the user's operation is meaningless, which is reasonable for most Web-side applications related to data operations. Therefore, the disclosed embodiment can group user interface events based on request record information, and the grouping method is to divide the user interface events for the same network request into an event group to obtain multiple event groups. Specifically, each user interface event and network request can be replayed, and the user interface event corresponding to each user operation can be replayed into a temporary queue. When a network request is monitored, the user interface event in the temporary queue can be taken out and divided into an event group, and the temporary queue is cleared to divide the next group until the remaining user interface events are divided into different event groups according to the network request.

[0074] Optionally, after grouping the user interface events according to the request record information and obtaining the event groups, the method may further include: determining the interface description information of the network request corresponding to each event group based on the mapping relationship between the request information and the interface description information; and determining the keywords in the interface description information as the names of each event group. Optionally, the user interface testing method of the disclosed embodiment may further include: generating a mapping relationship between the request information and the interface description information based on the interface description document of the request interface.

[0075] The interface description document refers to a document that describes the data structure of the request interface. The specific document is not limited, for example, it can be a swagger or other type of API description document. By parsing the interface description document of the request interface, a mapping relationship between the request information of a network request and the interface description information can be generated. For example, a mapping relationship between a method, a uniform resource identifier (URI) and API information can be generated, that is, HTTP-based methods and URIs can be mapped to specific API information.

[0076] Specifically, after the user interface events are grouped, each event grouping can be named for ease of maintenance and understanding. The specific naming method can determine the interface description information of the network request corresponding to each event grouping based on the mapping relationship between the above request information and the interface description information, extract the keywords in the interface description information, and determine the keywords as the name of each event grouping. Optionally, the disclosed embodiment can determine other information in the interface description information as the description of the event grouping. The description of the event grouping is more detailed than the name, which helps to improve readability. For example, for a request for a user to log in to a social networking site, the name of the event grouping is user login, and the description of the event grouping can be user login for the social networking site, supporting information such as mobile phones and email addresses.

[0077] Step 103: Generate a group test code for the user interface based on the event grouping and event record information, and use the group test code to test the user interface.

[0078] The grouped test code refers to the grouped test code of the user interface.

[0079] Specifically, generating group test code for the user interface based on event grouping and event record information may include: using an automated testing framework to generate test code corresponding to each event grouping based on event information of the user interface events included in each event grouping; and combining the test code corresponding to each event grouping to generate group test code for the user interface.

[0080] After obtaining the event information of each user interface event and grouping the user interface events, for each event group, different test codes can be generated using an automated testing framework based on the event information of different recorded user interface events, and then the test codes corresponding to each event group are combined to obtain the final user interface group test code. The present disclosure embodiment does not limit the above automated testing framework, for example, it can be Cypress. For example, assuming that the automated testing framework is Cypress, assuming that the user interface event is for an element<divid=root> ...the click event of the click can generate the test code of "cy.get('#root').click()".

[0081] The user interface testing scheme provided by the embodiment of the present disclosure obtains event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events; groups the user interface events according to the request record information to obtain event groups; generates user interface grouping test code based on the event groups and event record information, and uses the grouping test code to test the user interface. By adopting the above technical scheme, user interface grouping test code can be automatically generated by grouping user interface events, thereby realizing the testing of the user interface, improving the readability and maintainability of the test code, and reducing the workload of testers.

[0082] Figure 2 This is a flow chart of another method for testing a user interface provided by an embodiment of the present disclosure. This embodiment further optimizes the method for testing a user interface based on the above embodiment. Figure 2 As shown, the method includes:

[0083] Step 201: Acquire event record information and request record information of the user interface through a preset request interface.

[0084] The event record information includes event information of at least two user interface events, and the request record information includes request information of at least two network requests.

[0085] Optionally, the event information of the user interface event includes at least one of an event position, an event time, and event object information, and the event object information includes a positioning element of the event object or an absolute pixel position of the event object in a hypertext markup language.

[0086] Step 202: Group user interface events with the same network request into one group to obtain at least two event groups.

[0087] Among them, one event group includes multiple user interface events.

[0088] For example, Figure 3 A schematic diagram of an event grouping provided by an embodiment of the present disclosure, such as Figure 3 As shown, the arrow can represent the timeline, the icon with a black border in the figure represents the user interface event, and the icon without a border represents the network request. Based on the network request, the multiple user interface events in the figure can be divided into 5 event groups, such as Group1, Group2, Group3, Group4 and Group5 in the figure. The user interface events included in each event group can be different. In the figure, Group1, Group2 and Group5 all include three user interface events, Group3 includes 5 user interface events, and Group4 includes one user interface event. Figure 3The division of event groups in is only an example.

[0089] Step 203: Determine the interface description information of the network request corresponding to each event group based on the mapping relationship between the request information and the interface description information.

[0090] Specifically, before step 203, the user interface testing method in the embodiment of the present disclosure may further include: generating a mapping relationship between the request information and the interface description information based on the interface description document of the request interface.

[0091] Step 204: Determine the keywords in the interface description information as the names of each event group.

[0092] For example, Figure 4 A schematic diagram of another event grouping provided in an embodiment of the present disclosure, compared to Figure 3 , Figure 4 The request information of the network request corresponding to the first event group, Group1, can be sent to the matching module. The matching module can determine the corresponding interface description information based on the mapping relationship between the request information and the interface description information, and obtain the new name and description of Group1 in the figure based on the interface description information.

[0093] Step 205: Generate test codes corresponding to each event group using an automated testing framework according to event information of the user interface events included in each event group.

[0094] Step 206: Combine the test codes corresponding to each event group to generate a group test code for the user interface.

[0095] Step 207: Test the user interface using the group test code.

[0096] Next, the test method of the user interface in the embodiment of the present disclosure is further explained by a specific example. The specific process may include: 1. Recording of UI events and HTTP requests. 1) For recording of UI events, the recording of UI events can be done by listening to the occurrence of each UI event on the document object (document), and capturing and truncating the UI event. The above UI events may include single click (click), double click (dbclick), typing (type), modification (change), etc. Whenever a subscribed UI event occurs, the corresponding information (where is the click? What is entered? Etc.) and each time these occur, object information (e.g., what event is sent on which object), etc., can be obtained and recorded. There are two ways to record objects. One is to use a library such as Finder to record the CSS selector of the object, and the other is to record the absolute pixel position of the object on HTML. At this stage, the above two methods can be used, but when using, replaying and converting test codes, the solution of recording absolute pixel positions can be used. If you are familiar with the front-end framework, you can use the CSS solution, which can be set according to actual conditions. 2) For recording HTTP requests, a preset request interface can be used for recording, such as the Application Programming Interface (API) such as "A.webRequest.onBeforeRequest" and "A.webRequest.onSendHeaders" provided in the A browser. The request information of the network request can be obtained through the API. The above-mentioned A browser is a browser that can provide the API. And the test code of the request interface can be assembled through the API and its request identifier (Request ID).

[0097] 2. Grouping and naming of UI event streams. Since the purpose of a user's operation on the Web is usually to issue a request, it is reasonable to apply CRUD functions on the Web because the actual purpose of the user's operation is to modify the data. If a request is not issued, the user's operation is meaningless. This is reasonable for most Web applications related to data operations. Therefore, Figure 3As shown in the figure, the user's UI operations and the requests of the XHR object are recorded at the same time through the request interface, and the UI events and network requests are played back. Each user operation is played back into a temporary queue. When a request is made by an XHR object, all UI operations in the temporary queue are taken out and grouped together. The queue is cleared and the next group is waited for to be completed. Finally, the UI events of different UI operations are grouped into different groups according to the requests, as shown in the figure. Figure 3 Group 1, Group 2, Group 3, Group 4 and Group 5. The playback of UI events and network requests can be implemented in the browser by calling an interface to execute corresponding codes, such as using jQuery or which.

[0098] After the UI events are grouped, there will be a question of how to describe the event grouping. Of course, the above meaningless subtitles and / or numbers are used for naming. However, such naming is meaningless and not easy to maintain and understand. If manual renaming is required, it is also a heavy burden for testers. The disclosed embodiment can use swagger or other types of API description documents. First, swagger is parsed and a mapping relationship from (method, URI) to API information is generated, that is, a data structure of API information is returned given an HTTP method and URI. Through this mapping relationship, after the UI events are grouped, the API information can be used to name each event group and add information. See Figure 4 Specifically, the name of the event group can be named as the keyword of the API information, or other information in the API information can be used as the description of the event group.

[0099] The control flow described above can be expressed in code as follows:

[0100]

[0101]

[0102] 3. Generation of UI automated test code. After recording the UI events and HTTP requests, you can generate UI automated test code. There are many ways to achieve this. Different test codes can be generated based on different recorded UI events (e.g. click, double-click, input, copy, paste, etc.). Taking the Cypress automated test framework as an example, if you record a test for an element <div id=root> ... For the click event of the click, you can generate the test code of "cy.get('#root').click()", and other events can be generated in the same way. Then combine the test codes corresponding to each event group to get the final group test code of the user interface.

[0103] The disclosed embodiment can aggregate and classify UI operation flows according to HTTP requests and generate automated group test code, effectively reducing the workload of testers in writing UI automated test code, the workload of grouping UI automated test code, and the workload of grouping code describing UI automated test. Based on the disclosed embodiment, by installing a request interface that can simultaneously record user UI operations and network requests, easy-to-read and easy-to-maintain group test code for UI automated testing can be generated, and automated test code for the request interface can also be generated.

[0104] The user interface testing scheme provided by the embodiment of the present disclosure obtains the event record information and request record information of the user interface through a preset request interface, divides the user interface events with the same network request into a group, obtains at least two event groups, determines the interface description information of the network request corresponding to each event group based on the mapping relationship between the request information and the interface description information, determines the keyword in the interface description information as the name of the event group, and uses the automated testing framework to generate the test code corresponding to each event group according to the event information of the user interface event included in each event group, combines the test code corresponding to each event group to generate the group test code of the user interface, and uses the group test code to test the user interface. By adopting the above technical scheme, the group test code of the user interface can be automatically generated by grouping the user interface events, thereby realizing the testing of the user interface, improving the readability and maintainability of the test code, and reducing the workload of the tester.

[0105] Figure 5 This is a schematic diagram of the structure of a user interface testing device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 5 As shown, the device comprises:

[0106] The information acquisition module 301 is used to acquire event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events;

[0107] An event grouping module 302, configured to group the user interface events according to the request record information to obtain event groups;

[0108] The testing module 303 is used to generate a group testing code for the user interface based on the event grouping and the event record information, and use the group testing code to test the user interface.

[0109] Optionally, the information acquisition module 301 is specifically used for:

[0110] The event record information and request record information of the user interface are obtained through a preset request interface, wherein the request record information includes request information of at least two network requests.

[0111] Optionally, the event grouping module 302 is specifically used for:

[0112] The user interface events with the same network request are divided into a group to obtain at least two event groups, wherein one of the event groups includes a plurality of user interface events.

[0113] Optionally, the device further comprises a naming module, which is used to: group the user interface events according to the request record information, and after obtaining the event groups,

[0114] Determine the interface description information of the network request corresponding to each of the event groups based on the mapping relationship between the request information and the interface description information;

[0115] The keyword in the interface description information is determined as the name of each of the event groups.

[0116] Optionally, the device further includes a mapping relationship module, configured to:

[0117] Based on the interface description document of the request interface, a mapping relationship between the request information and the interface description information is generated.

[0118] Optionally, the test module is specifically used for:

[0119] According to the event information of the user interface event included in each of the event groups, using an automated testing framework to generate a test code corresponding to each of the event groups;

[0120] The test codes corresponding to the event groups are combined to generate the group test code of the user interface.

[0121] Optionally, the event information of the user interface event includes at least one of event location, event time and event object information.

[0122] The user interface testing device provided in the embodiments of the present disclosure can execute the user interface testing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0123] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6, which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present disclosure. The electronic device 400 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0124] like Figure 6 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0125] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0126] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 409, or installed from a storage device 408, or installed from a ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the test method of the user interface of the embodiment of the present disclosure are executed.

[0127] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0128] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0129] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0130] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events; groups the user interface events according to the request record information to obtain event groups; generates a group test code for the user interface based on the event group and the event record information, and uses the group test code to test the user interface.

[0131] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0132] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0133] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0134] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0135] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0136] According to one or more embodiments of the present disclosure, the present disclosure provides a method for testing a user interface, including:

[0137] Acquire event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events;

[0138] Grouping the user interface events according to the request record information to obtain event groups;

[0139] A group test code of the user interface is generated based on the event grouping and the event record information, and the user interface is tested using the group test code.

[0140] According to one or more embodiments of the present disclosure, in the user interface testing method provided by the present disclosure, the step of obtaining event record information and request record information of the user interface includes:

[0141] The event record information and request record information of the user interface are obtained through a preset request interface, wherein the request record information includes request information of at least two network requests.

[0142] According to one or more embodiments of the present disclosure, in the user interface testing method provided by the present disclosure, the user interface events are grouped according to the request record information to obtain event groups, including:

[0143] The user interface events with the same network request are divided into a group to obtain at least two event groups, wherein one of the event groups includes a plurality of user interface events.

[0144] According to one or more embodiments of the present disclosure, in the user interface testing method provided by the present disclosure, the user interface events are grouped according to the request record information, and after the event groups are obtained, the method further includes:

[0145] Determine the interface description information of the network request corresponding to each of the event groups based on the mapping relationship between the request information and the interface description information;

[0146] The keyword in the interface description information is determined as the name of each of the event groups.

[0147] According to one or more embodiments of the present disclosure, the user interface testing method provided by the present disclosure further includes:

[0148] Based on the interface description document of the request interface, a mapping relationship between the request information and the interface description information is generated.

[0149] According to one or more embodiments of the present disclosure, in the user interface testing method provided by the present disclosure, generating a group test code of the user interface based on the event grouping and the event record information includes:

[0150] According to the event information of the user interface event included in each of the event groups, using an automated testing framework to generate a test code corresponding to each of the event groups;

[0151] The test codes corresponding to the event groups are combined to generate the group test code of the user interface.

[0152] According to one or more embodiments of the present disclosure, in the user interface testing method provided by the present disclosure, the event information of the user interface event includes at least one of event location, event time, and event object information.

[0153] According to one or more embodiments of the present disclosure, the present disclosure provides a testing device for a user interface, comprising:

[0154] An information acquisition module, used to acquire event record information and request record information of a user interface, wherein the event record information includes event information of at least two user interface events;

[0155] An event grouping module, used for grouping the user interface events according to the request record information to obtain event groups;

[0156] A testing module is used to generate a group test code for the user interface based on the event grouping and the event record information, and use the group test code to test the user interface.

[0157] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the information acquisition module is specifically used for:

[0158] The event record information and request record information of the user interface are obtained through a preset request interface, wherein the request record information includes request information of at least two network requests.

[0159] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the event grouping module is specifically used for:

[0160] The user interface events with the same network request are divided into a group to obtain at least two event groups, wherein one of the event groups includes a plurality of user interface events.

[0161] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the device further includes a naming module, which is used to: group the user interface events according to the request record information, and after obtaining the event groups,

[0162] Determine the interface description information of the network request corresponding to each of the event groups based on the mapping relationship between the request information and the interface description information;

[0163] The keyword in the interface description information is determined as the name of each of the event groups.

[0164] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the device further includes a mapping relationship module, which is used to:

[0165] Based on the interface description document of the request interface, a mapping relationship between the request information and the interface description information is generated.

[0166] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the testing module is specifically used for:

[0167] According to the event information of the user interface event included in each of the event groups, using an automated testing framework to generate a test code corresponding to each of the event groups;

[0168] The test codes corresponding to the event groups are combined to generate the group test code of the user interface.

[0169] According to one or more embodiments of the present disclosure, in the user interface testing device provided by the present disclosure, the event information of the user interface event includes at least one of an event location, an event time, and event object information.

[0170] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:

[0171] processor;

[0172] a memory for storing instructions executable by the processor;

[0173] The processor is used to read the executable instructions from the memory and execute the instructions to implement any user interface testing method provided in the present disclosure.

[0174] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute any of the user interface testing methods provided by the present disclosure.

[0175] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0176] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0177] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for testing a user interface, characterized in that: include: Acquire event record information and request record information of the user interface, wherein the event record information includes event information of at least two user interface events; Grouping the user interface events according to the request record information to obtain event groups; Generate a group test code of the user interface based on the event grouping and the event record information, and use the group test code to test the user interface, wherein the group test code refers to the test code of the user interface after it has been grouped; The obtaining of event record information and request record information of the user interface includes: Acquire event record information and request record information of the user interface through a preset request interface, wherein the request record information includes request information of at least two network requests; The user interface events are grouped according to the request record information to obtain the event groups, and the method further includes: Determine the interface description information of the network request corresponding to each of the event groups based on the mapping relationship between the request information and the interface description information; The keyword in the interface description information is determined as the name of each of the event groups.

2. The method according to claim 1, characterized in that The user interface events are grouped according to the request record information to obtain event groups, including: The user interface events with the same network request are divided into a group to obtain at least two event groups, wherein one of the event groups includes a plurality of user interface events.

3. The method according to claim 1, characterized in that Also includes: Based on the interface description document of the request interface, a mapping relationship between the request information and the interface description information is generated.

4. The method according to claim 1, characterized in that: Generating a group test code of the user interface based on the event grouping and the event record information, including: According to the event information of the user interface event included in each of the event groups, using an automated testing framework to generate a test code corresponding to each of the event groups; The test codes corresponding to the event groups are combined to generate the group test code of the user interface.

5. The method according to any one of claims 1 to 4, characterized in that: The event information of the user interface event includes at least one of event location, event time, and event object information.

6. A user interface testing device, characterized in that: include: An information acquisition module, used to acquire event record information and request record information of a user interface, wherein the event record information includes event information of at least two user interface events; An event grouping module, used for grouping the user interface events according to the request record information to obtain event groups; A testing module, used for generating a grouping test code of the user interface based on the event grouping and the event record information, and using the grouping test code to test the user interface, wherein the grouping test code refers to the test code of the user interface after it has been grouped; The information acquisition module is specifically used for: Acquire event record information and request record information of the user interface through a preset request interface, wherein the request record information includes request information of at least two network requests; The device further comprises a naming module, which is used to: group the user interface events according to the request record information, and after obtaining the event groups, Determine the interface description information of the network request corresponding to each of the event groups based on the mapping relationship between the request information and the interface description information; The keyword in the interface description information is determined as the name of each of the event groups.

7. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the user interface testing method described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the user interface testing method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Atom manipulation encapsulation apparatus and method

    CN101216766A

  • Automatic performance test system and method of mobile application based on Http protocol

    CN104579822A

  • Automatic test method and system

    CN107040433A

  • Test method and electronic device

    CN107402880A

  • Method for recording HTTP operation request and automatically generating performance test script

    CN110336717A