WO2026016162A1 - 用于测试网页应用的方法、装置、设备、介质和程序产品 - Google Patents

用于测试网页应用的方法、装置、设备、介质和程序产品

Info

Publication number
WO2026016162A1
WO2026016162A1 PCT/CN2024/106374 CN2024106374W WO2026016162A1 WO 2026016162 A1 WO2026016162 A1 WO 2026016162A1 CN 2024106374 W CN2024106374 W CN 2024106374W WO 2026016162 A1 WO2026016162 A1 WO 2026016162A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
request
target request
traffic file
web application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/CN2024/106374
Other languages
English (en)
French (fr)
Inventor
贺云风
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to PCT/CN2024/106374 priority Critical patent/WO2026016162A1/zh
Priority to US19/273,497 priority patent/US20260023680A1/en
Publication of WO2026016162A1 publication Critical patent/WO2026016162A1/zh
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Definitions

  • the embodiments disclosed herein generally relate to the Internet field, and specifically to methods, apparatus, devices, media, and program products for testing web applications.
  • 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.
  • Embodiments of this disclosure provide a method, apparatus, device, medium, and program product for testing web applications.
  • a method for testing a web application 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 returning a target response corresponding to the target request to the web client based on the traffic file, in response to the test cases not being updated. Return to the content to complete the testing of the web application.
  • an apparatus for testing a web application 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.
  • an electronic device 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.
  • a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the method according to a first aspect of this disclosure.
  • a computer program product includes a computer program that, when executed by a processor, implements the method according to a first aspect of this disclosure.
  • 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
  • Figure 2 illustrates a schematic flowchart of an example of testing a web application according to an embodiment of the present disclosure
  • Figure 3 illustrates a schematic diagram of an example method for testing a web application according to an embodiment of the present disclosure
  • Figure 4 illustrates a schematic diagram of an example system architecture for testing web applications according to an embodiment of the present disclosure
  • Figure 5 illustrates a schematic diagram of an example of pseudocode for testing a web application according to an embodiment of the present disclosure
  • Figure 6 illustrates a schematic block diagram of an apparatus for testing web applications according to an embodiment of the present disclosure
  • Figure 7 illustrates a schematic block diagram of an example device suitable for implementing embodiments of the present disclosure.
  • 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.
  • 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.
  • the computing device determines whether a traffic file corresponding to the web application exists based on the target request.
  • the computing device further determines whether the test cases have 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.
  • the testing device uses the traffic file to return the content corresponding to the target request.
  • the target returned content intercepts network requests, reducing the reliance on servers or networks during web application testing, improving test stability and accuracy, and enhancing user experience.
  • FIG. 1 illustrates an example environment in which the devices and/or methods of the embodiments of this disclosure can be implemented.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the computing device 108 can also determine whether the 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 process the web application... During testing, computing device 108 checks for the existence of traffic file 112 after receiving target request 106.
  • traffic file 112 is a Hypertext Transfer Protocol archive file.
  • 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.
  • 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.
  • a whitelist of interfaces can be set.
  • the computing device does not intercept requests on the whitelisted interfaces.
  • for some interfaces when matching requests corresponding to those interfaces, only some fields may be matched, rather than all fields.
  • 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.
  • This method by streaming the target request and target response content at the test device, allows for seamless data exchange.
  • the system associates and saves data in the file, thereby enabling the interception and replay of network requests. It also supports users in setting custom matching rules during testing, improving the user experience.
  • 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.
  • 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.
  • 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.
  • the computing device 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.
  • the traffic file is stored at the computing device's location. In another example, the traffic file is stored on a remote server.
  • the computing device 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.
  • 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.
  • the computing device determines whether a match is successful. This occurs when a match exists in the traffic file. When a reference request matches the target request, the match is successful. Next, the computing device further returns the request using the saved traffic at box 212. During this process, the computing device obtains the return content corresponding to the reference request. Then, the computing device returns the return content corresponding to the reference request as the target return content to the web page, thus completing the test.
  • the computing device When no matching reference request exists in the traffic file, the actual request is issued at box 218.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the computing device determines, based on the target request, whether a traffic file corresponding to the web application exists. For example, the computing device could perform an inspection to determine if such a file exists. Traffic files.
  • 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 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.
  • the computing device 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.
  • 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.
  • 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.
  • the computing device 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.
  • the computing device can use the traffic file to determine the target response content that can be returned to the web page.
  • the computing device matches the target request with a reference request 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 can send a request to the server to obtain the corresponding target return content. Additionally, the request at this time can also be... The corresponding target return content is stored in the traffic file.
  • 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.
  • 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.
  • 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.
  • 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.
  • This method by streaming the target request and target response content at the test device, allows for seamless data exchange.
  • network requests can be intercepted and replayed, thereby reducing the reliance of web application testing on real traffic, improving the stability and accuracy of testing, and enhancing the user experience.
  • FIG3 illustrates an example method for testing web applications according to an embodiment of the present disclosure.
  • FIG4 illustrates an example system architecture for testing web applications according to an embodiment of the present disclosure.
  • 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.
  • 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.
  • Network services are used to provide communication between web pages and servers, as well as communication between test devices and the server.
  • these network services can all be remote network services.
  • these network services can all be short-range network services, such as local area network (LAN) services.
  • LAN local area network
  • the traffic matching service is used to match target requests with reference requests in the traffic file.
  • this matching service is based on the identifiers in the target and reference requests.
  • the storage service is used to store related information in the traffic file.
  • the storage service is used to store associated target requests and target response content in the traffic file.
  • 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.
  • the traffic interception module determines that a reference matching the target request exists in the traffic file.
  • the target request is intercepted on the test device, and then the response content corresponding to the reference request is returned to the web page as the target response content, thus completing the test.
  • 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.
  • 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.
  • 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.
  • 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.
  • box 502 is an example of pseudocode.
  • 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.
  • 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.
  • ⁇ 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.
  • FIG. 5 illustrates an example of pseudocode for testing web applications according to an embodiment of the present disclosure.
  • FIG. 6 illustrates a schematic block diagram of an apparatus for testing web applications according to an embodiment of the present disclosure.
  • 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.
  • 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
  • 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 matching the target request in the traffic file; and a return module configured to return...
  • the returned content is provided to the webpage as the target content.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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; and a target request sending module configured to...
  • the system is configured to send the target request to the server; the target return content receiving module is configured to receive the target return content corresponding to the target request; and the storage module is configured to store the target return content in a traffic file in association with the target request.
  • the traffic file is a Hypertext Transfer Protocol archive file.
  • 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.
  • FIG 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.
  • 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.
  • ROM read-only memory
  • RAM random access memory
  • 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.
  • I/O interface 705 is also connected to bus 704.
  • I/O interface 705 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.
  • 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.
  • 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.
  • method 300 can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708.
  • part or all of the computer program can be loaded and/or installed on device 700 via ROM 702 and/or communication unit 709.
  • 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.
  • This disclosure can be a method, apparatus, system, and/or computer program product.
  • the product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.
  • 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.
  • 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.
  • RAM random access memory
  • ROM read-only memory
  • EPROM or flash memory erasable programmable read-only memory
  • SRAM static random access memory
  • CD-ROM compact disc read-only memory
  • DVD digital multifunction disc
  • 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.
  • 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.
  • 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, status 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 be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, or partially on the user's computer. The upper part executes on a remote computer, or entirely on a remote computer or server.
  • the remote computer can 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 can be connected to an external computer (e.g., via the Internet using an Internet service provider).
  • electronic circuitry such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from computer-readable program instructions. This electronic circuitry can execute computer-readable program instructions to implement various aspects of this disclosure.
  • 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.
  • 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.
  • 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.
  • each block in the flowchart or block diagram may represent a module, program segment, or instruction.
  • a portion of the module, program segment, or instruction contains one or more executable instructions for implementing the specified logical function.
  • the functions marked in the blocks may occur in a different order than those shown in the figures. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and combinations of blocks in the block diagram and/or flowchart can 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.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本公开的实施例涉及用于测试网页应用的方法、装置、设备、介质和程序产品。该方法包括基于测试用例,获取由网页应用的网页端向网页应用的服务器端发送的目标请求。该方法还包括基于目标请求,确定是否存在与网页应用对应的流量文件。该方法还包括响应于存在与网页应用对应的流量文件,确定测试用例是否被更新。该方法还包括响应于测试用例未被更新,基于流量文件向网页端返回与目标请求对应的目标返回内容,以完成网页应用的测试。通过该方法,由于在测试设备处利用流量文件来返回与目标请求对应的目标返回内容,实现了对网络请求的拦截,减少了网页应用测试时对服务器或网络的依赖,提高了测试的稳定性和准确率,改进了用户体验。

Description

用于测试网页应用的方法、装置、设备、介质和程序产品 技术领域
本公开的实施例总体涉及互联网领域,具体涉及用于测试网页应用的方法、装置、设备、介质和程序产品。
背景技术
目前,互联网在人们的日常生活中越来越重要,甚至成为了人们依赖的重要工具。当今社会,大量的工作都离不开互联网的支持。从对基本的衣食住行的支撑,到在全世界广泛传播各类文化娱乐,再到现如今的各行各业的不断兴起,这些都离不开互联网的支持。在互联网技术中,网页应用为一个重要的方向。
随着互联网技术的飞速发展,网页应用已成为现代生活与工作中不可或缺的一部分。从办公到生活的各种场景中,网页应用都被广泛使用以提供各种服务。网页应用现在正不断渗透到各个领域,极大地丰富了用户的在线体验。与此同时,网页应用的功能也日益多样化,如文字处理、图片创作等,满足了用户多样化的需求。然而,在测试网页应用的过程中还存在许多需要解决的问题。
发明内容
本公开的实施例提供了一种用于测试网页应用的方法、装置、设备、介质和程序产品。
根据本公开的第一方面,提供了一种用于测试网页应用的方法。该方法包括基于测试用例,获取由网页应用的网页端向网页应用的服务器端发送的目标请求。该方法还包括基于目标请求,确定是否存在与网页应用对应的流量文件。该方法还包括响应于存在与网页应用对应的流量文件,确定测试用例是否被更新。该方法还包括响应于测试用例未被更新,基于流量文件向网页端返回与目标请求对应的目标返 回内容,以完成网页应用的测试。
在本公开的第二方面中,提供了一种用于测试网页应用的装置。该装置包括目标请求获取模块,被配置为基于测试用例,获取由网页应用的网页端向网页应用的服务器端发送的目标请求;流量文件存在判定模块,被配置为基于目标请求,确定是否存在与网页应用对应的流量文件;测试用例更新判定模块,被配置为响应于存在与网页应用对应的流量文件,确定测试用例是否被更新;以及目标返回内容返回模块,被配置为响应于测试用例未被更新,基于流量文件向网页端返回与目标请求对应的目标返回内容,以完成网页应用的测试。
在本公开的第三方面中,提供了一种电子设备,包括至少一个处理器;以及存储装置,用于存储至少一个程序,当至少一个程序被至少一个处理器执行,使得至少一个处理器实现根据本公开的第一方面的方法。
在本公开的第四方面中,提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现根据本公开的第一方面的方法。
在本公开的第五方面中,提供了一种计算机程序产品。该计算机程序产品包括计算机程序,该计算机程序在被处理器执行时实现根据本公开的第一方面的方法。
应当理解,该内容部分中所描述的内容并非旨在限定本公开的实施例的关键或重要特征,亦非用于限制本公开的范围。本公开的其它特征将通过以下的描述变得容易理解。
附图说明
通过结合附图对本公开示例性实施例进行更详细的描述,本公开的上述以及其它目的、特征和优势将变得更加明显,其中,在本公开示例性实施例中,相同的参考标号通常代表相同部件。
图1图示了本公开的实施例的设备和/或方法可以在其中被实施的示例环境的示意图;
图2图示了根据本公开的实施例的用于测试网页应用的示例的流程图的示意图;
图3图示了根据本公开的实施例的用于测试网页应用的示例方法的示意图;
图4图示了根据本公开的实施例的用于测试网页应用的系统架构的示例的示意图;
图5图示了根据本公开的实施例的用于测试网页应用的伪代码的示例的示意图;
图6图示了根据本公开实施例的用于测试网页应用的装置的示意性框图;
图7图示了适于用来实施本公开内容的实施例的示例设备的示意性框图。
在各个附图中,相同或对应的标号表示相同或对应的部分。
具体实施方式
可以理解的是,本技术方案所涉及的数据(包括但不限于数据本身、数据的获取或使用)应当遵循相应法律法规及相关规定的要求。在响应于接收到用户的主动请求时,向用户发送提示信息,以明确地提示用户,其请求执行的操作将需要获取和使用到用户的个人信息。从而,使得用户可以根据提示信息来自主地选择是否向执行本公开技术方案的操作的电子设备、应用程序、服务器或存储介质等软件或硬件提供个人信息。
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。
在本公开的实施例的描述中,术语“包括”及其类似用语应当理 解为开放性包含,即“包括但不限于”。术语“基于”应当理解为“至少部分地基于”。术语“一个实施例”或“该实施例”应当理解为“至少一个实施例”。术语“第一”、“第二”等等可以指代不同的或相同的对象。下文还可能包括其他明确的和隐含的定义。
如上所述,在测试网页应用的过程中还存在许多需要解决的问题。例如,现有的网页应用测试的方案中,通常依赖与服务器端接口的通信。在现有的持续集成的测试方案中,经测试的网页应用一般会使用真实的线上网络流量进行测试,这会导致成本增加。
对于上述传统的测试方案,在对网页应用的网页端的代码进行测试时,当未对与网页端对应的后端代码进行屏蔽时,可能会受到服务器端的影响。同时,由于测试环境下的网络的波动以及相关服务器端接口的变更,也会导致测试失败,从而导致持续集成的测试被中止,也会降低相应的拦截准确率。另外,在持续集成的网络环境中进行测试时,由于持续集成的网络环境和真实的网络环境有所不同,可能还会存在接口缺失的问题。此外,当需要测试的网页应用和与其对应的服务端位于不同的地理位置时,例如,位于不同的国家,由于不同国家之间存在的网络壁垒,会导致测试需要使用的资源被隔离,测试所需要的权限也会受到相应的限制,导致测试无法顺利进行。另外,当测试过程中出现问题时,无法利用问题现场的网络流量复现出现的问题,导致测试效率低下。
至少为了解决上述和其他潜在问题,本公开的实施例提出了一种用于测试网页应用的方法。在该方法中,计算设备可以先根据测试用例,来获取由网页应用的网页端向服务器端发送的目标请求。其中,网页端为任意兼容该网页应用的客户端形式。接下来,计算设备可以基于目标请求,来确定是否存在与网页应用对应的流量文件。计算设备在确定存在流量文件时,还需要进一步判断测试用例是否被更新。计算设备在判断测试用例未被更新后,可以利用流量文件来返回与目标请求对应的目标返回内容至网页端处,来完成针对网页应用的测试。通过该方法,由于在测试设备处利用流量文件来返回与目标请求对应 的目标返回内容,实现了对网络请求的拦截,减少了网页应用测试时对服务器或网络的依赖,提高了测试的稳定性和准确率,改进了用户体验。
下面将进一步结合附图来详细描述本公开的实施例。其中图1示出了本公开的实施例的设备和/或方法可以在其中被实施的示例环境。在环境100中,计算设备108可以在测试开始时,首先根据测试用例104来获取由网页应用的网页端102向网页应用的服务器端110发送的目标请求106。然后计算设备108根据目标请求106来判断是否存在与网页应用对应的流量文件112。接着计算设备108在确定存在与网页应用对应的流量文件112后,还需要进一步确定测试用例104是否被更新。在确定测试用例104未被更新后,计算设备108利用流量文件112向网页应用的网页端102返回与目标请求106对应的目标返回内容114,以完成测试。
计算设备108的示例包括但不限于个人计算机、服务器计算机、手持或膝上型设备、移动设备(诸如移动电话、个人数字助理(PDA)、媒体播放器等)、多处理器系统、消费电子产品、小型计算机、大型计算机、包括上述系统或设备中的任意一个的分布式计算环境等。
如图1所示,计算设备108利用测试用例104来测试网页应用的网页端102。其中,测试用例104包含多个测试项,每一个测试项是用于在网页端102上执行一个或多个操作。其中有的测试项会引起网页应用的网页端102向网页应用的服务器端110发送用于与服务器端交互的目标请求。在一些实施例中,测试用例104可以被更新。在一个示例中,测试用例104中包含10个测试项。在另一个示例中,当测试用例104被更新后,更新后的测试用例包含15个测试项。
在网页应用的网页端102向网页应用的服务器端110发送目标请求时,计算设备108可用于拦截或者获取由网页应用的网页端102向网页应用的服务器端110发送的目标请求106。
计算设备108还可以基于目标请求106来确定与网页应用的网页端102对应的流量文件112是否存在。例如,当开始对网页应用进行 测试时,计算设备108在获取到目标请求106后进行检查以确认是否存在流量文件112。在一个示例中,流量文件112的类型为超文本传输协议存档文件。
在一些实施例中,如果计算设备108没有检查到与测试用例104对应的流量文件112,表明测试用例104是第一次被使用。计算设备108可以创建针对测试用例104的流量文件,该流量文件是用于存储由于测试用例104引起的由网页应用的网页端102向网页应用的服务器端110发送的目标请求和以及从服务器端返回的针对目标请求的目标返回内容两者。
在一些实施例中,如果计算设备108检测到与网页应用的网页端102对应的流量文件112,表明先前已执行过测试用例104。此时,还需要进一步确定测试用例104是否被更新。如果测试用例未被更新,则可以将获取的由网页应用的网页端102向网页应用的服务器端110发送的目标请求与流量文件112中存储的参考请求进行比较以确定是否存在对应的参考请求。如果存在与目标请求匹配的参考请求,则将在流量文件中针对参考请求的返回内容提供给网页应用的网页端102。这种操作,不需要再通过网络向网页应用的服务器端110获取返回内容,从而避免了服务器端的网络性能或设备问题对网页端测试的影响。
在一些实施例中,在进行目标请求的匹配时,可以设置一些接口白名单。计算设备不对针对接口白名单中的请求进行拦截。在一些实施例中,对于一些接口,在进行与该接口对应的请求的匹配时,可以仅匹配部分字段,而不需要匹配全部的字段。上述示例仅是用于描述本公开,而非对本公开的具体限定。
在一些实施例中,如果测试用例被检测到更新,则需要清空流量文件中存储的信息。测试用例中的涉及服务器端的请求被正常发送到服务器端。然后,将发送到服务器端的请求和从服务端获取到的返回内容重新写到流量文件中。在所有测试项均被测试完成后,完成对网页应用的测试。
通过该方法,由于在测试设备处将目标请求和目标返回内容在流 量文件处进行关联保存,进而实现了对网络请求的拦截和回放,并且还支持用户在测试中设置自定义匹配规则,改进了用户体验。
上面结合图1描述了本公开的实施例的设备和/或方法可以在其中被实施的示例环境的示意图,下面结合图2描述根据本公开的实施例的用于测试网页应用的示例的流程图的示意图。图1中的计算设备108可被用作测试设备。
如图2所示,在示例200中,在框202处,计算设备开始执行测试,可以理解的是计算设备可以对测试用例中的所有测试项进行测试,也可以对测试用例中的一部分测试项进行测试。
在框204处,计算设备判断是否存在与网页应用对应的流量文件,当未检查到流量文件时,则在框214处创建文件。例如,创建可用于存储所有目标请求及对应的返回内容的流量文件。
除了创建流量文件,在框216处,计算设备还将目标请求向网页应用的服务器端发送,从而获得来自服务器端的返回内容。在获得来自服务器端的返回内容后,计算设备可以将与目标请求和对应的目标返回内容存储在流量文件中。在一个示例中,流量文件被存储在计算设备处。在另一个示例中,流量文件被存储在远程服务器上。
在计算设备确定存在流量文件后,在框206处,计算设备进一步确定测试用例是否处于更新模式,即测试用例是否被更新过。当计算设备确定测试用例被更新后,在框216处向服务器端发出实际请求,并将返回保存至流量文件。在该过程中,计算设备直接向服务器端发出目标请求,并同时将与目标请求相关联的目标返回内容存储在流量文件中。附加地,当计算设备确定测试用例被更新后,计算设备将流量文件中的信息全部移除。然后,计算设备将目标请求和与目标请求相关联的目标返回内容存储在流量文件。
在框208处,计算设备使用流量文件匹配请求。在确定测试用例未被更新后,计算设备使用流量文件对目标请求进行匹配。在一个示例中,计算设备对目标请求与流量文件中存储的请求进行匹配。
在框210处,计算设备确定匹配是否成功。当流量文件中存在与 目标请求相匹配的参考请求时,匹配成功。接下来,计算设备进一步在框212处使用保存的流量返回该请求。在这个过程中,计算设备获取对应于参考请求的返回内容。然后,计算设备将与参考请求对应的返回内容作为目标返回内容返回给网页端,以此完成测试。
当流量文件中不存在与目标请求相匹配的参考请求时,在框218处实际发出请求。此时,计算设备直接将目标请求发送至服务器端,然后计算设备接收与目标请求对应的目标返回内容。附加地,计算设备可以将目标请求与目标返回内容相关联地存储在流量文件中。
通过该方法,由于在测试设备处将目标请求和目标返回内容在流量文件处进行关联保存,进而实现了对网络请求的拦截和回放,改进了用户体验。
上面结合图2描述了根据本公开的实施例的用于测试网页应用的示例的流程图的示意图。下面结合图3描述根据本公开的实施例的用于测试网页应用的示例方法的示意图。图3所示的过程可在图1所示的计算设备108或其他任意合适的计算设备处执行。
如图3所示,在示例300中,在框302处,计算设备基于测试用例,获取由网页应用的网页端向网页应用的服务器端发送的目标请求。为了测试网页应用的网页端,需要设计相应的测试用例来对网页端的功能和操作进行检测。
在一些实施例中,针对网页应用的网页端,可以设置多个测试用例。每个测试用例的作用或功能不同,分别用于测试网页应用中不同的功能。例如,一个测试用例用于测量评论提交功能,其可以包括多个测试步骤:打开页面,点击评论按钮,向评论框中添加文本,点击评论提交按钮等。对于点击评论提交按钮操作则会触发网页端向服务器端发送提交评论的目标请求。而对于打开页面、点击评论按钮、向评论框中添加文本等测试操作,则是在测试设备处或者在网页端执行的操作,并不需要向服务器端发送请求。
随后,在框304处计算设备基于目标请求,确定是否存在与网页应用对应的流量文件。例如,计算设备可以进行检查以确定是否存在 流量文件。在一些实施例中,计算设备可以根据测试用例的标识来检测是否存在与该测试用例相对应的流量文件。例如在存储测试用例的流量文件时,还会对应的存储测试用例的标识。计算设备将测试用例的标识与存储的流量文件对应的测试用例的标识进行匹配来查找对应的流量文件。
在一些实施例中,当计算设备在没有检测到流量文件时,直接创建新的流量文件以用于网页应用测试。同时,计算设备还将目标请求发送至服务器端,并从服务器端接收到返回内容。此时,计算设备会将该请求和对应的返回内容存储到流量文件中。
接着,在框306处,计算设备响应于存在与网页应用对应的流量文件,确定测试用例是否被更新。例如,当测试设备检测到当前存在流量文件时,还需要进一步判定该测试用例是否被更新过。如果是未更新过的测试用例,则先前的流量文件还可以被使用。如果是更新过的测试用例,则需要重写针对该测试用例的流量文件。
在一些实施例中,在用户对测试用例进行更新后,计算设备可以获取测试用例被更新的指示信息。例如,通过针对测试用例的一个标志位来指示测试用例被更新。如果确定测试用例被更新后,流量文件中的内容将不再可用。接下来,计算设备会删除流量文件中的内容,同时还会将目标请求发送至服务器端,并将目标请求和从服务器端返回的与目标请求对应的目标返回内容相关联地存储在流量文件中。
最后,在框308处,计算设备响应于测试用例未被更新,基于流量文件向网页端返回与目标请求对应的目标返回内容,以完成网页应用的测试。在确定测试用例未被更新时,则计算设备可以利用流量文件来确定出可以返给网页端的目标返回内容。
在一些实施例中,计算设备将目标请求与流量文件中的参考请求进行匹配。如果匹配,则计算设备将参考请求对应的返回内容确定为可用于目标请求的目标返回内容。然后,将确定的目标返回内容提供给网页端。如果未找到匹配的参考请求,则计算设备可以向服务器端发送请求来获得对应的目标返回内容。附加地,还可以将此时的请求 和对应的目标返回内容存储在流量文件中。
在一些实施例中,计算设备可以预先设置一些白名单接口作为第一接口列表,针对第一接口列表的接口的访问请求将不被拦截。在这种情况下,在将目标请求与流量文件中的参考请求进行匹配时,计算设备还可以确定目标请求是否是针对预先配置的第一接口列表中的接口的。如果目标请求是针对第一接口列表中的接口的,则直接将目标请求发送到服务端来获取目标返回内容,而不将目标请求与流量文件中的参考请求进行匹配。如果目标请求不是针对第一接口列表中的接口的,将目标请求与流量文件中的参考请求进行匹配。如果匹配,则计算设备将参考请求对应的返回内容确定为可用于目标请求的目标返回内容。然后,将确定的目标返回内容提供给网页端。如果未找到匹配的参考请求,则计算设备可以向服务器端发送请求来获得对应的目标返回内容。附加地,还可以将此时的请求和对应的目标返回内容存储在流量文件中。
在一些实施例中,还可以依据需设置第二接口列表。对于针对第二接口列表中接口的请求,在进行请求匹配时,仅需要匹配一些关键字段或参数就行。例如,在测试过程中,可能操作请求涉及时间信息,如果针对某些接口时间信息并不重要,可以设置进行请求匹配时不用对时间参数或字段进行匹配。在这种情况下,在进行目标请求与流量文件中的参考请求的匹配时,计算设备还可以确定目标请求是否是针对第二接口列表中的接口的;如果目标请求是针对第二接口列表中的接口的,将目标请求的部分字段与参考请求的部分字段进行匹配。如果目标请求不是针对第二接口列表中的接口的,将目标请求的全部字段与参考请求的全部字段进行匹配。如果匹配,则计算设备将参考请求对应的返回内容确定为可用于目标请求的目标返回内容。然后,将确定的目标返回内容提供给网页端。如果未找到匹配的参考请求,则计算设备可以向服务器端发送请求来获得对应的目标返回内容。在一些实施例中,当测试用例中的所有操作完成时,终止测试。
通过该方法,由于在测试设备处将目标请求和目标返回内容在流 量文件处进行关联保存,实现了对网络请求的拦截和回放,从而减少了网页应用测试对真实流量的依赖,并且提高了测试的稳定性和准确率,改进了用户体验。
上面结合图3描述了根据本公开的实施例的用于测试网页应用的示例方法的示意图。下面结合图4描述根据本公开的实施例的用于测试网页应用的系统架构的示例的示意图。
如图4所示,在示例400中,系统架构由基础设施层、应用层和用户层组成。可以理解的是,用户可以根据自身需求选择合适的能实现本方案中技术方案的其他类型的系统架构,本申请在此不作限制。
在基础设施层处,测试设备会提供用于测试的服务模块428,该服务模块中包括网络服务模块430、流量匹配服务模块432和储存服务模块434。可以理解的是,用户可以根据自身需求添加其他类型的服务,本申请在此不做限制。
网络服务用于提供网页端和服务端之间的通信服务,同时也提供测试设备与服务端进行通信的服务。在一个示例中,该网络服务可以均为远程网络服务。在另一个示例中,该网络服务可以均为短程网络服务,如本地局域网服务。
流量匹配服务用于目标请求和流量文件中的参考请求之间的匹配服务。在一个示例中,该匹配服务基于目标请求和参考请求中的标识来进行。
在一些实施例中储存服务用于流量文件中相关的信息存储。例如,储存服务用于将相关联的目标请求和目标返回内容存储至流量文件中。
在应用层处,包括网络模块408、储存(本地/远端)模块414和流量匹配模块422,其中网络模块中还包括流量拦截模块410和流量回放模块412;储存(本地/远端)模块还包括写入模块416、创建模块418和删除模块420;流量匹配模块还包括自定义匹配模块424和接口白名单模块426。
流量拦截模块在确定流量文件中存在与目标请求匹配的参考请 求时,将目标请求在测试设备处进行拦截,然后将与参考请求对应的返回内容作为目标返回内容返回给网页端,以此完成测试。
流量回放模块在测试因故失败或因故被中止时,执行流量回放功能以复现测试过程中流量的具体情况,以方便用户分析测试过程中的失败或终止原因。写入模块在流量文件被创建后,将与目标请求和与目标请求对应的目标返回内容相关联地写入并存储在流量文件中。
删除模块在测试设备确定测试用例被更新后,将已经写入流量文件中信息进行移除,以重新写入新的测试用例对应的目标请求和目标返回内容。
自定义匹配模块使得用户可以根据自身需求来定制流量文件的匹配规则。例如,用户可以规定一个请求不需要匹配平台字段,另一个请求不需要匹配时间字段。附加的,流量文件还内置默认匹配规则,使得测试用例中访问本地服务的访问请求无需经过匹配而可以直接进行请求的访问。
接口白名单模块使得用户可以根据自身需求将部分接口列入白名单。例如,来自白名单中的接口的访问请求将不会被在测试设备处被拦截,该访问请求将直接发送给服务器端,与服务器端直接通信。
在用户层,包括使用网络模块402,用户可以根据该功能模块对整个测试过程进行录制以用于流量回放来分析并判断测试过程中可能出现的各种问题。其中,在框404中,“const network=useNetwork(),开始录制”表示在测试过程开始时进行录制,在框406中,“network.stop()结束录制并生成文件”表示在测试完成时,结束对测试过程的录制并将录制的测试过程生成对应的文件并进行保存。
上面结合图4描述了根据本公开的实施例的用于测试网页应用的系统架构的示例的示意图。下面结合图5描述根据本公开的实施例的用于测试网页应用的伪代码的示例的示意图。
如图5所示的示例500,框502为伪代码的示例。例如,其中的注释“//设置对真实服务器的请求访问”表示可以对服务器端的发送请求,以使得目标请求访问可以经由测试设备被发送至服务器端。
又如,其中的注释“//匹配请求时忽略指定的查询键”表示在进行匹配时,可以忽略预先设置的特定的信息。例如,在进行匹配时,可以将请求的某些字段信息进行忽略。在一个实例中,在进行匹配时忽略请求中的平台字段。在另一个示例中,在进行匹配时,忽略请求中的时间字段。
其中的注释“//默认为静默时,传入调试时会输出不匹配的请求”表示在默认匹配规则下,当调试通过时,可以直接输出请求。例如,当测试设备接收到来自访问本地服务的访问请求时,直接执行该访问请求。
执行测试所使用的伪代码中的代码“const network=await useNetwork('spender-search');”表示调用使用网络(useNetwork)模块来查询文件’spender-search’是否存在。如果不存,就创建该文件然后再进行调用。例如,当计算设备检测当前不存在流量文件时,执行创建文件的任务以创建流量文件。
上面结合图5描述了根据本公开的实施例的用于测试网页应用的伪代码的示例的示意图。下面结合图6描述根据本公开的实施例的用于测试网页应用的装置的示意性框图。
如图6所示,装置600包括目标请求获取模块610,被配置为基于测试用例,获取由网页应用的网页端向网页应用的服务器端发送的目标请求;流量文件存在判定模块620,被配置为基于目标请求,确定是否存在与网页应用对应的流量文件;测试用例更新判定模块630,被配置为响应于存在与网页应用对应的流量文件,确定测试用例是否被更新;以及目标返回内容返回模块640,被配置为响应于测试用例未被更新,基于流量文件向网页端返回与目标请求对应的目标返回内容,以完成网页应用的测试。
在一些实施例中,目标返回内容返回模块640包括:匹配模块,被配置为将目标请求与流量文件中的参考请求进行匹配;返回内容确定模块,被配置为响应于流量文件中存在与目标请求相匹配的参考请求,确定与参考请求对应的返回内容;以及返回模块,被配置为将返 回内容作为目标返回内容提供给网页端。
在一些实施例中,目标返回内容返回模块640还包括:目标请求发送模块,被配置为响应于流量文件中不存在与目标请求相匹配的参考请求,向服务器端发送目标请求;目标返回内容接收模块,被配置为接收与目标请求对应的目标返回内容;以及存储模块,被配置为将目标返回内容与目标请求相关联地存储在流量文件中。
在一些实施例中,匹配模块包括:第一请求判定模块,被配置为确定目标请求是否是针对预先配置的第一接口列表中的接口的,其中第一接口列表中的接口是被允许访问的接口;以及第一请求匹配模块,被配置为响应于目标请求不是针对第一接口列表中的接口的,将目标请求与流量文件中的参考请求进行匹配。
在一些实施例中,装置600还包括:第一请求发送模块,被配置为响应于目标请求是针对第一接口列表中的接口的,向服务器端发送目标请求;以及第一内容接收模块,被配置为接收与目标请求对应的目标返回内容。
在一些实施例中,匹配模块包括:第二请求判定模块,被配置为确定目标请求是否是针对第二接口列表中的接口的;以及第二请求匹配模块,被配置为响应于目标请求是针对第二接口列表中的接口的,将目标请求的部分字段与参考请求的部分字段进行匹配。
在一些实施例中,匹配模块包括还包括:第二请求匹配模块,被配置为响应于目标请求不是针对第二接口列表中的接口的,将目标请求的全部字段与参考请求的全部字段进行匹配。在一些实施例中,装置600还包括:流量文件创建模块,被配置为响应于不存在与网页应用对应的流量文件,创建流量文件;目标返回内容获取模块,被配置为通过向服务器端发送目标请求,来获取与目标请求对应的目标返回内容;以及存储模块,被配置为将目标返回内容与目标请求相关联地存储在流量文件中。
在一些实施例中,装置600还包括:移除模块,被配置为响应于测试用例被更新,移除流量文件中的信息;目标请求发送模块,被配 置为将目标请求发送至服务器端;目标返回内容接收模块,被配置为接收与目标请求对应的目标返回内容;以及存储模块,被配置为目标返回内容与目标请求相关联地存储在流量文件中。
在一些实施例中,流量文件为超文本传输协议存档文件。
在一些实施例中,装置600还包括:访问请求执行模块,被配置为响应于获取到与网页端有关的用于访问本地服务的访问请求,执行访问请求。
图7示出了可以用来实施本公开的实施例的示例设备700的示意性框图。图1中的计算设备108可以利用设备700来实现。如图所示,设备700包括中央处理单元(CPU)701,其可以根据存储在只读存储器(ROM)702中的计算机程序指令或者从存储单元708加载到随机访问存储器(RAM)703中的计算机程序指令,来执行各种适当的动作和处理。在RAM 703中,还可存储设备700操作所需的各种程序和数据。CPU 701、ROM 702以及RAM 703通过总线704彼此相连。输入/输出(I/O)接口705也连接至总线704。
设备700中的多个部件连接至I/O接口705,包括:输入单元706,例如键盘、鼠标等;输出单元707,例如各种类型的显示器、扬声器等;存储页面708,例如磁盘、光盘等;以及通信单元709,例如网卡、调制解调器、无线通信收发机等。通信单元709允许设备700通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。
上文所描述的各个过程和处理,例如方法300,可由处理单元701执行。例如,在一些实施例中,方法300可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元708。在一些实施例中,计算机程序的部分或者全部可以经由ROM702和/或通信单元709而被载入和/或安装到设备700上。当计算机程序被加载到RAM 703并由CPU 701执行时,可以执行上文描述的方法300的一个或多个动作。
本公开可以是方法、装置、系统和/或计算机程序产品。计算机程 序产品可以包括计算机可读存储介质,其上载有用于执行本公开的各个方面的计算机可读程序指令。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是——但不限于——电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机 上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。
这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本公开的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理单元,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理单元执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的 一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的技术改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。

Claims (15)

  1. 一种用于测试网页应用的方法,包括:
    基于测试用例,获取由所述网页应用的网页端向所述网页应用的服务器端发送的目标请求;
    基于所述目标请求,确定是否存在与所述网页应用对应的流量文件;
    响应于存在与所述网页应用对应的所述流量文件,确定所述测试用例是否被更新;以及
    响应于所述测试用例未被更新,基于所述流量文件向所述网页端返回与所述目标请求对应的目标返回内容,以完成所述网页应用的测试。
  2. 根据权利要求1所述的方法,其中基于所述流量文件向所述网页端返回与所述目标请求对应的目标返回内容包括:
    将所述目标请求与所述流量文件中的参考请求进行匹配;
    响应于所述流量文件中存在与所述目标请求相匹配的所述参考请求,确定与所述参考请求对应的返回内容;以及
    将所述返回内容作为所述目标返回内容提供给所述网页端。
  3. 根据权利要求2所述的方法,其中基于所述流量文件向所述网页端返回与所述目标请求对应的目标返回内容还包括:
    响应于所述流量文件中不存在与所述目标请求相匹配的所述参考请求,向所述服务器端发送所述目标请求;
    接收与所述目标请求对应的所述目标返回内容;以及
    将所述目标返回内容与所述目标请求相关联地存储在所述流量文件中。
  4. 根据权利要求3所述的方法,其中将所述目标请求与所述流量文件中的参考请求进行匹配包括:
    确定所述目标请求是否是针对预先配置的第一接口列表中的接口的,其中所述第一接口列表中的接口是被允许访问的接口;以及
    响应于所述目标请求不是针对所述第一接口列表中的接口的,将所述目标请求与所述流量文件中的参考请求进行匹配。
  5. 根据权利要求4所述的方法,其中还包括:
    响应于所述目标请求是针对所述第一接口列表中的接口的,向所述服务器端发送所述目标请求;以及
    接收与所述目标请求对应的所述目标返回内容。
  6. 根据权利要求3所述的方法,其中将所述目标请求与所述流量文件中的参考请求进行匹配包括:
    确定所述目标请求是否是针对第二接口列表中的接口的;以及
    响应于所述目标请求是针对所述第二接口列表中的接口的,将所述目标请求的部分字段与所述参考请求的部分字段进行匹配。
  7. 根据权利要求6所述的方法,其中将所述目标请求与所述流量文件中的参考请求进行匹配还包括:
    响应于所述目标请求不是针对第二接口列表中的接口的,将所述目标请求的全部字段与所述参考请求的全部字段进行匹配。
  8. 根据权利要求1所述的方法,还包括:
    响应于不存在与所述网页应用对应的所述流量文件,创建所述流量文件;
    通过向所述服务器端发送所述目标请求,来获取与所述目标请求对应的所述目标返回内容;以及
    将所述目标返回内容与所述目标请求相关联地存储在所述流量文件中。
  9. 根据权利要求1所述的方法,还包括:
    响应于所述测试用例被更新,移除所述流量文件中的信息;
    将所述目标请求发送至所述服务器端;
    接收与所述目标请求对应的所述目标返回内容;以及
    所述目标返回内容与所述目标请求相关联地存储在所述流量文件中。
  10. 根据权利要求1所述的方法,还包括:
    所述流量文件为超文本传输协议存档文件。
  11. 根据权利要求1所述的方法,还包括:
    响应于获取到与所述网页端有关的用于访问本地服务的访问请求,执行所述访问请求。
  12. 一种用于测试网页应用的装置,包括:
    目标请求获取模块,被配置为基于测试用例,获取由所述网页应用的网页端向网页应用的服务器端发送的目标请求;
    流量文件存在判定模块,被配置为基于所述目标请求,确定是否存在与所述网页应用对应的流量文件;
    测试用例更新判定模块,被配置为响应于存在与所述网页应用对应的流量文件,确定所述测试用例是否被更新;以及
    目标返回内容返回模块,被配置为响应于所述测试用例未被更新,基于所述流量文件向所述网页端返回与所述目标请求对应的目标返回内容,以完成所述网页应用的测试。
  13. 一种电子设备,包括:
    至少一个处理器;以及
    存储装置,用于存储至少一个程序,当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现根据权利要求1-11中任一项所述的方法。
  14. 一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-11中任一项所述的方法。
  15. 一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-11中的任一项所述的方法。
PCT/CN2024/106374 2024-07-19 2024-07-19 用于测试网页应用的方法、装置、设备、介质和程序产品 Pending WO2026016162A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2024/106374 WO2026016162A1 (zh) 2024-07-19 2024-07-19 用于测试网页应用的方法、装置、设备、介质和程序产品
US19/273,497 US20260023680A1 (en) 2024-07-19 2025-07-18 Method and apparatus, device, medium and program product for testing web applications

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2024/106374 WO2026016162A1 (zh) 2024-07-19 2024-07-19 用于测试网页应用的方法、装置、设备、介质和程序产品

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US19/273,497 Continuation US20260023680A1 (en) 2024-07-19 2025-07-18 Method and apparatus, device, medium and program product for testing web applications

Publications (1)

Publication Number Publication Date
WO2026016162A1 true WO2026016162A1 (zh) 2026-01-22

Family

ID=98432626

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2024/106374 Pending WO2026016162A1 (zh) 2024-07-19 2024-07-19 用于测试网页应用的方法、装置、设备、介质和程序产品

Country Status (2)

Country Link
US (1) US20260023680A1 (zh)
WO (1) WO2026016162A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180137286A1 (en) * 2016-11-16 2018-05-17 International Business Machines Corporation Method and apparatus for security testing of application flows that cannot be automated through http replay
CN113590497A (zh) * 2021-09-27 2021-11-02 腾讯科技(深圳)有限公司 业务服务的测试方法、装置、电子设备及存储介质
CN117234949A (zh) * 2023-11-13 2023-12-15 广州品唯软件有限公司 测试数据降噪方法、装置、存储介质、计算机设备
CN117667710A (zh) * 2023-12-07 2024-03-08 北京有竹居网络技术有限公司 页面测试用例的确定方法、测试方法、装置、介质及设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180137286A1 (en) * 2016-11-16 2018-05-17 International Business Machines Corporation Method and apparatus for security testing of application flows that cannot be automated through http replay
CN113590497A (zh) * 2021-09-27 2021-11-02 腾讯科技(深圳)有限公司 业务服务的测试方法、装置、电子设备及存储介质
CN117234949A (zh) * 2023-11-13 2023-12-15 广州品唯软件有限公司 测试数据降噪方法、装置、存储介质、计算机设备
CN117667710A (zh) * 2023-12-07 2024-03-08 北京有竹居网络技术有限公司 页面测试用例的确定方法、测试方法、装置、介质及设备

Also Published As

Publication number Publication date
US20260023680A1 (en) 2026-01-22

Similar Documents

Publication Publication Date Title
CN110858172B (zh) 一种自动化测试代码生成方法和装置
US11620179B1 (en) Method, apparatus, device, storage medium and program product for log information processing
WO2023231341A1 (zh) 数据资产风险发现方法和装置
CN111666201A (zh) 回归测试方法、装置、介质及电子设备
CN108959294B (zh) 一种访问搜索引擎的方法和装置
CN113360377B (zh) 一种测试方法和装置
CN112100092A (zh) 一种信息缓存方法、装置、设备及介质
EP4717017A1 (en) Data privacy inconsistency detection
CN113254340B (zh) 一种测试用例的生成方法和装置
CN114385382A (zh) 轻应用的访问方法、装置、计算机设备和存储介质
CN119848841A (zh) 一种代码分析方法及相关设备
US9398041B2 (en) Identifying stored vulnerabilities in a web service
CN115408461A (zh) 数据信息获取方法、装置、电子设备和介质
CN120321224A (zh) 流量追踪方法和装置、电子设备、计算机可读存储介质
WO2026016162A1 (zh) 用于测试网页应用的方法、装置、设备、介质和程序产品
WO2025222808A1 (zh) 代码编辑的方法、装置、设备和存储介质
CN114595449A (zh) 一种安全扫描方法及装置
CN113347052A (zh) 通过访问日志统计用户访问数据的方法和装置
CN116450533A (zh) 用于应用程序的安全检测方法、装置、电子设备和介质
CN111367898B (zh) 数据处理方法、装置、系统、电子设备及存储介质
US20190095538A1 (en) Method and system for generating content from search results rendered by a search engine
CN114911954A (zh) 一种富媒体资源交互方法、装置、设备及存储介质
CN115525608A (zh) 一种数据处理方法、装置、电子设备及计算机可读介质
CN114115908A (zh) 一种指令集生成、程序解析方法装置、设备以及存储介质
CN114462030A (zh) 隐私政策的处理、取证方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24947550

Country of ref document: EP

Kind code of ref document: A1