Web page testing method, device and medium for application program

By acquiring the request queue of web page operations, identifying request object attributes, generating executable code classes, orchestrating test case data, and dynamically injecting test cases, the frequent adaptation problem in UI automation testing is solved, improving testing efficiency and stability.

CN116340156BActive Publication Date: 2025-12-19INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310256895.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-08
Publication Date
2025-12-19
Estimated Expiration
2043-03-08

AI Technical Summary

Technical Problem

Existing UI automation testing methods require frequent adaptation and modification of test cases, resulting in high maintenance costs, low execution efficiency, instability, and susceptibility to operating system and browser environments.

Method used

By acquiring the request queue generated by web page operations, identifying request object attributes, generating executable code classes, obtaining attribute values, orchestrating test case data, dynamically injecting test cases, simulating user operations, and bypassing the impact of page element changes.

Benefits of technology

It improves the efficiency and coverage of test case acquisition, reduces maintenance difficulty, and enhances the stability and efficiency of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116340156B_ABST
    Figure CN116340156B_ABST
Patent Text Reader

Abstract

The present disclosure provides a web page testing method of an application program, relates to the technical field of software testing, and can be used in the financial field or other fields. The method comprises the following steps: obtaining at least one request generated by a predetermined user performing at least one operation in a web page to obtain a request queue; identifying parameters in each request from a message of each request in the request queue to obtain attributes of each request object; generating executable code classes of each request object based on the attributes of each request object; obtaining values of the attributes of each request object to obtain test case data; arranging the executable code classes of each request object according to an order of the requests in the request queue to obtain to-be-executed case code; obtaining a test case class based on the to-be-executed case code and the test case data; and testing the application program based on the test case class. The present disclosure also provides a web page testing device of an application program, equipment, a storage medium and a program product.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of software testing, which can be used in the financial field or other fields, and more particularly to a web page testing method, device, equipment, medium and program product of an application. BACKGROUND

[0002] With the increasing pace of software delivery, the introduction of DevOps (Development and Operation) in the software development process can greatly ensure the quality and efficiency of software delivery, and automated testing is a key link for the successful development of DevOps. Since web applications mainly provide page operation and interaction for users, the efficiency of writing, the success rate of running, and the maintenance cost of the page function automation testing (hereinafter referred to as UI automation testing) case of the web application greatly determine the delivery pace and quality of the software.

[0003] The general solution or idea of UI automation testing is to locate the page elements to be operated according to the key page element tags to drive the browser to simulate user operations (such as single click, double click, input text, etc.) for testing. However, this method has the following defects: on the one hand, the page elements need to be located, so the test case needs to be constantly adapted and modified with the adjustment of the web page of the application, resulting in high maintenance cost of the test case; on the other hand, the number of test cases obtained by driving the browser to simulate user operations is limited and the efficiency is low, and the execution of the test case is affected by various factors such as operating system, browser and other software environment, which is unstable. SUMMARY

[0004] In view of the above problems, the present disclosure provides a web page testing method, device, equipment, medium and program product of an application, which can improve the efficiency of UI automation testing.

[0005] According to a first aspect of the present disclosure, a web page testing method of an application is provided. The method comprises: obtaining at least one request generated by a predetermined user performing at least one operation in the web page to obtain a request queue; identifying parameters in each request from the message of each request in the request queue to obtain the attributes of each request object; generating executable code classes of each request object based on the attributes of each request object; obtaining the values of the attributes of each request object to obtain test case data; arranging the executable code classes of each request object in the order of the requests in the request queue to obtain to-be-executed case code; obtaining a test case class based on the to-be-executed case code and the test case data; and testing the application based on the test case class.

[0006] According to an embodiment of the present disclosure, the obtaining the value of the attribute of each request object includes: extracting the value of the parameter in each request from the message of each request in the request queue to obtain the default value of the attribute of each request object; and obtaining the modification value of the default value of the attribute of each request object.

[0007] According to an embodiment of the present disclosure, the testing the application based on the test case class includes: reading the value of the attribute of the request object selected by the user from the test case data; injecting the value of the attribute of the request object selected by the user into the to-be-executed case code to generate a test case; and testing the application by using the test case.

[0008] According to an embodiment of the present disclosure, the injecting the value of the attribute of the request object selected by the user into the to-be-executed case code to generate a test case includes: instantiating the executable code class of each request object in the to-be-executed case code by using the attribute of the request object selected by the user to generate a request instance of each request object. The testing the application by using the test case includes: sequentially sending the request instance of each request object according to the order of the requests in the request queue.

[0009] According to an embodiment of the present disclosure, the testing the application based on the test case class further includes: obtaining execution result information after the test case is executed; and recording the value of the attribute of the request object in the test case and the execution result information in association with the test case.

[0010] According to an embodiment of the present disclosure, the generating the executable code class of each request object based on the attribute of each request object includes: instantiating a predefined executable code template by using the parameter in each request to obtain the executable code class of each request object.

[0011] According to an embodiment of the present disclosure, the parameter in each request includes at least one of the following: an input parameter, an output parameter, an interface protocol type, a request mode, an interface calling address, or an encoding format. The executable code template is provided with a keyword identifier for annotating each parameter. The instantiating the predefined executable code template by using the parameter in each request to obtain the executable code class of each request object includes: identifying the keyword identifier in the executable code template; and filling the parameter in each request into a position indicated by the keyword identifier for annotating the parameter.

[0012] According to an embodiment of the present disclosure, the identifying the parameters in each request from the request message of each request in the request queue comprises: extracting the input parameters from a uniform resource locator in a request header of the request message; and extracting the input parameters from a request body of the request message.

[0013] According to an embodiment of the present disclosure, the identifying the parameters in each request from the request message of each request in the request queue comprises: extracting the output parameters exchanged in a JSON format from the return message of each request.

[0014] According to an embodiment of the present disclosure, the obtaining at least one request generated by the predetermined user performing at least one operation on the Web page to obtain a request queue comprises: obtaining the request message and the return message generated by the predetermined user operating the Web page between a specified start signal and a termination signal.

[0015] In a second aspect, the present disclosure provides a Web page testing device of an application program. The device comprises a case generation service module and a case execution service module. Wherein,

[0016] The case generation service module comprises a request analysis framework and a case generation framework. Wherein, the request analysis framework is configured to: obtain at least one request generated by a predetermined user performing at least one operation on the Web page to obtain a request queue; identify the parameters in each request from the request message of each request in the request queue to obtain the attributes of each request object; and generate an executable code class of each request object based on the attributes of each request object. The case generation framework is configured to: obtain the values of the attributes of each request object to obtain test case data; arrange the executable code class of each request object in the order of the requests in the request queue to obtain a to-be-executed case code; and obtain a test case class based on the to-be-executed case code and the test case data. The case execution service module is configured to test the application program based on the test case class.

[0017] According to an embodiment of the present disclosure, the case execution service module is specifically configured to: read the values of the attributes of the request object selected by the user from the test case data; inject the values of the attributes of the request object selected by the user into the to-be-executed case code to generate a test case; and test the application program by using the test case.

[0018] According to an embodiment of the present disclosure, the case execution service module is further configured to obtain execution result information after the test case is executed, and record the values of the attributes of the request object in the test case and the execution result information associated with the test case.

[0019] In a third aspect, an electronic device is provided. The electronic device includes one or more processors and memory. The memory is configured to store one or more programs. The one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method described above.

[0020] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores executable instructions, which, when executed by a processor, cause the processor to perform the method described above.

[0021] In a fifth aspect, a computer program product is provided. The computer program product includes a computer program, which, when executed by a processor, implements the method described above.

[0022] The one or more embodiments described above have the following advantages or beneficial effects: the behavior of simulating user operations on a Web page can be at least partially bypassed, and the influence of changes in elements of the Web page on the written test cases is reduced. Therefore, by obtaining the request queue, a test case class including test case code to be executed and test case data is obtained, and when testing, the test case data can be injected into the test case code to be executed to generate specific executable test cases for testing. Thus, a series of test cases with the same attributes can be executed based on one test case class, which significantly improves the efficiency of obtaining test cases and the coverage of testing the Web page. BRIEF DESCRIPTION OF DRAWINGS

[0023] The above and other objects, features and advantages of the present disclosure will become more apparent from the following description when taken in conjunction with the accompanying drawings, in which:

[0024] Figure 1 An application scenario diagram of a Web page testing method, apparatus, device, medium and program product of an application program according to an embodiment of the present disclosure is schematically shown;

[0025] Figure 2 A flowchart of a Web page testing method of an application program according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 3 A property configuration of a request object according to an embodiment of the present disclosure is schematically shown;

[0027] Figure 4 A property configuration of a test case class according to an embodiment of the present disclosure is schematically shown;

[0028] Figure 5 A flowchart of testing an application program based on a test case class in an embodiment of the present disclosure is schematically shown.

[0029] Figure 6 A schematic diagram illustrating the orchestration and sequential execution of request instances in a test case of an embodiment of the present disclosure is shown;

[0030] Figure 7 A flowchart illustrating a web page testing method of an application according to another embodiment of the present disclosure is shown;

[0031] Figure 8 A schematic diagram illustrating the operation of a case executor for testing an application in an embodiment of the present disclosure is shown;

[0032] Figure 9 A block diagram illustrating the structure of a web page testing apparatus for an application according to an embodiment of the present disclosure is shown; and

[0033] Figure 10 A block diagram of an electronic device suitable for implementing a web page testing method of an application according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0034] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood, however, that the description which follows is merely illustrative and is not intended to limit the scope of the present disclosure. In the following detailed description of embodiments of the present disclosure, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure. However, it will be apparent to one skilled in the art that one or more embodiments of the present disclosure can be practiced without these specific details. In other instances, well-known structures and functions have not been described in detail in order to avoid obscuring aspects of the present disclosure.

[0035] The terms used herein are merely used to describe specific embodiments and are not intended to limit the present disclosure. The terms "include", "comprise", and the like used herein indicate the presence of the described features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0036] All terms used herein, including technical and scientific terms, have the same meanings as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having meanings consistent with the context of the present description, and should not be interpreted in an idealized or overly formal manner.

[0037] In the case of using expressions similar to "at least one of A, B, and C, etc.", it is generally understood that the expression is used to include at least one of A, B, or C (e.g., to the effect that the word "or" has the same meaning as "and / or" as generally used (e.g., "A, B, and / or C" would include at least one of A, B, or C, etc.). Also, in the case of using an expression similar to "at least one of A, B, and C, etc.", it is generally understood that the expression is used to include more than one element (e.g., to the effect that the expression "at least one of A, B, and C" would include, for example, A alone, B alone, C alone, A and B together, A and C together, B and C together, or A, B, and C together, etc.). Also, as used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. It is further to be understood that the use of "a", "an", "the" and similar referents in the context of describing the embodiments (especially in the context of the following claims) are to be construed to cover both the singular and the plural, unless otherwise indicated herein or clearly contradicted by context. Recitation of ranges of values herein are merely intended to serve as a shorthand method of referring individually to each separate value falling within the range, unless otherwise indicated herein and each separate value is incorporated into the specification as if it were individually recited herein. The use of any and all examples, or exemplary language (e.g., "such as") provided herein, is intended merely to better illuminate the application and does not pose a limitation on the scope of the application unless otherwise claimed. No language is intended to indicate that the application will not also encompass isocyanates, isothiocyanates, or thiocyanates. No language in the specification should be construed as indicating any non-claimed element as essential to the practice of the application.

[0038] Embodiments of the present disclosure provide a web page testing method, apparatus, device, medium and program product of an application program. According to the method of the embodiments of the present disclosure, at least one request generated by a predetermined user performing at least one operation in a web page is obtained to obtain a request queue. Then, parameters in each request are identified from the message of each request in the request queue, and each request is abstracted into a request object, taking the parameters in each request as the attributes of each request object. Then, for each request object, an executable code class of each request object is generated. Next, the values of the attributes of each request object are obtained to obtain test case data, and at the same time, the executable code class of each request object can be arranged according to the order of the requests in the request queue to obtain to-be-executed case code, and then based on the to-be-executed case code and the test case data, a test case class is obtained. At this time, in the test execution, the application program can be tested based on the test case class.

[0039] It can be seen that when the web page is tested, the embodiments of the present disclosure obtain the http request data, bypass the behavior of simulating user operation on the browser, and reduce the influence of changes in web page elements on the written test case.

[0040] Moreover, in the embodiments of the present disclosure, based on the obtained request queue, a test case class is obtained, wherein the test case data in the test case class can be injected into the to-be-executed case code in the test execution process to implement the execution of a specific test case. In this way, after obtaining the request queue for performing an operation on a function in a web page, the test case class obtained according to the embodiments of the present disclosure substantially contains a series of test cases that can test the function, which obviously improves the efficiency of obtaining test cases and the efficiency of testing the web page.

[0041] Figure 1 An application scenario diagram of the web page testing method, apparatus, device, medium and program product of an application program according to the embodiments of the present disclosure is schematically shown.

[0042] As Figure 1As shown, the application scenario 100 according to the embodiment can include a test terminal 101, a test server 102, and an application server 103.

[0043] The test server 102 can be communicatively connected with the test terminal 101 and the application server 103 respectively. A test user can send an instruction to the test server 102 through an operation in the test terminal 101, to control the test server 102 to test an application supported by the application server 103.

[0044] The application scenario 100 can further include a proxy server 104 and a user terminal 105. The proxy server 104 can be arranged between the user terminal 105 and the application server 103, to intercept and forward messages between the user terminal 105 and the application server 103.

[0045] A predetermined user (for example, a test recording personnel) can use the user terminal 105 to browse a Web page of an application supported by the application server 103. The predetermined user can perform a series of operations in the Web page through the user terminal 105. The series of requests triggered by the operations can be forwarded through the proxy server 104, to realize the interaction between the user terminal 105 and the application server 103.

[0046] The proxy server 104 can communicate with the test server 102. The proxy server 104 can provide the test server 102 with the interaction request messages between the user terminal 105 and the application server 103, so that the test server 102 can execute the Web page testing method of the application according to the embodiments of the present disclosure, to test the application supported by the application server 103.

[0047] It can be seen that in the application scenario 100, the Web page testing method of the application provided by the embodiments of the present disclosure can be executed by the test server 102. Accordingly, the Web page testing apparatus, device, medium and program product of the application provided by the embodiments of the present disclosure can be arranged in the test server 102. It should be noted that, Figure 1 The above-mentioned application scenario is only an example of an application scenario to which the embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but does not mean that the embodiments of the present disclosure cannot be applied to other devices, systems, environments or scenarios.

[0048] It should be understood that, Figure 1 The number of terminal devices, networks and servers in the above-mentioned application scenario is only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.

[0049] The following will be described based on Figure 1 the above-mentioned scenario, byFigures 2-8 The application page testing method of the embodiments of the present disclosure is described in detail. It should be noted that the serial numbers of the operations in the following method are only used to represent the operations for description, and should not be regarded as representing the execution sequence of the operations. The method does not need to be executed in the order shown unless explicitly indicated.

[0050] Figure 2 The flowchart of the application page testing method according to the embodiments of the present disclosure is schematically shown.

[0051] As Figure 2 shown, the application page testing method according to the embodiments can include operation S210 to operation S270.

[0052] Firstly, in operation S210, at least one request generated by a predetermined user performing at least one operation in a Web page is obtained to obtain a request queue. Each request includes a request message and a return message.

[0053] Specifically, the predetermined user can open the Web page of the application in the user terminal 105, and then perform a series of operations on the Web page. The proxy server 104 can record all the messages between the user terminal 105 and the application server 103 in the whole process. Thus, the test server 102 can obtain a series of requests generated by the predetermined user performing operations in the Web page through the user terminal 105 from the proxy server 104.

[0054] For example, for a certain function or certain functions of the application, the test recording personnel can use the user terminal 105 to perform corresponding operations in the Web page. For example, for the function of querying project information according to the project number, operations including logging in, finding the project management page from the home page, inputting the project number in the project input box in the project management page, submitting and obtaining feedback results, etc. The information of the interaction process between the user terminal 105 and the application server 103 is forwarded through the proxy server 104, so that all the messages in the whole interaction process can be recorded in the proxy server 104. Specifically, a packet capturing service can be deployed on the proxy server 104, all the requests or responses forwarded on the proxy server 104 are copied to the port to be monitored through the packet capturing service, and then all the monitored http request messages and return messages are recorded to complete the recording of the requests.

[0055] In one embodiment, when test server 102 receives at least one request from proxy server 104, it may receive request and return messages generated by a predetermined user interacting with a web page between a specified start signal and a stop signal. For example, when recording requests on user terminal 105, testers can mark each segment of continuous operation by specifying start and stop signals. This allows each segment of continuous operation to be a complete operation performed on a specific test item in the web application.

[0056] Then, in operation S220, the parameters in each request are identified from the message of each request in the request queue, and the attributes of each request object are obtained. The parameters in each request include at least one of the following: input parameters, output parameters, interface protocol type, request method, interface call address, or encoding format.

[0057] The embodiments of this disclosure can abstract each request into a request object, and analyze each request by means of an object-oriented approach. Figure 3 The attributes of a request object according to an embodiment of the present disclosure are illustrated schematically.

[0058] like Figure 3 As shown, in this embodiment, each request object may have the following attributes: input parameters, output parameters, interface protocol type, request method, interface call address, and encoding format. Accordingly, these parameters can be extracted from the round-trip messages in each request to obtain these attributes of the request object.

[0059] Next, in operation S230, an executable code class for each request object is generated based on the attributes of each request object.

[0060] For example, it can be used according to Figure 3 The system uses the attribute settings shown in the request object, identifies parameters in the request message (such as parameter names or variable characters or strings), instantiates a predefined executable code template for the request object (e.g., a Java code template), and obtains the executable code class for each request object. By implementing the defined executable code template, the efficiency of obtaining the executable code class can be improved.

[0061] Specifically, executable code templates can be pre-written based on the attribute settings in the request object. An example of pseudocode for an executable code template is shown below:

[0062] public class apiobjecttemplate extends restapiobject{

[0063] / / Automatically fill in based on the recording request

[0064] @APIAsQueryString

[0065] public string PopulateFromRecordingRequest automatically fills in;

[0066] / / PopulateFromRecordingRequest automatically fills in

[0067] @JsonAsOutput

[0068] public string PopulateFromRecordingRequest automatically fills in;

[0069] public string geturl(){

[0070] / / PopulateFromRecordingRequest automatically fills in

[0071] }

[0072] / **

[0073] *Please fill in the request encoding type according to the actual situation

[0074] *@return

[0075] * /

[0076] public string getcharset(){

[0077] / / PopulateFromRecordingRequest automatically fills in

[0078] }

[0079] / **

[0080] *Please fill in the return message type according to the actual situation

[0081] *@return

[0082] * /

[0083] public string getreturntype(){

[0084] / / PopulateFromRecordingRequest automatically fills in

[0085] }

[0086] / **

[0087] *Please fill in the request method type according to the actual situation

[0088] *@return

[0089] * /

[0090] public string getmethod(){

[0091] / / Fill in automatically according to the recorded request

[0092] }

[0093] For each to-be-filled string in the above executable code template, the parameter name or variable, etc. character or string recognized in operation S220 can be used for explicit assignment, so as to obtain the executable code class.

[0094] In some embodiments, since the parameters in the request are identified in S220, the parameters and parameter values may be intercepted together, and at this time, in operation S230, the instantiation of the executable code template is explicitly assigned, each parameter and its parameter value can also be filled into the executable code template, and at this time, the obtained executable code class is an executable code segment in which each parameter is assigned a default value. The executable code segment is an instance of the executable code class, and the default value of each parameter in the executable code segment can be replaced, so that when other values different from the default value need to be injected in the subsequent injection, the default value can be replaced. In some embodiments, the default value of each parameter assigned in the executable code segment can also be extracted to obtain the executable code class.

[0095] Next, in operation S240, the value of the attribute of each request object is obtained to obtain the test case data.

[0096] In one embodiment, the value of the parameter in each request message can be extracted from the message of each request in the request queue to obtain the default value of the attribute of each request object, or as mentioned above, the default value of each parameter can be extracted from the executable code segment with the default value generated in operation S230. In other embodiments, the default value can be further modified to obtain the modified value of the default value, so as to expand the test case data, so that the data source relied on when generating the test case later can not be limited to the request obtained during recording.

[0097] Then, in operation S250, the executable code class of each request object is arranged according to the order of the request in the request queue to obtain the to-be-executed case code. One to-be-executed case code corresponds to one request queue.

[0098] Next, in operation S260, the test case class is obtained based on the to-be-executed case code and the test case data.

[0099] This disclosure embodiment can abstract a test case as an object, and use the object's attributes to form a series of test cases with common attributes, that is, to obtain a test case class. The attribute structure of a test case class can be as follows: Figure 4 As shown.

[0100] Figure 4 The illustration schematically depicts the attribute composition of a test case class according to an embodiment of this disclosure. For example... Figure 4 As shown in this embodiment, the attributes of a test case class may include a case name, a list of simulated requests, test case data, execution results, and prompt information. The list of simulated requests records the code to be executed, which is at least one executable code class arranged according to the request order in the request queue of operation S210. The test case data provides the data source for the values ​​of the attributes of each request object in the code to be executed.

[0101] Next, we will operate the S270 and test the application based on the test case class.

[0102] Combination Figure 4 During application testing, parameter values ​​from the test case data can be used to assign values ​​to parameters in the code to be executed, thereby instantiating each executable code class in the code to be executed. Each instance of this executable code class can then trigger the generation of a request instance, as shown below. Figure 6 As shown.

[0103] As can be seen, in this embodiment of the disclosure, a test case class that can be assembled into a series of test cases is obtained based on an acquired request queue. Therefore, when an operation is performed on a function in a web page to obtain a request queue, a series of test cases for testing that function can be obtained, improving the efficiency of obtaining test cases and enhancing the comprehensiveness and completeness of testing that function.

[0104] Furthermore, in this embodiment, the initial data upon which the test case class is generated is the HTTP request data from the interaction between the web page and the backend application, bypassing the identification of web page elements. This reduces the impact of changes in web page elements on the written test cases and lowers the maintenance difficulty of the test cases.

[0105] Furthermore, a test case class can dynamically assemble test cases during the testing process, which increases the number of available test cases, improves the effectiveness of testing web pages, and thus improves the efficiency of testing web pages.

[0106] Figure 5 A flowchart illustrating a test case class-based test application is shown in one embodiment of this disclosure.

[0107] As Figure 5 shown, operation S270 according to this embodiment can include operations S271-S275.

[0108] First, in operation S271, the values of the attributes of the request objects selected by the user from the test case data are read. In one embodiment, the process of selecting the values of the attributes of the request objects by the test user is similar to the input operation when simulating the operation of a certain function on a Web page, such as logging in a username, selecting a drop-down box, or inputting a query number, etc. In other embodiments, the test user can write a script for automatically selecting the values of the attributes of the request objects in a test case class, and then trigger the script in operation S271 to select the attributes of each request object in the test case class.

[0109] Then, in operation S272, the values of the attributes of the request objects selected by the user are injected into the to-be-executed case code to generate a test case.

[0110] Next, in operation S273, the application program is tested using the test case.

[0111] Figure 6 A schematic diagram of the arrangement and sequential execution of the request instances in the test case according to an embodiment of the present disclosure is shown.

[0112] In combination Figure 5 and Figure 6 , in one embodiment, when generating the test case in operation S272, the values of the attributes of one or more request objects involved in the current test can be selected by user operation to simulate the input operation of the user on the Web page, and the executable code of each request object is instantiated according to the values of the attributes of the request objects to generate the request instance of each request object. For example, when the test is executed, the to-be-executed case code is loaded first, and then the parameters specified by the user are read before the test case is started to be executed, and the read parameters are injected into the request message to be sent when the test case is executed. Then, in operation S273, each request instance of the request objects is sent in sequence according to the order of the requests in the request queue.

[0113] As Figure 6As shown, the request queue corresponding to the to-be-executed case code includes request object 1, request object 2 and request object 3. During the test execution process, the user can select and specify the value of the attribute in each request object from the test case data, so as to dynamically generate the request instance of each request object, and send the request message to the application server 103 in sequence according to the order in the request queue. For example, request instance 1 is sent first, and when the return message of request instance 1 is received and the return message conforms to the expectation, request instance 2 is sent. Then when the return message of request instance 2 is received and the return message conforms to the expectation, request instance 3 is sent. Then when the return message of request instance 3 is received and the return message conforms to the expectation, it is determined that the test case test is successful. If the return message of any one of request instance 1, request instance 2 or request instance 3 does not conform to the expectation, the test case fails. When the return message of request instance 1 or request instance 2 does not conform to the expectation, the sending of the subsequent request instance can be interrupted.

[0114] Next, the execution result information after the test case execution can also be obtained at operation S274.

[0115] Then, at operation S275, the value of the attribute of the request object in the test case and the execution result information are recorded in association with the test case. For example, the execution result information can be recorded in the test case class as shown in the following table together with the specific test case (i.e., the execution case), the parameter value and other information, so that the execution results of various test cases are summarized in one test case class, and the running situation of the function to be tested can be analyzed in a centralized manner. Figure 4

[0116] It can be seen that the UI automation test method based on the http request provided by the embodiments of the present disclosure simulates the user operation on the Web page by recording the http request, and completes the result verification according to the service return message. Moreover, by simulating the http request and arranging in sequence, the test case data is dynamically injected to generate and send the message, the execution of various test cases with the same attribute and different parameter values can be performed, various possible operation behaviors of the user are simulated, the test coverage situation is increased, the test is more effective, the execution speed is fast, the success rate is high, and the efficiency of result verification and the frequency of software delivery can be improved.

[0117] Figure 7 A flowchart of a Web page test method of an application program according to another embodiment of the present disclosure is schematically shown.

[0118] As shown in Figure 7 The Web page test method of the application program according to the embodiment can be implemented by three parts of case generation service, case execution service and case query service. ​

[0119] The case generation service mainly intercepts and parses the requests and responses between the user terminal 104 and the application server 103 after the user performs a series of operations on the web page, identifies the key elements in each HTTP request, generates executable code classes for each request, and arranges and executes them according to the pre-recorded request order to form case code to be executed.

[0120] Specifically, the case generation service can perform three steps: request recording (001), request parameter analysis (002), and execution code generation (003).

[0121] In request recording 001, the pre-selected user opens the application's web page on the user terminal 105 and performs a series of operations. Then, the packet capture service deployed on the proxy server 104 forwards all requests or responses between the user terminal 105 and the application server 103 to the port to be listened to. The packet capture service then records all the HTTP request messages and return messages it listens to, thus completing the request recording.

[0122] In Request Parameter Analysis 002, a request can be abstracted as an object. This request object possesses the following basic characteristics: input parameters, output parameters, interface protocol type, request method, interface call address, and encoding format, as described above. Figure 3 As shown. During request analysis, extract from a recorded request message. Figure 3 The parameters corresponding to each attribute shown (such as parameter name or variable name) are then instantiated at the code level according to the predefined executable code template, and the input parameters, output parameters and other attributes are explicitly assigned values, thus instantiating a Java class.

[0123] The parameters in a request can be divided into input parameters and output parameters. Embodiments of this disclosure can extract input parameters from a request message (i.e., a send message) and output parameters from a response message.

[0124] During input parameter analysis, input parameters can be extracted from the Uniform Resource Locator (URL) in the request header and from the request body. For example, variable information can be extracted from the URL in the request header to obtain the input parameters in the URL, and input parameters can be analyzed and extracted from the request body.

[0125] When analyzing output parameters, the variables that are exchanged in JSON format can be extracted from the response message of each request to obtain the output parameters.

[0126] In one embodiment, a keyword identifier can be set in the executable code template for annotating each parameter. In this way, when the pre-defined executable code template is instantiated by using the parameters in each request, the keyword identifier in the executable code template can be identified first, and then each parameter in the request (e.g., parameter name, variable character, or even the value of the parameter, etc.) identified is filled into the position indicated by the keyword identifier for annotating the parameter.

[0127] Specifically, referring to the executable code template in the foregoing example, for the parameters in the request URL, the input parameter in the form of Year=2022 can be cut from the complete request URL and filled into the position annotated by the custom API AsQueryString in the executable code template. For the parameters in the request body, they can be filled into the position annotated by API AsInput in the executable code template. For the output parameters, since the http request currently mainly uses JSON as the main data exchange format, in order to facilitate the positioning and identification of the data in the output message when writing the test case, all the variables in the returned message in JSON form are identified and the variable definition part in the request instance code is generated in the executable code template annotated by the custom JsonAsOutput.

[0128] In the executable code generation 003, the test case is abstracted as an object having a case name, a request queue contained, test case data, execution result of the case, and prompt information, etc. attributes, as shown in the following table. Figure 4 For each request object that has been analyzed and instantiated, the executable code class of each request is arranged in order according to the execution order recorded when the request is recorded, that is, the to-be-executed case code corresponding to the user Web operation is generated.

[0129] The case parameter injection 004 and the case execution 005 can be performed in the case execution service. In one embodiment, the case execution service can perform the execution of the case and the recording of the result through the case executor as shown in the following table. Figure 8

[0130] Figure 8 The running schematic diagram of the case executor of the test application program in one embodiment of the present disclosure is schematically shown. The case executor running time includes the following steps:

[0131] Step S81—Before the case execution, the operation that can be performed before the case execution, such as some data backup or initialization before the case execution, can be specified by the case writer.

[0132] Step S82—Load the case, that is, load the to-be-executed case code into the executor and prepare to run. ​

[0133] Step S83 - inject parameter value. When the case code is generated, the default value of the input parameter in the request can be extracted. In this way, when the user writes the test case, the key input parameters (such as the user login username, password, input data) are specified or modified by the case writer according to the test idea. Before the case is started, the user-specified case parameters are read, and the parameters are injected into the sent message when the case is executed.

[0134] Step S84 - execute the case, and sequentially execute all request instances included in the case, that is, simulate the operation performed by the user on the Web interface.

[0135] Step S85 - after the case is executed, the operation can be performed after the case is executed, which is specified by the case writer, such as cleaning the business data generated during the case execution.

[0136] Step S86 - record the execution result, and record the execution result of the case after the case is executed and insert the case database table, and the record content includes the case name, the case parameter, the execution time, the execution time, and the execution result.

[0137] Case query service: can provide the function of case query for the user, the user can accurately query the case according to the case name and view the execution of the case.

[0138] In this way, the embodiments of the present disclosure simulate the operation of the user on the Web page by recording the request, compared with the traditional test scheme, the case execution is more stable, the http request triggered in the key area marked by the user is accurately identified and simulated, the test case runs faster and more efficiently.

[0139] The embodiments of the present disclosure do not need to position the page elements to write the test case, which makes the case easier to write and greatly reduces the maintenance cost of the case.

[0140] Based on the Web page test method of the application program according to the above various embodiments, the various embodiments of the present disclosure also provide a Web page test device of an application program. The following will be combined with Figure 9 The device will be described in detail.

[0141] Figure 9 The structure block of the Web page test device 900 of the application program according to the embodiments of the present disclosure is schematically shown.

[0142] As Figure 9As shown, the web page testing apparatus 900 of the application according to the embodiments of the present disclosure can include a case generation service module 910 and a case execution service module 920. The case generation service module 910 includes a request analysis framework 911 and a case generation framework 912.

[0143] The request analysis framework 911 is configured to: first acquire at least one request generated by a predetermined user performing at least one operation in a web page to obtain a request queue; then identify parameters in each request from a message of each request in the request queue to obtain attributes of each request object; and next generate executable code classes of each request object based on the attributes of each request object. In an embodiment, the request analysis framework 911 can perform the operations S210-S230 described above.

[0144] The case generation framework 912 is configured to: first acquire values of the attributes of each request object to obtain test case data; then arrange the executable code classes of each request object in the order of the requests in the request queue to obtain to-be-executed case code; and next generate a test case class based on the to-be-executed case code and the test case data. In an embodiment, the case generation framework 912 can perform the operations S240-S260 described above.

[0145] The case execution service module 920 is configured to test the application based on the test case class. In an embodiment, the case execution service module 920 can perform the operation S270 described above.

[0146] In some embodiments, the case execution service module 920 is specifically configured to: read values of attributes of a request object selected by a user from the test case data; inject the values of the attributes of the request object selected by the user into the to-be-executed case code to generate a test case; and test the application by using the test case.

[0147] In other embodiments, the case execution service module 920 is further configured to acquire execution result information after execution of the test case, and record the values of the attributes of the request object in the test case and the execution result information in association with the test case.

[0148] In some embodiments, the apparatus 900 can further include a case query service module. The case query service module can provide the user with a query of relevant data in the test case class, as described above. Figure 7

[0149] According to the embodiments of the present disclosure, the apparatus 900 can perform the method described above with reference to the foregoing description, and details are not described herein again. Figures 2-8

[0150] ​​According to an embodiment of the present disclosure, any of the case generation service module 910, the case execution service module 920, the case query service module, the request analysis framework 911 and the case generation framework 912 can be combined in one module, or any of them can be split into multiple modules. Alternatively, at least part of the function of one or more of these modules can be combined with at least part of the function of the other modules, and implemented in one module. According to an embodiment of the present disclosure, at least one of the case generation service module 910, the case execution service module 920, the case query service module, the request analysis framework 911 and the case generation framework 912 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of integrating or packaging a circuit, etc. hardware or firmware, or any one of the three implementation ways of software, hardware and firmware or any appropriate combination of any of them. Alternatively, at least one of the case generation service module 910, the case execution service module 920, the case query service module, the request analysis framework 911 and the case generation framework 912 can be at least partially implemented as a computer program module which can perform corresponding functions when it is run.

[0151] Figure 10 A block diagram of an electronic device 1000 suitable for implementing the web page testing method of the application according to an embodiment of the present disclosure is schematically shown.

[0152] As shown in Figure 10 The electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001 which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or loaded from a storage portion 1008 into a random access memory (RAM) 1003. The processor 1001 can include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset, and / or a special-purpose microprocessor (such as an application specific integrated circuit (ASIC)), etc. The processor 1001 can also include an on-board memory for cache use. The processor 1001 can include a single processing unit or multiple processing units for performing different actions of the method processes according to an embodiment of the present disclosure.

[0153] In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are stored. The processor 1001, the ROM 1002, and the RAM 1003 are connected to each other via the bus 1004. The processor 1001 performs various operations of the method flow according to the embodiments of the present disclosure by executing the programs in the ROM 1002 and / or the RAM 1003. It should be noted that the programs can also be stored in one or more memories other than the ROM 1002 and the RAM 1003. The processor 1001 can also perform various operations of the method flow according to the embodiments of the present disclosure by executing the programs stored in the one or more memories.

[0154] According to an embodiment of the present disclosure, the electronic device 1000 can further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 can further include one or more of the following components connected to the I / O interface 1005: an input part 1006 including a keyboard, a mouse, etc.; an output part 1007 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 1008 including a hard disk, etc.; and a communication part 1009 including a network interface card such as a LAN card, a modem, etc. The communication part 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1010 as necessary, so that a computer program read out therefrom is installed in the storage part 1008 as necessary.

[0155] The present disclosure also provides a computer readable storage medium, which can be included in the device / apparatus / system described in the above embodiments; or can exist separately without being assembled into the device / apparatus / system. The above computer readable storage medium carries one or more programs, when the one or more programs are executed, the method according to the embodiments of the present disclosure is implemented.

[0156] According to an embodiment of the present disclosure, the computer readable storage medium can be a nonvolatile computer readable storage medium, for example, can include, but is not limited to, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, the computer readable storage medium can include one or more memories such as the ROM 1002 and / or the RAM 1003 described above and / or one or more memory chips other than the ROM 1002 and the RAM 1003.

[0157] Embodiments of the present disclosure also include a computer program product that includes a computer program containing program codes for executing the methods shown in the flowcharts. When the computer program product is run in a computer system, the program codes are used to cause the computer system to implement the methods provided by the embodiments of the present disclosure.

[0158] The above-described functions defined in the system / apparatus / module / unit of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. According to an embodiment of the present disclosure, the above-described system, apparatus, module, unit, etc. can be implemented by the computer program modules.

[0159] In one embodiment, the computer program can rely on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program can also be transmitted, distributed, and / or downloaded in the form of a signal over a network medium and installed and / or installed from the removable medium 1011 through the communication part 1009. The program codes contained in the computer program can be transmitted by any appropriate network medium, including but not limited to wireless, wired, etc., or any appropriate combination thereof.

[0160] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009 and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above-described functions defined in the system of the embodiments of the present disclosure are performed. According to an embodiment of the present disclosure, the above-described system, apparatus, device, module, unit, etc. can be implemented by computer program modules.

[0161] According to embodiments of the present disclosure, program code of the computer program for performing the methods provided by the embodiments of the present disclosure can be written in any combination of one or more programming languages, and can be implemented in a computer program product. Specifically, the computer program can be implemented in a high-level procedural and / or object-oriented programming language, and / or in assembly / machine language. The programming language includes, but is not limited to, Java, C++, python, “C” language, or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, and partly on a remote computing device, or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider (ISP).

[0162] The computer program product of the present disclosure can be a computer program product, which is a machine-readable medium (or computer readable medium) having stored therein a sequence of instructions readable by a machine (e.g., a computer). The instructions in the machine-readable medium focus on the function of the computer program (e.g., in the form of a computer program product). The instructions can be executed by one or more processors to produce a computer-implemented process, such as the one(s) described herein. The instructions can be stored in a computer memory, which can be a single memory or spread out over multiple memories. The machine-readable medium can be a magnetic or optical disk, a magnetic tape, a semiconductor memory, a computer disk, or any other suitable medium. The machine-readable medium can be loaded into the computer memory, or the computer memory can access the machine-readable medium through a connection, such as a communication network. The machine-readable medium can be a computer readable storage medium.

[0163] Those skilled in the art will understand that features of the various embodiments and / or claims of the present disclosure can be combined and / or sub-combined, even if such combinations or sub-combinations are not expressly noted in the present disclosure. In particular, features of the various embodiments and / or claims of the present disclosure can be combined and / or sub-combined without departing from the spirit and teachings of the present disclosure. All such combinations and / or sub-combinations are within the scope of the present disclosure.

[0164] The above describes embodiments of the present disclosure. However, these embodiments are merely for illustrative purposes, and are not intended to limit the scope of the present disclosure. Although each embodiment is described above separately, this does not mean that the measures in each embodiment cannot be used advantageously in combination. The scope of the present disclosure is defined by the appended claims and their equivalents. Those skilled in the art can make various substitutions and modifications without departing from the scope of the present disclosure, and these substitutions and modifications should all fall within the scope of the present disclosure.

Claims

1. A method for testing a web page of an application, comprising: obtaining a plurality of requests generated by a predetermined user performing a plurality of operations in the web page to obtain a request queue; each request comprising a request message and a return message; identifying parameters in each request from the request message of each request in the request queue to obtain attributes of each request object, wherein the attributes of each request object comprise all parameters in the request message and the return message of the request; generating executable code classes of the each request object based on the attributes of the each request object; obtaining values of the parameters in the attributes of the each request object to obtain test case data, the test case data comprising default values of the parameters in the attributes of the each request object and modified values of the default values; arranging the executable code classes of the each request object according to the order of the requests in the request queue to obtain to-be-executed case code; obtaining a test case class based on the to-be-executed case code and the test case data; and testing the application based on the test case class, comprising: instantiating the executable code classes of the each request object in the to-be-executed case code by using the values of the parameters selected by the user from the test case data each time to generate a test case, the test case comprising request instances of the each request object in the request queue; sending the request instances of the each request object in the test case in turn according to the order of the requests in the request queue, comprising: sending a next request instance after receiving a return message of a previous request instance and the return message conforms to an expectation of the previous request instance; wherein if the return messages of all the request instances in the test case conform to the expectation, it is determined that the test case is tested successfully; and if the return message of any request instance does not conform to the expectation, it is determined that the test case is tested unsuccessfully.

2. The method of claim 1, wherein, The obtaining of the values of the parameters in the attributes of the each request object to obtain the test case data comprises: extracting the values of the parameters in each request from the request message of each request in the request queue to obtain default values of the parameters in the attributes of the each request object; and obtaining modified values of the default values of the parameters in the attributes of the each request object.

3. The method of claim 1, wherein, The testing of the application based on the test case class comprises: reading the values of the parameters in the attributes of the request object selected by the user from the test case data; injecting the values of the parameters in the attributes of the request object selected by the user into the to-be-executed case code to generate a test case; and testing the application by using the test case.

4. The method of claim 3, wherein, The testing of the application based on the test case class further comprises: obtaining execution result information after the execution of the test case; and associating the test case, recording the values of the parameters in the attributes of the request object in the test case and the execution result information.

5. The method of claim 1, wherein, The generating of the executable code classes of the each request object based on the attributes of the each request object comprises: Instantiating a pre-defined executable code template with the parameters in the each request to obtain an executable code class of the each request object.

6. The method of claim 5, wherein: The parameters in the each request include at least one of: input parameters, output parameters, interface protocol types, request modes, interface calling addresses, or encoding formats; The executable code template is provided with keyword identifiers for annotating each parameter; The instantiating a pre-defined executable code template with the parameters in the each request to obtain an executable code class of the each request object includes: Identifying the keyword identifiers in the executable code template; and Filling the parameters in the each request into positions indicated by the keyword identifiers for annotating the parameters.

7. The method of claim 1 or 6, wherein, The identifying the parameters in the each request from the request message of the each request in the request queue includes identifying input parameters from the request message of the each request, specifically including: Extracting input parameters from a uniform resource locator in a request header of the request message; and Extracting input parameters from a request body of the request message.

8. The method of claim 1 or 6, wherein, The identifying the parameters in the each request from the request message of the each request in the request queue includes: Extracting output parameters in a JSON format for data exchange from the return message of the each request.

9. The method of claim 1, wherein, The obtaining a request queue including multiple requests generated by a predetermined user performing multiple operations on a Web page includes: Obtaining request messages and return messages generated by the predetermined user operating the Web page between a specified start signal and a termination signal.

10. A Web page testing apparatus for an application program, comprising a case generation service module and a case execution service module; wherein: The case generation service module comprises a request analysis framework and a case generation framework; wherein: The request analysis framework is configured to: Obtain a request queue including multiple requests generated by a predetermined user performing multiple operations on a Web page, each request including a request message and a return message; Identify parameters in the each request from the request message of the each request in the request queue to obtain attributes of the each request object, wherein the attributes of the each request object include all parameters in the request message and the return message of the request, and Generate an executable code class of the each request object based on the attributes of the each request object; The case generation framework is configured to: Obtain values of the parameters in the attributes of the each request object to obtain test case data, the test case data including default values of the parameters in the attributes of the each request object and modification values of the default values, Arrange the executable code classes of the each request object in an order of the requests in the request queue to obtain to-be-executed case code, and Obtain a test case class based on the to-be-executed case code and the test case data; The case execution service module is configured to test the application program based on the test case class, including: each parameter selected by the user from the test case data is used to instantiate an executable code class of each request object in the to-be-executed case code to generate a test case, the test case including a request instance of each request object in the request queue; sending the request instances of each request object in the test case in the order of the requests in the request queue, including: sending a next request instance after receiving a return message of a previous request instance and the return message conforms to an expectation of the previous request instance; wherein, if the return messages of all the request instances in the test case conform to the expectations, it is determined that the test case is tested successfully, and if the return message of any request instance does not conform to the expectation, it is determined that the test case is tested unsuccessfully. 11.An electronic device, comprising: one or more processors; memory storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any one of claims 1-9. 12.A computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the method of any one of claims 1-9. 13.A computer program product comprising computer program instructions that, when executed by a processor, implement the method of any one of claims 1-9.

Citation Information

Patent Citations

  • Test script development method and device

    CN112988601A