A website interface test data automatic generation method and device
Patent Information
- Application Number
- CN202411548064.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2026-10-20
AI Technical Summary
[0004]有鉴于此,本发明提供了一种网站接口测试数据自动生成方法及装置,以解决手动创建模拟数据耗时费力的问题
[0047]本发明通过目标抓取插件实时监测浏览器运行过程中的网络请求,准确识别和提取网络请求的请求参数和返回参数,避免了人工收集数据可能出现的错误,确保测试数据的准确性,大大节省了测试数据准备的时间。服务器能根据历史记录中的历史请求参数和历史返回参数生成模拟数据,使模拟数据更贴近实际的业务场景,提高测试结果的可靠性。减少了测试人员重复构造测试数据的工作量,从而显著提高接口测试的效率。此外,本发明可以根据实际情况随时调整模拟请求,快速获得对应的模拟数据进行测试,提高了测试的灵活性和适应性。
Smart Images

Figure HDA0005117231450000011 
Figure HDA0005117231450000012 
Figure HDA0005117231450000021
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing technology, and specifically to a method and apparatus for automatically generating website interface test data. Background Technology
[0002] In software development and testing, mock data refers to test data that simulates real data. This data is used in place of real data during the development and testing phases so that developers and testers can perform their work without relying on actual data sources.
[0003] When creating mock data, testers must create mock data one by one according to the actual interface data format and requirements, especially when there are many interfaces or complex data structures. Due to the limitations of manual creation, testers usually cannot generate a large amount of mock data at once, which is a huge challenge for projects requiring large-scale testing. Manually creating mock data is not only time-consuming and laborious, but also prone to errors. Testers need to carefully check each data item to ensure that they are consistent with the actual interface data. This process greatly reduces testing efficiency and increases testing costs. Summary of the Invention
[0004] In view of this, the present invention provides a method and apparatus for automatically generating website interface test data, so as to solve the problem of time-consuming and laborious manual creation of simulated data.
[0005] In a first aspect, the present invention provides a method for automatically generating website interface test data, the method being executed by a client, the client having a target crawling plugin running, the method comprising:
[0006] The target crawling plugin monitors the browser's network requests in real time during operation, identifies and extracts the request parameters and return parameters of the network requests;
[0007] The target capture plugin sends the request parameters and the return parameters to the server for recording and storage. When the server detects a simulated request initiated by a user, it reads the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information, and generates simulated data based on the historical request parameters and historical return parameters, so as to execute the simulated operation according to the simulated data.
[0008] The above solution utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thus significantly improving the efficiency of interface testing. Furthermore, the above solution can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0009] In one alternative implementation, the target crawling plugin is built based on the following steps:
[0010] Functional requirements for obtaining the data to be scraped;
[0011] Based on the aforementioned functional requirements, the project structure for the target crawling plugin is constructed and written; the project structure includes a manifest.json file, a background.js file, a popup.html file, a popup.js file, an options.html file, and an options.js file;
[0012] Based on the project structure, the target crawling plugin was built; the target crawling plugin is a Chrome plugin.
[0013] In one optional implementation, the step of monitoring network requests made by the browser in real time during operation through the target crawling plugin, and identifying and extracting the request parameters and return parameters of the network requests, includes:
[0014] Authorize the target crawling plugin based on the manifest.json file;
[0015] After authorization is completed, the browser's network requests during runtime are monitored in real time based on the background.js file.
[0016] Determine the request type of the network request; the request type includes GET requests and POST requests;
[0017] If the network request is a GET request, then the request parameters of the network request are extracted based on the Uniform Resource Locator (URL) of the network request, and the return parameters of the network request are extracted based on the return header information of the network request.
[0018] If the network request is a POST request, then the request parameters of the network request are extracted based on the request body information, and the return parameters of the network request are extracted based on the return header information.
[0019] In one optional implementation, the step of sending the request parameters and the return parameters to the server for recording and saving via the target crawling plugin includes:
[0020] The target crawling plugin organizes the captured request parameters and return parameters according to the target format, and sends the organized request parameters and return parameters to the server for recording and storage.
[0021] Secondly, this invention provides a method for automatically generating website interface test data. The method is executed by a server, which runs a simulation platform and a request interceptor. The method includes:
[0022] The request and return parameters sent by the target crawling plugin are recorded and saved; the request and return parameters are generated by the target crawling plugin in real time by monitoring the network requests of the browser during operation, and by identifying and extracting the network requests.
[0023] The simulation request initiated by the user is obtained through the simulation platform;
[0024] Based on the simulated request, the historical request parameters and historical return parameters corresponding to the simulated request are read from the historical record information of the server, and the historical request parameters and historical return parameters are sent to the request interceptor.
[0025] The request interceptor generates simulated data based on the historical request parameters and the historical return parameters, and sends the simulated data as a return result to the simulation platform;
[0026] The simulation platform performs simulation operations based on the simulation data.
[0027] In one optional implementation, the step of generating simulated data based on the historical request parameters and the historical return parameters by the request interceptor includes:
[0028] The request interceptor analyzes the historical request parameters and historical return parameters to simulate the actual network request processing process, and generates simulated data according to the target simulation algorithm.
[0029] Thirdly, the present invention provides a device for automatically generating website interface test data, the device being executed by a client, the client having a target crawling plugin running in it, the device comprising:
[0030] The network request capture module is used to monitor the network requests made by the browser in real time during the operation of the target capture plugin, and to identify and extract the request parameters and return parameters of the network requests.
[0031] The parameter sending module is used to send the request parameters and the return parameters to the server for recording and saving through the target capture plugin, so that when the server hears that the user has initiated a simulated request, it can read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information according to the simulated request, and generate simulated data based on the historical request parameters and historical return parameters, so as to execute the simulated operation according to the simulated data.
[0032] Fourthly, the present invention provides a device for automatically generating website interface test data, which is executed by a server, wherein the server runs a simulation platform and a request interceptor, and the device includes:
[0033] The parameter recording module is used to record and save the request parameters and return parameters sent by the target crawling plugin; the request parameters and return parameters are generated by the target crawling plugin in real time by monitoring the network requests of the browser during operation, and identifying and extracting the network requests;
[0034] The simulated request acquisition module is used to acquire the simulated request initiated by the user through the simulation platform;
[0035] The historical record information reading module is used to read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information of the server according to the simulated request, and send the historical request parameters and historical return parameters to the request interceptor.
[0036] The simulation data generation module is used to generate simulation data based on the historical request parameters and the historical return parameters through the request interceptor, and send the simulation data as a return result to the simulation platform;
[0037] The simulation operation execution module is used to perform simulation operations based on the simulation data through the simulation platform.
[0038] Fifthly, the present invention provides a website interface test data automatic generation system, the system comprising: a client and a server; the client running a target crawling plugin, and the server running a simulation platform and a request interceptor;
[0039] The target crawling plugin is used to monitor network requests made by the browser in real time, identify and extract the request parameters and return parameters of the network requests, and send the request parameters and return parameters to the server for recording and storage.
[0040] The simulation platform is used to obtain the simulation request initiated by the user, and according to the simulation request, read the historical request parameters and historical return parameters corresponding to the simulation request from the historical record information of the server, and send the historical request parameters and historical return parameters to the request interceptor.
[0041] The request interceptor is used to generate simulated data based on the historical request parameters and the historical return parameters, and send the simulated data as a return result to the simulation platform;
[0042] The simulation platform is also used to perform simulation operations based on the simulation data.
[0043] In a sixth aspect, the present invention provides a computer device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform a method for automatically generating website interface test data according to the first aspect or any corresponding embodiment described above.
[0044] In a seventh aspect, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform a method for automatically generating website interface test data according to the first aspect or any corresponding embodiment described above.
[0045] Eighthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute a method for automatically generating website interface test data according to the first aspect or any corresponding embodiment described above.
[0046] The technical solution provided by this invention may include the following beneficial effects:
[0047] This invention utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thus significantly improving the efficiency of interface testing. Furthermore, this invention allows for real-time adjustment of simulated requests based on actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing. Attached Figure Description
[0048] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram of the structure of a website interface test data automatic generation system according to an embodiment of the present invention;
[0050] Figure 2 This is a flowchart of a method for automatically generating website interface test data according to an embodiment of the present invention;
[0051] Figure 3 This is a flowchart of another method for automatically generating website interface test data according to an embodiment of the present invention;
[0052] Figure 4 This is a structural block diagram of a website interface test data automatic generation device according to an embodiment of the present invention;
[0053] Figure 5 This is a structural block diagram of another website interface test data automatic generation device according to an embodiment of the present invention;
[0054] Figure 6 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0056] According to an embodiment of the present invention, an embodiment of an automatic website interface test data generation system is provided. Figure 1 This is a schematic diagram of the structure of a website interface test data automatic generation system according to an embodiment of the present invention, such as... Figure 1 As shown, the system includes: a client 110 and a server 120; the client 110 runs a target crawling plugin 111, and the server 120 runs a simulation platform 121 and a request interceptor 122.
[0057] The target capture plugin 111 is used to monitor the network requests made by the browser in real time, identify and extract the request parameters and return parameters of the network request, and send the request parameters and return parameters to the server 120 for recording and storage.
[0058] The simulation platform 121 is used to obtain the simulation request initiated by the user, and according to the simulation request, read the historical request parameters and historical return parameters corresponding to the simulation request from the historical record information of the server 120, and send the historical request parameters and historical return parameters to the request interceptor 122.
[0059] The request interceptor 122 is used to generate simulated data based on the historical request parameters and the historical return parameters, and send the simulated data as a return result to the simulation platform 121;
[0060] The simulation platform 121 is also used to perform simulation operations based on the simulation data.
[0061] Furthermore, the website interface test data automatic generation system of this embodiment mainly consists of two parts: a client 110 and a server 120. A target crawling plugin 111 runs on the client 110. A simulation platform 121 and a request interceptor 122 run on the server 120. The target crawling plugin 111 monitors network requests made by the browser in real time. When a user makes various operations through the browser and generates network requests, the target crawling plugin remains vigilant, identifying and extracting the request and return parameters of the network requests. These parameters contain key information about the request, such as the target address, the data carried, and the result information returned by the server. The target crawling plugin 111 also sends the extracted request and return parameters to the server 120 for recording and storage, providing a data foundation for subsequent simulation tests.
[0062] Furthermore, the simulation platform 121 is used to obtain simulation requests initiated by users. When a user needs to perform interface testing, they can send a simulation request to the simulation platform in a specific way. Based on the simulation request, the platform searches for historical request parameters and historical return parameters corresponding to the simulation request in the historical record information of the server 120, and sends the found historical request parameters and historical return parameters to the request interceptor 122. The request interceptor 122 is used to generate simulation data based on the received historical request parameters and historical return parameters. Through analysis and processing of this historical data, it constructs simulation data that matches the current simulation request and sends the simulation data as a return result to the simulation platform 121. After receiving the simulation data sent by the request interceptor, the simulation platform 121 performs simulation operations based on the simulation data. These simulation operations can be simulating interface calls, testing system responses, etc., to verify the performance and correctness of the interface.
[0063] In summary, this embodiment utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thereby significantly improving the efficiency of interface testing. Furthermore, this embodiment can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0064] According to an embodiment of the present invention, an embodiment of a method for automatically generating website interface test data is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0065] This embodiment provides a method for automatically generating website interface test data. Figure 1 The client 110 executes the command, and the target crawling plugin 111 runs in the client 110. Figure 2 This is a flowchart of a method for automatically generating website interface test data according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0066] Step S201: The target crawling plugin monitors the network requests made by the browser in real time during operation, and identifies and extracts the request parameters and return parameters of the network requests.
[0067] In one alternative implementation, the target crawling plugin is built based on the following steps:
[0068] Functional requirements for obtaining the data to be scraped;
[0069] Based on this functional requirement, the project structure for this target crawling plugin was built and written; the project structure includes manifest.json, background.js, popup.html, popup.js, options.html, and options.js files;
[0070] Based on the project structure, a target crawling plugin was built; this target crawling plugin is a Chrome extension.
[0071] Furthermore, this embodiment first builds a target crawling plugin. During construction, the functional requirements for the data to be crawled are first obtained, clarifying the specific functions the plugin needs to implement, such as crawling specific types of network request parameters and return parameters. Based on these functional requirements, the project structure of the target crawling plugin is built and written. The manifest.json file is used to authorize the plugin, determining its name, version, permissions, and other basic information. The background.js file is responsible for real-time monitoring of network requests during browser operation. The popup.html and popup.js files are used for the plugin's pop-up window interface display and interaction logic, while the options.html and options.js files may be used to set some parameter options for the plugin. Based on the above project structure, the target crawling plugin is built. Here, it is explicitly stated that this target crawling plugin is a Chrome extension, which can run on the Chrome browser.
[0072] In one optional implementation, step S201 includes:
[0073] Authorize the target crawling plugin based on the manifest.json file;
[0074] After authorization is completed, the background.js file is used to monitor the browser's network requests in real time during runtime;
[0075] Determine the request type of the network request; the request type includes GET requests and POST requests;
[0076] If the request type of the network request is a GET request, then the request parameters of the network request are extracted based on the Uniform Resource Locator of the network request, and the return parameters of the network request are extracted based on the return header information of the network request.
[0077] If the request type of the network request is a POST request, then the request parameters of the network request are extracted based on the request body information, and the return parameters of the network request are extracted based on the return header information.
[0078] Furthermore, during monitoring and extraction, this embodiment authorizes the target crawling plugin based on the manifest.json file to ensure that the plugin has sufficient permissions to monitor the browser's network requests. After authorization, the background.js file is used to monitor the browser's network requests in real time and determine the request type, which is divided into GET and POST requests. The parameter extraction methods differ for different request types: If the request type is GET, the request parameters are extracted based on the Uniform Resource Locator (URL) of the network request (GET request parameters are included in the URL), and the return parameters are extracted based on the response headers of the network request. If the request type is POST, the request parameters are extracted based on the request body information of the network request (POST request parameters are placed in the request body). Similarly, the return parameters are extracted based on the response headers of the network request.
[0079] Furthermore, in this embodiment, when a user enters the URL of a website they want to access in their browser and presses Enter to open the specified website, the browser can obtain the interface requests sent by the user to retrieve website content. Google Chrome provides custom plugin capabilities, allowing developers to write and launch custom plugins (i.e., the aforementioned target crawling plugin). With user authorization, these plugins can capture all ongoing browser network requests. Request and return parameters are included in a single complete network request, and this part of the plugin is saved and reported to the hosted server for recording. The sending capability utilizes the browser plugin's network request capabilities. In other words, when a user enters the URL of a website they want to access in their browser and presses Enter, the browser sends a request to the specified website server to retrieve the website's content. During this process, the browser initiates a series of interface requests to retrieve different parts of the webpage, such as HTML structure, images, script files, and other resources. This user action triggers communication between the browser and the server, and the interface requests are the specific means of achieving this communication. Through these interface requests, the browser can obtain the necessary information from the server and display it to the user. Google Chrome's custom plugin capabilities allow developers to write and launch custom plugins according to specific needs. Before the plugin can run, user authorization is required. Once authorized, the target crawling plugin can monitor all ongoing browser network requests in real time. A complete network request contains a wealth of information in its request and response parameters, which is invaluable for analyzing website behavior and performance, as well as conducting API testing. The plugin saves all these parameters and, using the browser plugin's own network request capabilities, reports this data to a pre-built server for recording. This allows the server to store a large amount of network request data, providing a data foundation for subsequent analysis and processing. For example, analysis of this data can reveal user behavior patterns, website traffic distribution, and API response status.
[0080] Step S202: The target capture plugin sends the request parameters and the return parameters to the server for recording and saving. This allows the server to read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information when it hears a simulated request from a user. Simulated data is then generated based on the historical request parameters and historical return parameters, and the simulated operation is performed based on the simulated data.
[0081] In one optional implementation, step S202 includes:
[0082] The target capture plugin organizes the captured request and return parameters according to the target format, and sends the organized request and return parameters to the server for recording and storage.
[0083] Furthermore, this embodiment also uses a target crawling plugin to organize the crawled request and return parameters according to the target format, making the data more standardized and easier for server storage and subsequent processing. The organized request and return parameters are sent to the server for recording and storage. After receiving this data, the server can, upon detecting a simulated request from a user, retrieve the corresponding historical request and return parameters from the historical record information. The server generates simulated data based on the historical request and return parameters. This simulated data can simulate real network requests and responses. Finally, simulated operations are performed based on the simulated data, such as simulating interface calls and testing system responses, to perform website interface testing.
[0084] Furthermore, the data captured by this target crawling plugin can be analyzed to extract network request and response parameters. This data can then be stored in a server database. When a user wants to initiate a simulated request, historical request and response parameters are retrieved and injected into a request interceptor to complete the simulation. The request interceptor can be a built-in network service responsible for acquiring network requests and returning simulated data. Users log into the simulation platform, select the data they want to simulate, and click the test button. The simulation platform is set up as a self-built service, acting as a network server to provide users with operable web pages and network request services for testing. In other words, firstly, the data captured by the target crawling plugin can be analyzed to extract network request and response parameters. These parameters contain key information about the network request, such as the target address, the data carried, and the response status. This data is then stored in a database, creating a historical data repository for later use, forming historical record information. When a user wants to initiate a simulated request, the system retrieves the corresponding historical request and response parameters from the database. These parameters are injected into the request interceptor, which receives the simulated request and returns simulated data based on the injected parameters. In this way, the system can simulate the response of various network requests without actually accessing the real server, which facilitates interface testing and system debugging.
[0085] Furthermore, in the backend system, administrators can customize collection rules. These rules define which network request resources should be automatically collected. For example, specific URL prefixes or path patterns can be set. When the target crawling plugin detects requests matching these prefixes or patterns, it will automatically capture and collect the relevant data for these requests. Therefore, the target crawling plugin in this embodiment can also obtain preset collection rules and crawl target network requests based on these preset collection rules, which include target URL prefixes and target path patterns. Custom collection rules allow organizations to precisely control the collection of any data according to actual needs, thereby avoiding unnecessary resource waste and data redundancy.
[0086] In the backend system, administrators can also configure the automatic modification and generation of simulated data with brute-force rules. Brute-force testing is used to test the system's behavior under extreme or abnormal conditions, such as handling abnormally long inputs or inputs that do not conform to expected formats. For example, the system typically collects usernames that are 4 characters long. However, during brute-force testing, the administrator can configure the system to automatically generate usernames that are 20 characters long and observe whether the system can correctly handle such abnormally long inputs. This type of testing helps to discover potential buffer overflows, performance bottlenecks, or other security issues. Therefore, the request interceptor in this embodiment can also generate target brute-force rule data and send this data to the simulation platform to perform brute-force testing. Furthermore, administrators can define other types of brute-force rules, such as generating invalid data in a specific format or simulating high-concurrency requests. These rules help organizations gain a more comprehensive understanding of the system's robustness and security.
[0087] In summary, this embodiment utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thereby significantly improving the efficiency of interface testing. Furthermore, this embodiment can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0088] This embodiment provides another method for automatically generating website interface test data, which is... Figure 1 The server 120 executes the command, and server 120 runs a simulation platform 121 and a request interceptor 122. Figure 3 This is a flowchart of another method for automatically generating website interface test data according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0089] Step S301: Record and save the request parameters and return parameters sent by the target crawling plugin; the request parameters and return parameters are generated by the target crawling plugin in real time monitoring the network requests of the browser during operation, and identifying and extracting the network requests.
[0090] Furthermore, the target crawling plugin in this embodiment is a software tool deployed in a client's browser or network environment. Its main function is to monitor and capture all network requests sent by the browser in real time. Request parameters refer to the information included when the browser sends a request to the server, such as the URL, HTTP method (GET, POST, etc.), request headers, and request body. Return parameters are the information returned by the server in response to the browser's request, including status codes, response headers, and response bodies. When the target crawling plugin detects a network request, it extracts the request parameters and return parameters and saves this information to the server's database or other storage media for later use.
[0091] Step S302: Obtain the simulation request initiated by the user through the simulation platform.
[0092] Furthermore, the simulation platform is a server-run software environment that provides a user interface and operation interface, allowing users to initiate simulated requests. Simulated requests are configured and initiated by the user on the simulation platform, designed to simulate real user behavior. Simulated requests can include specific URLs, request methods, request headers, and request bodies. The simulation platform receives the simulated request information input by the user and prepares to send it to a request interceptor for further processing.
[0093] Step S303: Based on the simulated request, read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information of the server, and send the historical request parameters and historical return parameters to the request interceptor.
[0094] Furthermore, historical information refers to the historical data of request and return parameters previously recorded and saved by the server through the target crawling plugin, stored in a database. When the simulation platform receives a simulated request, it searches the server's historical information for matching historical request and return parameters based on the content of the simulated request (such as URL, request method, etc.). Once a matching historical data is found, the simulation platform sends this data to the request interceptor to generate simulated data.
[0095] Step S304: The request interceptor generates simulated data based on the historical request parameters and the historical return parameters, and sends the simulated data as a return result to the simulation platform.
[0096] Furthermore, a request interceptor is a software component deployed on a server whose main function is to intercept and process simulated requests. Based on received historical request and response parameters, the request interceptor generates simulated data that matches the simulated request using a specific algorithm or logic. After generating the simulated data, the request interceptor sends this data as the return result to the simulation platform.
[0097] Step S305: Perform simulation operations based on the simulation data through the simulation platform.
[0098] Furthermore, simulated operations refer to a series of operations performed by the simulation platform based on received simulated data. These operations aim to simulate the behavior of real users and verify the functionality and performance of the interfaces. After receiving the simulated data, the simulation platform executes corresponding simulated operations according to the user's configuration and the content of the simulated request, such as simulating login and simulating data querying. The results of the simulated operations are displayed on the simulation platform's user interface for users to view and analyze.
[0099] In summary, this embodiment utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thereby significantly improving the efficiency of interface testing. Furthermore, this embodiment can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0100] This embodiment provides a device for automatically generating website interface test data. This device comprises… Figure 1 The client 110 executes the command, and the client 110 runs the target crawling plugin 111, such as... Figure 4 As shown, it includes:
[0101] The network request capture module 401 is used to monitor the network requests made by the browser in real time during the operation of the target capture plugin, and to identify and extract the request parameters and return parameters of the network request.
[0102] The parameter sending module 402 is used to send the request parameters and the return parameters to the server for recording and saving through the target capture plugin, so that when the server hears the user initiating a simulated request, it can read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information according to the simulated request, and generate simulated data based on the historical request parameters and historical return parameters, so as to execute the simulated operation according to the simulated data.
[0103] In some alternative implementations, the target crawling plugin is built based on the following steps:
[0104] Functional requirements for obtaining the data to be scraped;
[0105] Based on this functional requirement, the project structure for this target crawling plugin was built and written; the project structure includes manifest.json, background.js, popup.html, popup.js, options.html, and options.js files;
[0106] Based on the project structure, a target crawling plugin was built; this target crawling plugin is a Chrome extension.
[0107] In some alternative implementations, the network request capture module 401 is further configured to:
[0108] Authorize the target crawling plugin based on the manifest.json file;
[0109] After authorization is completed, the background.js file is used to monitor the browser's network requests in real time during runtime;
[0110] Determine the request type of the network request; the request type includes GET requests and POST requests;
[0111] If the request type of the network request is a GET request, then the request parameters of the network request are extracted based on the Uniform Resource Locator of the network request, and the return parameters of the network request are extracted based on the return header information of the network request.
[0112] If the request type of the network request is a POST request, then the request parameters of the network request are extracted based on the request body information, and the return parameters of the network request are extracted based on the return header information.
[0113] In some alternative implementations, the parameter sending module 402 is further configured to:
[0114] The target capture plugin organizes the captured request and return parameters according to the target format, and sends the organized request and return parameters to the server for recording and storage.
[0115] In summary, this embodiment utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thereby significantly improving the efficiency of interface testing. Furthermore, this embodiment can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0116] This embodiment provides another automatic website interface test data generation device, which consists of... Figure 1 The server 120 executes the command, and server 120 runs a simulation platform 121 and a request interceptor 122, such as... Figure 5 As shown, it includes:
[0117] The parameter recording module 501 is used to record and save the request parameters and return parameters sent by the target crawling plugin; the request parameters and return parameters are generated by the target crawling plugin in real time by monitoring the network requests of the browser during operation, and identifying and extracting the network requests.
[0118] The simulated request acquisition module 502 is used to acquire the simulated request initiated by the user through the simulation platform;
[0119] The historical record information reading module 503 is used to read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information of the server according to the simulated request, and send the historical request parameters and historical return parameters to the request interceptor.
[0120] The simulation data generation module 504 is used to generate simulation data based on the historical request parameters and the historical return parameters through the request interceptor, and send the simulation data as a return result to the simulation platform;
[0121] The simulation operation execution module 505 is used to perform simulation operations based on the simulation data through the simulation platform.
[0122] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0123] In summary, this embodiment utilizes a target crawling plugin to monitor network requests during browser operation in real time, accurately identifying and extracting request and return parameters. This avoids errors that may occur with manual data collection, ensuring the accuracy of test data and significantly saving test data preparation time. The server can generate simulated data based on historical request and return parameters, making the simulated data closer to actual business scenarios and improving the reliability of test results. This reduces the workload of testers repeatedly constructing test data, thereby significantly improving the efficiency of interface testing. Furthermore, this embodiment can adjust simulated requests at any time according to actual conditions, quickly obtaining corresponding simulated data for testing, improving the flexibility and adaptability of testing.
[0124] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 6 As shown, the computer device includes one or more processors 610, memory 620, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 6 Take the 610 processor as an example.
[0125] The processor 610 may be a central processing unit, a network processor, or a combination thereof. The processor 610 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0126] The memory 620 stores instructions executable by at least one processor 610 to cause the at least one processor 610 to perform the method shown in the above embodiments.
[0127] The memory 620 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 620 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 620 may optionally include memory remotely located relative to the processor 610, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0128] The memory 620 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 620 may also include a combination of the above types of memory.
[0129] The computer device also includes a communication interface 630 for communicating with other devices or communication networks.
[0130] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0131] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0132] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and all such modifications and variations fall within the defined scope.
Claims
1. A method for automatically generating website interface test data, characterized in that, The method is executed by a client, which runs a target crawling plugin, and the method includes: The target crawling plugin monitors the browser's network requests in real time during operation, identifies and extracts the request parameters and return parameters of the network requests; The target capture plugin sends the request parameters and the return parameters to the server for recording and storage. When the server detects a simulated request initiated by a user, it reads the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information, and generates simulated data based on the historical request parameters and historical return parameters, so as to execute the simulated operation according to the simulated data.
2. The method according to claim 1, characterized in that, The target crawling plugin is built based on the following steps: Functional requirements for obtaining the data to be scraped; Based on the aforementioned functional requirements, the project structure for the target crawling plugin is constructed and written; the project structure includes a manifest.json file, a background.js file, a popup.html file, a popup.js file, an options.html file, and an options.js file; Based on the project structure, the target crawling plugin was built; the target crawling plugin is a Chrome plugin.
3. The method according to claim 2, characterized in that, The step of monitoring network requests made by the browser in real time during operation through the target crawling plugin, and identifying and extracting the request parameters and return parameters of the network requests, includes: Authorize the target crawling plugin based on the manifest.json file; After authorization is completed, the browser's network requests during runtime are monitored in real time based on the background.js file. Determine the request type of the network request; the request type includes GET requests and POST requests; If the network request is a GET request, then the request parameters of the network request are extracted based on the Uniform Resource Locator (URL) of the network request, and the return parameters of the network request are extracted based on the return header information of the network request. If the network request is a POST request, then the request parameters of the network request are extracted based on the request body information, and the return parameters of the network request are extracted based on the return header information.
4. The method according to claim 1, characterized in that, The step of sending the request parameters and the return parameters to the server for recording and saving via the target crawling plugin includes: The target crawling plugin organizes the captured request parameters and return parameters according to the target format, and sends the organized request parameters and return parameters to the server for recording and storage.
5. A method for automatically generating website interface test data, characterized in that, The method is executed by a server, which runs a simulation platform and a request interceptor. The method includes: The request and return parameters sent by the target crawling plugin are recorded and saved; the request and return parameters are generated by the target crawling plugin in real time by monitoring the network requests of the browser during operation, and by identifying and extracting the network requests. The simulation request initiated by the user is obtained through the simulation platform; Based on the simulated request, the historical request parameters and historical return parameters corresponding to the simulated request are read from the historical record information of the server, and the historical request parameters and historical return parameters are sent to the request interceptor. The request interceptor generates simulated data based on the historical request parameters and the historical return parameters, and sends the simulated data as a return result to the simulation platform; The simulation platform performs simulation operations based on the simulation data.
6. The method according to claim 5, characterized in that, The step of generating simulated data based on the historical request parameters and the historical return parameters through the request interceptor includes: The request interceptor analyzes the historical request parameters and historical return parameters to simulate the actual network request processing process, and generates simulated data according to the target simulation algorithm.
7. A device for automatically generating website interface test data, characterized in that, The device is executed by a client, which runs a target crawling plugin. The device includes: The network request capture module is used to monitor the network requests made by the browser in real time during the operation of the target capture plugin, and to identify and extract the request parameters and return parameters of the network requests. The parameter sending module is used to send the request parameters and the return parameters to the server for recording and saving through the target capture plugin, so that when the server hears that the user has initiated a simulated request, it can read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information according to the simulated request, and generate simulated data based on the historical request parameters and historical return parameters, so as to execute the simulated operation according to the simulated data.
8. A device for automatically generating website interface test data, characterized in that, The process is executed by a server, which runs a simulation platform and a request interceptor. The device includes: The parameter recording module is used to record and save the request parameters and return parameters sent by the target crawling plugin; the request parameters and return parameters are generated by the target crawling plugin in real time by monitoring the network requests of the browser during operation, and identifying and extracting the network requests; The simulated request acquisition module is used to acquire the simulated request initiated by the user through the simulation platform; The historical record information reading module is used to read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information of the server according to the simulated request, and send the historical request parameters and historical return parameters to the request interceptor. The simulation data generation module is used to generate simulation data based on the historical request parameters and the historical return parameters through the request interceptor, and send the simulation data as a return result to the simulation platform; The simulation operation execution module is used to perform simulation operations based on the simulation data through the simulation platform.
9. A system for automatically generating website interface test data, characterized in that, The system includes a client and a server; the client runs a target crawling plugin, and the server runs a simulation platform and a request interceptor. The target crawling plugin is used to monitor network requests made by the browser in real time, identify and extract the request parameters and return parameters of the network requests, and send the request parameters and return parameters to the server for recording and storage. The simulation platform is used to obtain the simulated request initiated by the user, and according to the simulated request, read the historical request parameters and historical return parameters corresponding to the simulated request from the historical record information of the server, and send the historical request parameters and historical return parameters to the request interceptor. The request interceptor is used to generate simulated data based on the historical request parameters and the historical return parameters, and send the simulated data as a return result to the simulation platform; The simulation platform is also used to perform simulation operations based on the simulation data.
10. A computer device, characterized in that, include: The system includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes the computer instructions to perform a method for automatically generating website interface test data according to any one of claims 1 to 6.