Method for testing web application, apparatus, device, medium, and program product

By using traffic files to intercept and replay network requests from web applications at the testing device, the problems of high testing costs and poor stability in existing technologies are solved, achieving a more efficient testing process.

WO2026016162A1PCT designated stage Publication Date: 2026-01-22BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/106374
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2026-01-22

AI Technical Summary

Technical Problem

Existing web application testing solutions rely on communication via server-side interfaces, resulting in high testing costs and poor stability. Furthermore, testing in different geographical network environments faces resource isolation and access restrictions, making it difficult to reproduce network traffic issues and impacting testing efficiency.

Method used

By obtaining the target request from the webpage at the test device, it is determined whether a traffic file exists. If it exists, it is determined whether the test case has been updated. The target response content is returned using the traffic file to complete the test, reducing the dependence on the server and network, and realizing the interception and replay of network requests.

Benefits of technology

It improves the stability and accuracy of web application testing, reduces reliance on real networks, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024106374_22012026_PF_FP_ABST
    Figure CN2024106374_22012026_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to a method for testing a web application, an apparatus, a device, a medium, and a program product. The method comprises: on the basis of a test case, acquiring a target request sent by a web client of the web application to a server side of the web application. The method further comprises: on the basis of the target request, determining whether a traffic file corresponding to the web application is present. The method further comprises: in response to the presence of the traffic file corresponding to the web application, determining whether the test case has been updated. The method further comprises: in response to the fact that the test case has not been updated, on the basis of the traffic file, returning target return content corresponding to the target request to the web client, so as to complete the testing of the web application. By means of the method, the traffic file is used at a testing device to return the target return content corresponding to the target request, thereby achieving interception of a network request, reducing the dependence on a server or a network during web application testing, improving the stability and accuracy of testing, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, devices, media, and programs for testing web applications. Technical Field

[0001] The embodiments disclosed herein generally relate to the Internet field, and specifically to methods, apparatus, devices, media, and program products for testing web applications. Background Technology

[0002] Currently, the internet is becoming increasingly important in people's daily lives, even becoming a crucial tool they rely on. In today's society, a vast amount of work depends on the internet. From supporting basic necessities like food, clothing, shelter, and transportation, to the widespread dissemination of various cultural and entertainment activities worldwide, and the continuous rise of various industries, all of these rely on the internet. Within internet technology, web applications represent a significant area of ​​development.

[0003] With the rapid development of internet technology, web applications have become an indispensable part of modern life and work. From office to everyday life, web applications are widely used to provide various services. They are increasingly penetrating various fields, greatly enriching users' online experience. At the same time, the functions of web applications are becoming increasingly diversified, such as word processing and image creation, meeting diverse user needs. However, many problems still need to be solved during the testing of web applications.

[0004] Summary of the Invention

[0005] Embodiments of this disclosure provide a method, apparatus, device, medium, and program product for testing web applications.

[0006] According to a first aspect of this disclosure, a method for testing a web application is provided. The method includes obtaining a target request sent from a web application's web client to a web application's server based on test cases. The method further includes determining, based on the target request, whether a traffic file corresponding to the web application exists. The method further includes determining, in response to the existence of a traffic file corresponding to the web application, whether the test cases have been updated. The method further includes, in response to the test cases not being updated, returning target response content corresponding to the target request to the web client based on the traffic file to complete the testing of the web application.

[0007] In a second aspect of this disclosure, an apparatus for testing a web application is provided. The apparatus includes a target request acquisition module configured to acquire, based on test cases, a target request sent from the web client of the web application to the server of the web application; a traffic file existence determination module configured to determine, based on the target request, whether a traffic file corresponding to the web application exists; a test case update determination module configured to determine, in response to the existence of a traffic file corresponding to the web application, whether a test case has been updated; and a target return content return module configured to, in response to the test case not being updated, return target return content corresponding to the target request to the web client based on the traffic file, thereby completing the testing of the web application.

[0008] In a third aspect of this disclosure, an electronic device is provided, including at least one processor; and a storage device for storing at least one program, which, when executed by the at least one processor, causes the at least one processor to implement the method according to the first aspect of this disclosure.

[0009] In a fourth aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method according to a first aspect of this disclosure.

[0010] In a fifth aspect of this disclosure, a computer program product is provided. This computer program product includes a computer program that, when executed by a processor, implements the method according to a first aspect of this disclosure.

[0011] It should be understood that the content described in this section is not intended to limit the key or essential features of the embodiments of this disclosure, nor is it intended to restrict the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0012] The above and other objects, features and advantages of this disclosure will become more apparent from the accompanying drawings, in which like reference numerals generally denote like parts.

[0013] Figure 1 illustrates a schematic diagram of an example environment in which the devices and / or methods of the embodiments of this disclosure may be implemented;

[0014] Figure 2 illustrates a schematic flowchart of an example of testing a web application according to an embodiment of the present disclosure;

[0015] Figure 3 illustrates a schematic diagram of an example method for testing a web application according to an embodiment of the present disclosure;

[0016] Figure 4 illustrates a schematic diagram of an example system architecture for testing web applications according to an embodiment of the present disclosure;

[0017] Figure 5 illustrates a schematic diagram of an example of pseudocode for testing a web application according to an embodiment of the present disclosure;

[0018] Figure 6 illustrates a schematic block diagram of an apparatus for testing web applications according to an embodiment of the present disclosure;

[0019] Figure 7 illustrates a schematic block diagram of an example device suitable for implementing embodiments of the present disclosure.

[0020] In the various figures, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation

[0021] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and provisions. Upon receiving a user's active request, a prompt message is sent to the user to clearly inform the user that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware such as electronic devices, applications, servers or storage media performing the operations of this disclosed technical solution, based on the prompt message.

[0022] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0023] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0024] As mentioned above, there are still many problems to be solved in the process of testing web applications. For example, existing web application testing solutions typically rely on communication with server-side interfaces. In existing continuous integration testing solutions, web applications are generally tested using real online network traffic, which increases costs.

[0025] For the traditional testing methods described above, when testing the web application's web-side code, server-side issues may arise if the corresponding backend code is not masked. Furthermore, network fluctuations and changes to server-side interfaces in the test environment can also lead to test failures, causing continuous integration testing to be aborted and reducing interception accuracy. Additionally, testing in a continuous integration network environment may present interface gaps due to differences from real-world network conditions. Moreover, when the web application and its corresponding server are located in different geographical locations, such as different countries, network barriers between countries can isolate the resources needed for testing and restrict necessary permissions, hindering successful testing. Finally, when problems occur during testing, it's impossible to reproduce the issue using network traffic at the problem location, resulting in low testing efficiency.

[0026] To address at least the aforementioned and other potential problems, embodiments of this disclosure propose a method for testing web applications. In this method, a computing device first obtains a target request sent from the web application's web client to the server, based on test cases. The web client can be any client format compatible with the web application. Next, the computing device determines whether a traffic file corresponding to the web application exists based on the target request. Upon determining the existence of a traffic file, the computing device further determines whether the test cases have been updated. If the test cases have not been updated, the computing device can use the traffic file to return the target response content corresponding to the target request to the web client, thus completing the testing of the web application. This method, by using a traffic file to return the target response content corresponding to the target request at the testing device, achieves network request interception, reduces the dependence on servers or networks during web application testing, improves the stability and accuracy of testing, and enhances the user experience.

[0027] The embodiments of this disclosure will now be described in further detail with reference to the accompanying drawings. Figure 1 illustrates an example environment in which the devices and / or methods of the embodiments of this disclosure can be implemented. In environment 100, at the start of a test, computing device 108 first obtains a target request 106 sent from the web client 102 of a web application to the server 110 of the web application according to test case 104. Then, computing device 108 determines whether a traffic file 112 corresponding to the web application exists based on the target request 106. After determining that a traffic file 112 corresponding to the web application exists, computing device 108 further determines whether test case 104 has been updated. After determining that test case 104 has not been updated, computing device 108 uses traffic file 112 to return target return content 114 corresponding to target request 106 to the web client 102 of the web application to complete the test.

[0028] Examples of computing devices 108 include, but are not limited to, personal computers, server computers, handheld or laptop devices, mobile devices (such as mobile phones, personal digital assistants (PDAs), media players, etc.), multiprocessor systems, consumer electronics, minicomputers, mainframe computers, and distributed computing environments that include any of the above systems or devices.

[0029] As shown in Figure 1, computing device 108 uses test cases 104 to test the web application's web client 102. Test case 104 contains multiple test items, each of which performs one or more operations on the web client 102. Some of these test items cause the web application's web client 102 to send a target request to the web application's server 110 for interaction with the server. In some embodiments, test case 104 can be updated. In one example, test case 104 contains 10 test items. In another example, when test case 104 is updated, the updated test case contains 15 test items.

[0030] When the web application's web client 102 sends a target request to the web application's server 110, the computing device 108 can be used to intercept or obtain the target request 106 sent by the web application's web client 102 to the web application's server 110.

[0031] The computing device 108 can also determine whether a traffic file 112 corresponding to the web page 102 of the web application exists based on the target request 106. For example, when starting to test the web application, the computing device 108 checks to confirm the existence of the traffic file 112 after receiving the target request 106. In one example, the traffic file 112 is of type Hypertext Transfer Protocol archive file.

[0032] In some embodiments, if the computing device 108 does not detect a traffic file 112 corresponding to test case 104, it indicates that test case 104 is being used for the first time. The computing device 108 may create a traffic file for test case 104, which stores both the target request sent from the web client 102 of the web application to the server 110 of the web application caused by test case 104, and the target response content returned from the server in response to the target request.

[0033] In some embodiments, if the computing device 108 detects a traffic file 112 corresponding to the web application's web client 102, it indicates that test case 104 has been previously executed. At this point, it is necessary to further determine whether test case 104 has been updated. If the test case has not been updated, the target request sent from the web application's web client 102 to the web application's server 110 can be compared with reference requests stored in the traffic file 112 to determine if a corresponding reference request exists. If a reference request matching the target request exists, the return content for the reference request in the traffic file is provided to the web application's web client 102. This operation eliminates the need to retrieve the return content from the web application's server 110 over the network, thus avoiding the impact of server-side network performance or device issues on the web client testing.

[0034] In some embodiments, when matching target requests, a whitelist of interfaces can be set. The computing device does not intercept requests on the whitelisted interfaces. In some embodiments, for some interfaces, when matching requests corresponding to those interfaces, only some fields may be matched, rather than all fields. The above examples are for describing this disclosure only and are not intended to limit the scope of this disclosure.

[0035] In some embodiments, if an update is detected in a test case, the information stored in the traffic file needs to be cleared. Requests involving the server in the test cases are then sent to the server normally. The requests sent to the server and the responses received from the server are then rewritten to the traffic file. After all test items have been tested, the testing of the web application is complete.

[0036] This method enables the interception and replay of network requests by associating and saving the target request and the target response content in the traffic file at the test device. It also supports users in setting custom matching rules during testing, thus improving the user experience.

[0037] The above description, with reference to FIG1, illustrates an example environment in which the devices and / or methods of the embodiments of the present disclosure may be implemented. The following description, with reference to FIG2, illustrates a flowchart illustrating an example of testing a web application according to an embodiment of the present disclosure. The computing device 108 in FIG1 can be used as a testing device.

[0038] As shown in Figure 2, in Example 200, at box 202, the computing device begins to execute the test. It can be understood that the computing device can test all test items in the test case, or it can test only a portion of the test items in the test case.

[0039] At box 204, the computing device determines whether a traffic file corresponding to the web application exists. If no traffic file is found, it creates the file at box 214. For example, a traffic file can be created to store all target requests and their corresponding response content.

[0040] In addition to creating the traffic file, at box 216, the computing device also sends the target request to the web application's server to obtain the response content from the server. After obtaining the response content from the server, the computing device can store the target request and the corresponding target response content in the traffic file. In one example, the traffic file is stored at the computing device's location. In another example, the traffic file is stored on a remote server.

[0041] After the computing device determines that a traffic file exists, at box 206, the computing device further determines whether the test case is in update mode, i.e., whether the test case has been updated. When the computing device determines that the test case has been updated, it sends an actual request to the server at box 216 and saves the response to the traffic file. In this process, the computing device directly sends the target request to the server and simultaneously stores the target response content associated with the target request in the traffic file. Additionally, when the computing device determines that the test case has been updated, it removes all information from the traffic file. Then, the computing device stores the target request and the target response content associated with the target request in the traffic file.

[0042] At box 208, the computing device uses a traffic file to match requests. After determining that the test cases have not been updated, the computing device uses the traffic file to match the target request. In one example, the computing device matches the target request against requests stored in the traffic file.

[0043] At box 210, the computing device determines whether the match is successful. A match is successful when a reference request matching the target request exists in the traffic file. Next, the computing device returns the request using the saved traffic data at box 212. During this process, the computing device retrieves the response content corresponding to the reference request. Then, the computing device returns the response content corresponding to the reference request as the target response content to the web page, thus completing the test.

[0044] When no matching reference request exists in the traffic file, the actual request is issued at box 218. In this case, the computing device directly sends the target request to the server, and then receives the target response content corresponding to the target request. Additionally, the computing device may associate the target request with the target response content in the traffic file.

[0045] This method enables the interception and replay of network requests by associating and saving the target request and the target response content in the traffic file at the test device, thereby improving the user experience.

[0046] The above description, with reference to FIG2, is a schematic flowchart illustrating an example of testing a web application according to an embodiment of the present disclosure. The following description, with reference to FIG3, is a schematic diagram of an example method for testing a web application according to an embodiment of the present disclosure. The process shown in FIG3 can be performed on the computing device 108 shown in FIG1 or any other suitable computing device.

[0047] As shown in Figure 3, in Example 300, at box 302, the computing device obtains the target request sent from the web application's web client to the web application's server based on test cases. To test the web application's web client, corresponding test cases need to be designed to examine the web client's functionality and operations.

[0048] In some embodiments, multiple test cases can be set for the web page of a web application. Each test case has a different purpose or function, and is used to test different functions of the web application. For example, a test case for measuring the comment submission function may include multiple test steps: opening the page, clicking the comment button, adding text to the comment box, and clicking the comment submit button. Clicking the comment submit button will trigger the web page to send a target request to the server to submit the comment. However, the test operations such as opening the page, clicking the comment button, and adding text to the comment box are operations performed on the test device or on the web page, and do not require sending requests to the server.

[0049] Subsequently, at box 304, the computing device determines, based on the target request, whether a traffic file corresponding to the web application exists. For example, the computing device may perform a check to determine if a traffic file exists. In some embodiments, the computing device can detect the existence of a traffic file corresponding to a test case based on the identifier of the test case. For example, when storing the traffic file for a test case, the identifier of the corresponding test case is also stored. The computing device matches the identifier of the test case with the identifier of the test case corresponding to the stored traffic file to find the corresponding traffic file.

[0050] In some embodiments, when the computing device does not detect a traffic file, it directly creates a new traffic file for web application testing. Simultaneously, the computing device sends the target request to the server and receives the response content from the server. At this point, the computing device stores the request and the corresponding response content into the traffic file.

[0051] Next, at box 306, the computing device, in response to the existence of a traffic file corresponding to the web application, determines whether the test case has been updated. For example, when the testing device detects the existence of a traffic file, it needs to further determine whether the test case has been updated. If the test case has not been updated, the previous traffic file can still be used. If the test case has been updated, the traffic file for that test case needs to be rewritten.

[0052] In some embodiments, after a user updates a test case, the computing device can obtain indication information that the test case has been updated. For example, this can be indicated by a flag for the test case. If it is determined that the test case has been updated, the content in the traffic file will no longer be available. Next, the computing device will delete the content in the traffic file, and simultaneously send the target request to the server, storing the target request and the target response content returned from the server in association in the traffic file.

[0053] Finally, at box 308, in response to the test cases not being updated, the computing device returns the target response content corresponding to the target request to the web page based on the traffic file, thus completing the web application test. When it is determined that the test cases have not been updated, the computing device can use the traffic file to determine the target response content that can be returned to the web page.

[0054] In some embodiments, the computing device matches the target request with reference requests in the traffic file. If a match is found, the computing device determines the response content corresponding to the reference request as the target response content that can be used for the target request. The determined target response content is then provided to the web page. If no matching reference request is found, the computing device can send a request to the server to obtain the corresponding target response content. Additionally, the request and the corresponding target response content can be stored in the traffic file.

[0055] In some embodiments, the computing device may pre-configure a whitelist of interfaces as a first interface list, and access requests to interfaces in the first interface list will not be intercepted. In this case, when matching the target request with reference requests in the traffic file, the computing device may also determine whether the target request is for an interface in the pre-configured first interface list. If the target request is for an interface in the first interface list, the target request is directly sent to the server to obtain the target return content, without matching the target request with reference requests in the traffic file. If the target request is not for an interface in the first interface list, the target request is matched with reference requests in the traffic file. If a match is found, the computing device determines the return content corresponding to the reference request as the target return content that can be used for the target request. Then, the determined target return content is provided to the web page. If no matching reference request is found, the computing device may send a request to the server to obtain the corresponding target return content. Additionally, the request and the corresponding target return content at this time may also be stored in the traffic file.

[0056] In some embodiments, a second interface list can be set as needed. For requests targeting interfaces in the second interface list, only some key fields or parameters need to be matched during request matching. For example, during testing, the operation request may involve time information. If the time information is not important for some interfaces, it can be set so that time parameters or fields are not matched during request matching. In this case, when matching the target request with the reference request in the traffic file, the computing device can also determine whether the target request is for an interface in the second interface list; if the target request is for an interface in the second interface list, some fields of the target request are matched with some fields of the reference request. If the target request is not for an interface in the second interface list, all fields of the target request are matched with all fields of the reference request. If a match is found, the computing device determines the return content corresponding to the reference request as the target return content that can be used for the target request. Then, the determined target return content is provided to the web page. If no matching reference request is found, the computing device can send a request to the server to obtain the corresponding target return content. In some embodiments, the test is terminated when all operations in the test case are completed.

[0057] This method, by associating and saving the target request and target response content in the traffic file at the test device, enables the interception and replay of network requests. This reduces the reliance of web application testing on real traffic, improves the stability and accuracy of testing, and enhances the user experience.

[0058] The above description, with reference to FIG3, illustrates an example method for testing web applications according to an embodiment of the present disclosure. The following description, with reference to FIG4, illustrates an example system architecture for testing web applications according to an embodiment of the present disclosure.

[0059] As shown in Figure 4, in Example 400, the system architecture consists of an infrastructure layer, an application layer, and a user layer. It is understood that users can choose other types of system architectures that can implement the technical solutions in this application, based on their own needs; this application does not impose any restrictions.

[0060] At the infrastructure layer, the test equipment provides a service module 428 for testing, which includes a network service module 430, a traffic matching service module 432, and a storage service module 434. It is understood that users can add other types of services according to their own needs, and this application does not impose any restrictions.

[0061] Network services are used to provide communication between web pages and servers, as well as communication between test devices and the server. In one example, these network services can all be remote network services. In another example, these network services can all be short-range network services, such as local area network (LAN) services.

[0062] The traffic matching service is used to match target requests with reference requests in the traffic file. In one example, this matching service is based on the identifiers in the target and reference requests.

[0063] In some embodiments, the storage service is used to store related information in the traffic file. For example, the storage service is used to store associated target requests and target response content in the traffic file.

[0064] At the application layer, there are network module 408, storage (local / remote) module 414 and traffic matching module 422. The network module also includes traffic interception module 410 and traffic replay module 412; the storage (local / remote) module also includes writing module 416, creation module 418 and deletion module 420; the traffic matching module also includes custom matching module 424 and interface whitelist module 426.

[0065] When the traffic interception module determines that there is a reference request in the traffic file that matches the target request, it intercepts the target request at the test device and then returns the return content corresponding to the reference request as the target return content to the web page, thereby completing the test.

[0066] The traffic replay module executes the traffic replay function to reproduce the specific traffic situation during the test when the test fails or is terminated for any reason, so as to facilitate users in analyzing the reasons for the failure or termination of the test. The writing module writes and stores the target request and the corresponding target response content in the traffic file after it is created.

[0067] Once the test device determines that the test case has been updated, the deletion module removes the information already written to the traffic file in order to rewrite the target request and target return content corresponding to the new test case.

[0068] The custom matching module allows users to tailor the matching rules of traffic files to their specific needs. For example, a user can specify that one request does not need to match the platform field, and another request does not need to match the time field. Additionally, the traffic file also includes built-in default matching rules, allowing access requests to local services in test cases to proceed directly without prior matching.

[0069] The API whitelist module allows users to whitelist certain APIs according to their needs. For example, access requests from whitelisted APIs will not be intercepted on the test device; instead, the requests will be sent directly to the server for direct communication.

[0070] At the user level, including using network module 402, users can record the entire testing process for traffic replay analysis and to determine potential problems during the test. Specifically, in box 404, "const network = useNetwork(), Start Recording" indicates that recording begins at the start of the test. In box 406, "network.stop() End Recording and Generate File" indicates that recording ends upon completion of the test, and the recorded test process is generated into a corresponding file and saved.

[0071] The above diagram, with reference to Figure 4, illustrates an example of a system architecture for testing web applications according to embodiments of the present disclosure. The following diagram, with reference to Figure 5, illustrates an example of pseudocode for testing web applications according to embodiments of the present disclosure.

[0072] As shown in Example 500 in Figure 5, box 502 is an example of pseudocode. For example, the comment " / / Set up request access to the real server" indicates that a request can be sent to the server so that the target request access can be sent to the server via the test device.

[0073] For example, the comment " / / Ignore specified query keys when matching requests" means that specific pre-defined information can be ignored during matching. For instance, certain fields in the request can be ignored during matching. In one example, the platform field in the request is ignored during matching. In another example, the time field in the request is ignored during matching.

[0074] The comment " / / When silent by default, mismatched requests will be output during debugging" means that under the default matching rules, the request can be output directly when debugging passes. For example, when the test device receives an access request from a local service, it will execute the access request directly.

[0075] The pseudocode used in the test execution, `const network = await useNetwork('spender-search');`, indicates that the `useNetwork` module is invoked to query whether the file 'spender-search' exists. If it doesn't exist, the file is created before the call is made. For example, when the computing device detects that the traffic file does not currently exist, a task to create the file is executed.

[0076] The above description, with reference to FIG. 5, illustrates an example of pseudocode for testing web applications according to an embodiment of the present disclosure. The following description, with reference to FIG. 6, illustrates a schematic block diagram of an apparatus for testing web applications according to an embodiment of the present disclosure.

[0077] As shown in Figure 6, the device 600 includes a target request acquisition module 610, configured to acquire a target request sent from the web application's web client to its server based on test cases; a traffic file existence determination module 620, configured to determine whether a traffic file corresponding to the web application exists based on the target request; a test case update determination module 630, configured to determine whether the test case has been updated in response to the existence of a traffic file corresponding to the web application; and a target return content return module 640, configured to return the target return content corresponding to the target request to the web client based on the traffic file in response to the test case not being updated, thereby completing the testing of the web application.

[0078] In some embodiments, the target return content return module 640 includes: a matching module configured to match a target request with a reference request in a traffic file; a return content determination module configured to determine the return content corresponding to the reference request in response to the existence of a reference request in the traffic file that matches the target request; and a return module configured to provide the return content as the target return content to the web page.

[0079] In some embodiments, the target return content return module 640 further includes: a target request sending module configured to send a target request to the server in response to the absence of a reference request matching the target request in the traffic file; a target return content receiving module configured to receive target return content corresponding to the target request; and a storage module configured to store the target return content in association with the target request in the traffic file.

[0080] In some embodiments, the matching module includes: a first request determination module configured to determine whether a target request is for an interface in a pre-configured first interface list, wherein the interfaces in the first interface list are allowed interfaces; and a first request matching module configured to match the target request with a reference request in a traffic file in response to the target request not being for an interface in the first interface list.

[0081] In some embodiments, the apparatus 600 further includes: a first request sending module configured to send a target request to a server in response to the target request being for an interface in a first interface list; and a first content receiving module configured to receive target return content corresponding to the target request.

[0082] In some embodiments, the matching module includes: a second request determination module configured to determine whether a target request is for an interface in a second interface list; and a second request matching module configured to match some fields of the target request with some fields of a reference request in response to the target request being for an interface in the second interface list.

[0083] In some embodiments, the matching module further includes: a second request matching module, configured to match all fields of the target request with all fields of the reference request in response to a target request not being for an interface in the second interface list. In some embodiments, the apparatus 600 further includes: a traffic file creation module, configured to create a traffic file in response to the absence of a traffic file corresponding to the web application; a target return content acquisition module, configured to acquire target return content corresponding to the target request by sending a target request to the server; and a storage module, configured to store the target return content in association with the target request in the traffic file.

[0084] In some embodiments, the apparatus 600 further includes: a removal module configured to remove information from a traffic file in response to an update of a test case; a target request sending module configured to send a target request to a server; a target return content receiving module configured to receive target return content corresponding to the target request; and a storage module configured to store the target return content in the traffic file in association with the target request.

[0085] In some embodiments, the traffic file is a Hypertext Transfer Protocol archive file.

[0086] In some embodiments, the apparatus 600 further includes an access request execution module configured to execute an access request in response to receiving an access request related to a web page for accessing a local service.

[0087] Figure 7 shows a schematic block diagram of an example device 700 that can be used to implement embodiments of the present disclosure. The computing device 108 in Figure 1 can be implemented using device 700. As shown, device 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to computer program instructions stored in read-only memory (ROM) 702 or loaded from storage unit 708 into random access memory (RAM) 703. Various programs and data required for the operation of device 700 may also be stored in RAM 703. CPU 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.

[0088] Multiple components in device 700 are connected to I / O interface 705, including: input unit 706, such as keyboard, mouse, etc.; output unit 707, such as various types of monitors, speakers, etc.; storage page 708, such as disk, optical disk, etc.; and communication unit 709, such as network card, modem, wireless transceiver, etc. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0089] The various processes and handling described above, such as method 300, can be executed by processing unit 701. For example, in some embodiments, method 300 can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by CPU 701, one or more actions of method 300 described above can be performed.

[0090] This disclosure can be a method, apparatus, system, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.

[0091] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0092] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0093] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone 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 via 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., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions to implement various aspects of this disclosure.

[0094] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0095] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0096] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0098] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technical improvements to the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for testing a web application, comprising: obtaining, based on a test case, a target request sent by a web side of the web application to a server side of the web application; determining, based on the target request, whether a traffic file corresponding to the web application exists; in response to the traffic file corresponding to the web application existing, determining whether the test case is updated; and in response to the test case not being updated, returning, based on the traffic file, target return content corresponding to the target request to the web side to complete testing of the web application. 2.The method of claim 1, wherein returning, based on the traffic file, target return content corresponding to the target request to the web side comprises: matching the target request with a reference request in the traffic file; in response to the reference request matching the target request existing in the traffic file, determining return content corresponding to the reference request; and providing the return content as the target return content to the web side. 3.The method of claim 2, wherein returning, based on the traffic file, target return content corresponding to the target request to the web side further comprises: in response to the reference request matching the target request not existing in the traffic file, sending the target request to the server side; receiving the target return content corresponding to the target request; and storing the target return content in the traffic file in association with the target request. 4.The method of claim 3, wherein matching the target request with a reference request in the traffic file comprises: determining whether the target request is for an interface in a first preconfigured interface list, wherein the interface in the first interface list is an allowed access interface; and in response to the target request not being for the interface in the first interface list, matching the target request with a reference request in the traffic file. 5.The method of claim 4, further comprising: in response to the target request being for the interface in the first interface list, sending the target request to the server side; and receiving the target return content corresponding to the target request. 6.The method of claim 3, wherein matching the target request with a reference request in the traffic file comprises: determining whether the target request is for an interface in a second interface list; and in response to the target request being for the interface in the second interface list, matching part fields of the target request with part fields of the reference request. 7.The method of claim 6, wherein matching the target request with a reference request in the traffic file further comprises: in response to the target request not being for the interface in the second interface list, matching all fields of the target request with all fields of the reference request. 8.The method of claim 1, further comprising: ​ ​ ​ ​ ​ ​ In response to the absence of the traffic file corresponding to the web application, creating the traffic file; obtaining the target return content corresponding to the target request by sending the target request to the server side; and storing the target return content in the traffic file in association with the target request.

9. The method of claim 1, further comprising: in response to the test case being updated, removing information in the traffic file; sending the target request to the server side; receiving the target return content corresponding to the target request; and storing the target return content in the traffic file in association with the target request.

10. The method of claim 1, further comprising: the traffic file is a hypertext transfer protocol archive file.

11. The method of claim 1, further comprising: in response to obtaining an access request for accessing a local service related to the web side, executing the access request.

12. An apparatus for testing a web application, comprising: a target request obtaining module configured to obtain a target request sent by a web side of the web application to a server side of the web application based on a test case; a traffic file existence determining module configured to determine whether a traffic file corresponding to the web application exists based on the target request; a test case update determining module configured to determine whether the test case is updated in response to the existence of the traffic file corresponding to the web application; and a target return content returning module configured to return, in response to the test case not being updated, target return content corresponding to the target request to the web side based on the traffic file to complete the test of the web application.

13. An electronic device, comprising: at least one processor; and a storage device for storing at least one program, when the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1-11.

14. A computer readable storage medium having stored thereon a computer program, the computer program, when executed by a processor, implements the method according to any one of claims 1-11.

15. A computer program product comprising a computer program, the computer program, when executed by a processor, implements the method according to any one of claims 1-11. ​ ​

Citation Information

Patent Citations

  • Business service testing method and device, electronic equipment and storage medium

    CN113590497A

  • Test data noise reduction method and device, storage medium and computer equipment

    CN117234949A

  • Page test case determination method, page test case testing method, page test case determination device, page test case testing device, medium and equipment

    CN117667710A

  • Method and apparatus for security testing of application flows that cannot be automated through HTTP replay

    US20180137286A1