A test method and apparatus
Patent Information
- Application Number
- CN202510510574.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2026-10-23
AI Technical Summary
现阶段测试的重点往往集中在后端的性能测试,而对前端页面的性能测试关注较少,就目前对前端页面的性能测试而言,通常仅限于对单个页面的进行性能评估,且不适用于评估流程化的交互测试场景(用户在页面中发生一系列流程化的交互动作)中页面所表现出的性能,即测试场景非常有限,测试准确性也不高
[0024]所述发明中的一个实施例具有如下优点或有益效果:通过将测试代码注入浏览器页面;测试代码包含用户与待测网站之间的交互流程的测试;设置多个测试用户,对于每个测试用户,通过在浏览器页面中执行测试代码包含的交互流程中的各个交互动作,获取待测网站中对应的各个网站页面的页面响应结果;根据各个页面响应结果计算得到每个测试用户对应的待测网站的各个网站页面的性能评分,综合各个性能评分得到待测网站的测试评分的技术方案,实现了多页面、准确率高的网站测试,通过模拟用户在待测网站中各个交互动作,不仅触发了各个网站页面的响应,获取到各个网站页面的页面响应结果;而且基于交互流程模拟用户的真实行为,获取到的页面响应结果也更准确客观;另外,基于多个测试用户的多用户测试,还实现了对待测网站的并发测试,进而达到丰富测试场景、提升测试准确率和实现并发测试的目的。
Smart Images

Figure CN122963932A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a testing method and apparatus. Background Technology
[0002] Performance testing is an indispensable and crucial part of software development. Its purpose is to verify whether a software system can meet the performance metrics specified by the user, and to identify performance bottlenecks for optimization. Currently, testing often focuses on backend performance, while frontend performance testing receives less attention. Even then, frontend performance testing is typically limited to evaluating the performance of individual pages and is unsuitable for assessing the performance of pages in procedural interactive scenarios (where users perform a series of sequential interactive actions). In other words, the testing scenarios are very limited, and the accuracy of the tests is not high. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a testing method and apparatus that achieves multi-page, high-accuracy website testing. By simulating various user interactions on the website under test, it not only triggers responses on each website page and obtains the page response results, but also, based on the interaction flow simulating real user behavior, the obtained page response results are more accurate and objective. In addition, multi-user testing based on multiple test users also enables concurrent testing of the website under test, thereby enriching the testing scenarios, improving testing accuracy, and achieving the purpose of concurrent testing.
[0004] To achieve the aforementioned objective, according to one aspect of the present invention, a testing method is provided, comprising:
[0005] Inject test code into the browser page; the test code contains tests of the interaction flow between the user and the website under test;
[0006] Multiple test users are set up. For each test user, the page response results of each corresponding website page in the test website are obtained by executing each interactive action in the interactive flow contained in the test code in the browser page.
[0007] The performance score of each website page of the website under test corresponding to each test user is calculated based on the response results of each page, and the test score of the website under test is obtained by combining the performance scores.
[0008] Optionally, by executing each interactive action in the interactive flow contained in the test code in the browser page, the page response results of each corresponding website page in the website under test are obtained, including: assigning a corresponding test service to each test user; for each test service: obtaining the website address from the test code; calling a specified access instruction based on the website address in the browser page to access the website under test; simulating the test user performing corresponding operations on the website under test according to the test steps of each interactive action in the interactive flow, and recording the page response results of the website page corresponding to each operation.
[0009] Optionally, the performance score of each website page corresponding to each test user on the website under test is calculated based on the response results of each page, including: collecting page state data from the response results of each page, and filtering out corresponding multi-dimensional page performance indicators from the page state data; for each website page of the website under test: dynamically determining the first weight corresponding to each page performance indicator using a pre-trained feature evaluation model; determining the second weight corresponding to each page performance indicator using causal analysis; determining the weight corresponding to each page performance indicator based on the first weight and the second weight; and calculating the performance score of the website page using a weighted fusion method based on each weight and the corresponding page performance indicator.
[0010] Optionally, the various interactive actions in the interactive flow included in the test code executed in the browser page are implemented based on a user interaction testing framework; the performance score is determined based on a page performance evaluation testing tool.
[0011] Optionally, injecting the test code into the browser page includes: using the translation and packaging function integrated in the test framework to translate and package each test file in the test code to generate an optimized test file; loading the optimized test file into the browser page; the browser page is a blank browser tab.
[0012] Optionally, before obtaining the page response results of each corresponding website page in the website under test by executing each interactive action in the interactive flow contained in the test code in the browser page, the method further includes: setting a network speed limit for the browser page so that the network environment of the browser page conforms to the real online environment.
[0013] Optionally, the acquisition of each page response result and the calculation of each performance score are processed in a multi-threaded manner; the method further includes: when the number of test users reaches a threshold, the test score of the website under test is a stress test score.
[0014] According to a second aspect of the present invention, a testing apparatus is provided, comprising:
[0015] The test code injection module is used to inject test code into a browser page; the test code contains tests on the interaction flow between the user and the website under test.
[0016] The response result acquisition module is used to set up multiple test users. For each test user, the module executes various interactive actions in the interactive flow contained in the test code on the browser page to obtain the page response results of each corresponding website page on the website under test.
[0017] The test scoring determination module is used to calculate the performance score of each website page of the website under test corresponding to each test user based on the response results of each page, and to obtain the test score of the website under test by combining the performance scores.
[0018] According to a third aspect of the present invention, a test electronic device is provided, comprising:
[0019] One or more processors;
[0020] Storage device for storing one or more programs.
[0021] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiments of the present invention.
[0022] According to a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect of the present invention.
[0023] According to a fifth aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method provided in the first aspect of the present invention.
[0024] One embodiment of the invention has the following advantages or beneficial effects: By injecting test code into a browser page; the test code includes testing of the interaction flow between the user and the website under test; setting up multiple test users, for each test user, by executing various interactive actions in the interaction flow contained in the test code in the browser page, the page response results of the corresponding website pages in the website under test are obtained; the performance score of each website page of the website under test corresponding to each test user is calculated based on the page response results, and the test score of the website under test is obtained by combining the various performance scores, a multi-page, highly accurate website testing is achieved. By simulating various interactive actions of users in the website under test, not only are the responses of each website page triggered and the page response results of each website page obtained; but also, based on the interaction flow simulating the user's real behavior, the obtained page response results are more accurate and objective; in addition, multi-user testing based on multiple test users also realizes concurrent testing of the website under test, thereby achieving the purpose of enriching test scenarios, improving test accuracy, and realizing concurrent testing. Attached Figure Description
[0025] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0026] Figure 1 This is a schematic diagram of the main flow of the testing method according to an embodiment of the present invention;
[0027] Figure 2 This is a flowchart of a test method according to a possible embodiment of the present invention;
[0028] Figure 3 This is a schematic diagram of the test process of the page performance evaluation-based test tool according to an embodiment of the present invention;
[0029] Figure 4 This is a flowchart of a test method according to another possible embodiment of the present invention;
[0030] Figure 5 This is a flowchart illustrating the multi-threaded processing of an embodiment of the present invention;
[0031] Figure 6 This is a schematic diagram of the overall process of testing the website under test according to an embodiment of the present invention;
[0032] Figure 7 This is a schematic diagram of the main modules of the testing device according to an embodiment of the present invention;
[0033] Figure 8 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0034] Figure 9This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0035] It should be noted that the collection, updating, analysis, use, transmission, and storage of user personal information involved in the technical solution of this invention all comply with relevant laws and regulations, are used for legitimate and reasonable purposes, and are not shared, disclosed, or sold outside of these legitimate uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken to selectively block the use or access to personal information data to prevent unauthorized access to such personal information data, ensure that personnel authorized to access personal information data comply with relevant laws and regulations, and ensure the security of user personal information. Furthermore, once this user personal information data is no longer needed, the risk should be minimized by restricting or even prohibiting data collection and / or deleting the data.
[0036] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0037] Currently, performance testing often focuses on backend performance testing, while less attention is paid to frontend page performance testing. As for frontend page performance testing, it is usually limited to performance evaluation of a single page and is not suitable for evaluating the performance of a page in a process-oriented interactive test scenario (where the user performs a series of process-oriented interactive actions on the page). In other words, the test scenarios are very limited and the test accuracy is not high.
[0038] To address the aforementioned problems in existing technologies, this invention proposes a testing method. Based on test code containing interactive flows, for each test user, the method executes various interactive actions within the flow in a browser page to obtain the page response results of each website page on the website under test. Then, based on these page response results, a test score for the website under test is calculated. This achieves multi-page, highly accurate website testing. By simulating various user interactions on the website under test, not only are responses triggered on each website page, obtaining their response results, but the page response results are also more accurate and objective because the interactive flow simulates real user behavior. Furthermore, multi-user testing based on multiple test users enables concurrent testing of the website under test, thereby enriching the testing scenarios, improving testing accuracy, and achieving concurrent testing.
[0039] Figure 1 This is a schematic diagram of the main flow of the testing method according to an embodiment of the present invention, as shown below. Figure 1 As shown, the testing method of this invention includes the following:
[0040] Step S101: Inject test code into the browser page; the test code contains tests on the interaction flow between the user and the website under test.
[0041] Specifically, existing performance testing often focuses on the backend, using scenarios such as simulating large data streams, weak networks, and offline operation to identify system performance bottlenecks. However, in practice, if the backend response time is halved, the overall response time can only be reduced by 5%-10%. In contrast, for frontend website performance testing, halving the frontend response time can reduce the overall response time by 40%-45%. Therefore, frontend website performance testing is more practically significant.
[0042] The website's test code primarily ensures that the website's webpage functionality, performance, user experience, and compatibility meet expected requirements. Accordingly, to simulate real user access to the website, the test code includes the interaction flow between the user and the test website, such as: user enters username and password → clicks login → redirects to the homepage; if password is incorrect → displays "Incorrect password". Considering that the website page construction process relies on a browser, the test code containing the user's interaction flow with the website under test is injected into the browser page so that the test code can run in the browser.
[0043] Step S102: Set up multiple test users. For each test user, execute each interactive action in the interactive flow contained in the test code on the browser page to obtain the page response results of each corresponding website page on the website under test.
[0044] According to one embodiment of the present invention, before obtaining the page response results of each corresponding website page in the website under test by executing each interactive action in the interactive flow contained in the test code in the browser page, the method further includes: setting the network speed limit of the browser page so that the network environment of the browser page conforms to the real online environment.
[0045] Specifically, considering the testing of front-end websites, the high performance of the host browser page might mask real-world issues. For example, the test network environment might be configured with a high-speed network (gigabit fiber optic), while real users might be using a slow network. This would result in the page loading speed being very fast during testing, but the actual loading speed experienced by users would generally be slow or even slower, leading to discrepancies between test results and reality. Therefore, before testing, it's necessary to set network speed limits for the browser page, forcing it to run under the same online network environment as real users. This ensures that all tests run under the same network conditions, making it easier to discover potential performance issues, such as resource loading blockages and slow rendering speeds.
[0046] Furthermore, to simulate more realistic website visits, this embodiment of the invention sets up multiple test users, simulating multiple test users executing various interaction actions with the website under test contained in the test code through browser pages, such as page redirection actions to query payment records, and the aforementioned login redirection actions. These interaction actions typically trigger corresponding pages on the website, and the test unit obtains the response results of each website page in response to the interaction actions by monitoring the website under test.
[0047] Step S103: Calculate the performance score of each website page of the website to be tested for each test user based on the response results of each page, and combine the performance scores to obtain the test score of the website to be tested.
[0048] Specifically, based on the above simulation of multiple test users accessing the website under test, the page response results of each website page are obtained. Each test user corresponds to a series of page response results on the website under test. The page response results contain rich page status information, providing the necessary data foundation for evaluating page performance. For each test user, necessary data is extracted from the page response results of their corresponding website pages, and the extracted data is used to calculate the performance score of each website page. Specifically, a score mapping method can be used, where the corresponding performance score is obtained by querying a score lookup table based on the specific data.
[0049] For example, if the page response time of website page 1 obtained from the page response results of test user A is 3 seconds, and the score corresponding to 3 seconds is 8 points (out of 10) is retrieved from the score lookup table, then the performance score of website page 1 is 8 points.
[0050] Finally, taking website pages as the dimension, the performance scores of the same website pages from all test users are combined to obtain the performance score of each website page. These performance scores are then combined to obtain the overall test score of the website under test. The specific calculation can use methods such as averaging, summation, or weighted summation; the specific calculation method in this embodiment is not limited. For example, if test user A's website page 1 has a performance score of 7 and website page 2 has a performance score of 8; and test user B's website page 1 has a performance score of 8 and website page 2 has a performance score of 8, then using the averaging method, the performance score of website page 1 for both test users A and B is calculated to be 7.5, and the performance score of website page 2 is 8. Therefore, the final test score of the website is 7.75.
[0051] Alternatively, test users can be used as a comprehensive dimension. First, the performance scores of each website page corresponding to each test user can be calculated to obtain the test score of the website to be tested for each test user. Finally, the test scores of the websites to be tested for each test user can be combined to obtain the final test score of the website to be tested.
[0052] This invention simulates various test users accessing a website under test, monitors and obtains the page response results of each page on the website under test, and then calculates the test score of the website under test based on the page response results. This achieves multi-page, high-accuracy website testing. By simulating the various interactive actions of multiple users on the website under test, it not only triggers the response of each website page and obtains the page response results, but also simulates the real behavior of multiple users based on the interaction process, resulting in more accurate and objective page response results.
[0053] Figure 2 This is a flowchart of a test method according to one possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 2 As shown, the test method may include:
[0054] Step S201: Inject test code into the browser page; the test code contains tests on the interaction flow between the user and the website under test.
[0055] Step S202: Set up multiple test users and assign corresponding test services to each test user.
[0056] Specifically, in order to facilitate management, reuse, and expansion, and to facilitate the subsequent statistics and maintenance of the response results of each website page by the testing unit, the embodiments of the present invention use service abstraction to assign a corresponding exclusive testing service to each testing user, with one testing user corresponding to one testing service.
[0057] Step S203: For each test service: Obtain the website address from the test code, and access the website under test by calling the specified access command based on the website address in the browser page; simulate the test user to perform corresponding operations on the website under test according to the test steps of each interactive action in the interaction process, and record the page response results of the website page corresponding to each operation.
[0058] Specifically, the test unit parses the test code to obtain the website address contained within it. This website address is the address of the website under test in this embodiment of the invention. Using the website address as a parameter for the access command, the test unit simulates a test user accessing the website under test by calling this access command in the browser page. Then, following the test steps of each interactive action included in the interaction flow in the test code, the test unit simulates a test user performing operations corresponding to each interactive action on the website under test, and listens to and obtains the page response results of the corresponding website page triggered by each operation.
[0059] Step S204: Collect page status data from each page response result, and filter out the corresponding multi-dimensional page performance indicators from each page status data.
[0060] Specifically, considering that the page response results contain various page-related information, to facilitate subsequent page performance evaluation, page state data related to page performance evaluation is first collected from each page response result. Since page performance is typically evaluated around dimensions such as loading performance, resource optimization, runtime performance, and caching, for each page response result, this embodiment of the invention filters out page performance indicators of different dimensions from its corresponding page state data. Specific page performance indicators may include three dimensions: website page response time, website page loading time, and whether there is layout offset during website page loading. Of course, other page performance indicators can also be selected according to the focus of the test; this embodiment of the invention does not impose specific limitations.
[0061] Step S205: For each page of the website to be tested: dynamically determine the first weight corresponding to each page performance indicator using a pre-trained feature evaluation model; determine the second weight corresponding to each page performance indicator using causal analysis; determine the weight corresponding to each page performance indicator based on the first weight and the second weight; calculate the performance score of the website page using a weighted fusion method based on each weight and the corresponding page performance indicator.
[0062] Specifically, since the test unit simulates each test user executing test code, this embodiment of the invention takes one test user as an example. After operating the website under test according to the interaction flow, the user will receive response results from multiple website pages in sequence. For each website page's response result, there are multiple dimensions of page performance indicators, such as the website page's response time, website page loading time, and whether there is layout offset during website page loading. Therefore, the performance score of the website page needs to comprehensively consider multiple dimensions of page performance indicators.
[0063] To calculate website page performance scores more objectively and accurately, this invention employs two weighting methods to jointly calculate the scores. Since various page performance metrics are essentially feature data for a website page, the importance of each metric varies, and this difference is often influenced by other factors. Therefore, this invention uses a dynamic weighting method to determine the first weight. A pre-trained feature evaluation model (e.g., random forest) is used to dynamically evaluate the current importance of each page performance metric to the website page, and the first weight corresponding to each metric is assigned based on its importance.
[0064] Simultaneously, establish causal relationships between various page performance metrics and website pages, call causal inference libraries (such as the DoWhy library), identify page performance metrics that are indeed causally related to website pages, and determine the second weight corresponding to each page performance metric based on the true or false causal relationship between each page performance metric and website pages.
[0065] Furthermore, for each page performance metric, its corresponding first and second weights are combined to obtain its corresponding weight. This combination can be achieved through direct summation, weighted summation, product, or weighted product. Finally, based on the weights of each page performance metric calculated comprehensively, and combined with the metric score corresponding to each page performance metric calculated from its specific numerical value, a comprehensive performance score representing the website page is calculated using a weighted fusion method. It is understood that the fusion in this embodiment of the invention can be summation, product, or a combination of summation and product, selected according to specific calculation requirements.
[0066] Step S206: Combine the various performance scores to obtain the test score of the website under test.
[0067] This invention discloses a specific implementation method for simulating a test user's access to a website under test and obtaining multi-dimensional page performance indicators during the operation of the website under test according to the interaction flow in the test code. It also proposes a weight determination method that combines dynamic weight and causal analysis weight, which effectively improves the accuracy of the website page performance score, thereby ensuring the accuracy of subsequent test scores and guaranteeing the test quality.
[0068] To further improve testing efficiency and make full use of existing resources, according to an embodiment of the present invention, the various interactive actions in the interactive flow contained in the test code executed in the browser page are implemented based on a user interaction testing framework; the performance score is determined based on a page performance evaluation testing tool.
[0069] Specifically, given that the performance evaluation test of multiple pages on a website in this embodiment of the invention mainly obtains more accurate page response results by simulating test users accessing the website under test, and then calculates the test score of the website under test based on the response results of each page, the testing unit can improve efficiency by calling a testing framework specifically designed for user interaction testing to simulate test users accessing the website under test. Examples include the Cypress testing framework, primarily used for end-to-end user interaction testing, or the Selenium testing framework. The testing unit only needs to monitor the response results of each website page when calling the testing framework to simulate test users accessing the website under test, effectively improving testing efficiency.
[0070] Furthermore, the testing unit can also use page performance evaluation tools to calculate the test score, such as Lighthouse or PageSpeed Insights, which are used to evaluate webpage quality and performance. The testing unit synchronizes the monitored page response results to the testing tool, uses the tool to evaluate and score the website pages, and finally obtains the test score of the website under test.
[0071] Figure 3This is a schematic diagram of the testing process of the page performance evaluation testing tool according to an embodiment of the present invention. Taking the Lighthouse testing tool mentioned above as an example, Lighthouse is a single-page page performance evaluation tool. Lighthouse establishes a connection with the browser page, the browser page sends a network request to the service cluster, the service cluster retrieves data information from the database according to the network request and responds, and the browser parses and renders the received data information to load the front-end page. During the front-end page loading process, Lighthouse runs a collector to collect the necessary page state data from the front-end page. Lighthouse then runs a series of audit items, each of which filters page performance indicators used to evaluate page performance from the page state data, and then calculates the performance score of the front-end page based on the page performance indicators and generates a report. The report supports saving in HTML and JSON formats.
[0072] Figure 4 This is a flowchart of a test method according to another possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 4 As shown, the test method may include:
[0073] Step S401: Using the translation and packaging function integrated in the test framework, translate and package each test file in the test code to generate an optimized test file; load the optimized test file into the browser page; the browser page is a blank browser tab; the test code contains tests of the interaction process between the user and the website under test.
[0074] Specifically, considering that this embodiment of the invention calls a testing framework to simulate the interaction between a test user and the website under test, it is necessary to ensure that the test code can be recognized by the testing framework. Therefore, it is necessary to utilize the transpilation and bundling function integrated in the testing framework. For example, for the Cypress testing framework, its integrated code bundling tool webpack is used. By transpiling each test file in the test code into syntax recognized by the testing framework, such as converting TypeScript to JavaScript, and bundling all the test files in the test code into a single js file, an optimized test file is generated. This optimized test file is then loaded into a blank browser tab. A blank browser tab refers to a clean browser tab with no cache and no history, equivalent to the initial state when the user first opens the browser.
[0075] This invention utilizes a testing framework to simulate user access to the website under test. The framework's translation and packaging capabilities are leveraged to adapt the test code to the framework, improving testing efficiency. Simultaneously, optimized test files are loaded into a blank browser tab, preventing contamination of the test environment by the website's original records. This ensures dynamic loading of optimized test files in a clean environment, avoiding inaccurate test results due to caching or historical data, and guaranteeing test consistency.
[0076] Step S402: Set up multiple test users, call the user interaction test framework, and obtain the page response results of each corresponding website page in the website under test.
[0077] Specifically, the test unit calls a user interaction testing framework (such as Cypress or Selenium) to simulate various test users accessing the website under test, and listens to the page response results of each website page during the execution of the test framework.
[0078] Step S403: Based on the response results of each page, call the page performance evaluation test tool to calculate the performance score of each website page of the website under test corresponding to each test user, and combine the performance scores to obtain the test score of the website under test.
[0079] Specifically, the testing unit synchronously inputs the obtained page response results into a performance evaluation tool (such as Lighthouse or PageSpeed Insights). Using the tool's internal performance scoring logic, it calculates the performance score for each page of the website under test for each test user. Finally, the performance scores of all website pages are combined to obtain the overall test score for the website under test.
[0080] According to one embodiment of the present invention, the acquisition of each page response result and the calculation of each performance score are processed in a multi-threaded manner; the method further includes: when the number of test users reaches a number threshold, the test score of the website under test is a stress test score.
[0081] Specifically, given that the test objects in this embodiment of the invention are multiple website pages of the website under test, in order to further improve testing efficiency, a corresponding thread is allocated to each website page to achieve multi-threaded parallel computing. Furthermore, the number of test users in this embodiment of the invention can also be expanded. Based on a preset threshold for the number of stress tests on the website under test, when the number of test users reaches the preset threshold, the test on the website under test is considered a stress test, and the final test score is the stress test score.
[0082] Understandably, the number of test users can also be used to test the performance of the website under test under different concurrency levels. Therefore, embodiments of the present invention also support testing the performance scores of each website page of the website under test under different concurrency levels according to preset different numbers of users, thereby obtaining the test scores of the website under test under different concurrency levels.
[0083] Figure 5 This is a flowchart illustrating the multi-threaded processing of an embodiment of the present invention. In the diagram, N test users correspond to N service nodes. A testing framework is used to simulate test users accessing the website under test. Each test user executes the interaction flow in the test code, triggering M website pages (pages 1 to M in the diagram). Correspondingly, M threads are called to monitor the page response results of the corresponding website pages. Then, M performance scores are calculated based on the M page response results, such as scoreA1, scoreA2, ..., scoreAM for service node A in the diagram. Finally, the M performance scores of each test user are combined to obtain the test score of the website under test.
[0084] Figure 6 This is a schematic diagram illustrating the overall process of testing the website under test according to an embodiment of the present invention. The testing unit deploys a test environment container, assigning a corresponding service node to each test user, as shown in the diagram (service node A, service node B, ..., service node N). The testing framework simulates each test user sending requests to the service cluster to access the website under test via access commands, and obtains the responses from the service cluster. The testing unit monitors the page response results of the website pages, obtaining the page response results for each service corresponding to each website page. The testing unit synchronizes each page response result in real time to a page performance evaluation-based testing tool (e.g., Lighthouse). Utilizing the professional page performance evaluation capabilities of the testing tool, it calculates the performance score of each website page under test, and finally combines all performance scores to obtain the test score of the website under test. This diagram mainly illustrates when different numbers of concurrent test users are set. In this case, the testing tool calculates the performance score of each website page under different concurrency levels, and the final test score of the website under test is a combination of test scores under different concurrency levels.
[0085] To improve testing efficiency, this invention integrates a user interaction testing framework and a page performance evaluation tool to test the website under test. It fully utilizes the simulated interaction testing capabilities of the testing framework and the page performance evaluation capabilities of the testing tool. Furthermore, a blank browser tab is used to avoid historical data contamination of the testing environment. Additionally, multi-user testing based on multiple test users enables concurrent testing of the website under test. As the number of test users expands, this solution can also be used for stress testing of the website under test, thus expanding its application scenarios.
[0086] Figure 7 This is a schematic diagram of the main modules of a testing apparatus according to an embodiment of the present invention. Figure 7 As shown, the testing device 700 mainly includes a test code injection module 701, a response result acquisition module 702, and a test score determination module 703.
[0087] The test code injection module 701 is used to inject test code into a browser page; the test code contains tests on the interaction flow between the user and the website under test.
[0088] The response result acquisition module 702 is used to set up multiple test users. For each test user, the page response results of each corresponding website page in the test website are obtained by executing each interactive action in the interactive flow contained in the test code in the browser page.
[0089] The test scoring determination module 703 is used to calculate the performance score of each website page of the website under test corresponding to each test user based on the response results of each page, and to obtain the test score of the website under test by combining the performance scores.
[0090] According to an embodiment of the present invention, the response result acquisition module 702 is further configured to: assign a corresponding test service to each test user; for each test service: obtain a website address from the test code; access the website to be tested by calling a specified access instruction based on the website address in the browser page; simulate the test user to perform corresponding operations on the website to be tested according to the test steps of each interactive action in the interaction process, and record the page response results of the website page corresponding to each operation.
[0091] According to another embodiment of the present invention, the test scoring determination module 703 is further configured to: collect page state data from each page response result, and filter out corresponding multi-dimensional page performance indicators from each page state data; for each website page of the website to be tested: dynamically determine the first weight corresponding to each page performance indicator using a pre-trained feature evaluation model; determine the second weight corresponding to each page performance indicator using causal analysis; determine the weight corresponding to each page performance indicator based on the first weight and the second weight; and calculate the performance score of the website page using a weighted fusion method based on each weight and the corresponding page performance indicator.
[0092] According to another embodiment of the present invention, the various interactive actions in the interactive flow included in the test code executed in the browser page are implemented based on a user interaction testing framework; the performance score is determined based on a page performance evaluation testing tool.
[0093] According to another embodiment of the present invention, the test code injection module 701 is further configured to: use the translation and packaging function integrated in the test framework to translate and package each test file in the test code to generate an optimized test file; load the optimized test file into the browser page; the browser page is a blank browser tab.
[0094] According to another embodiment of the present invention, the testing device 700 further includes a speed limiting module (not shown in the figure), which is used to: set the network speed limit of the browser page before obtaining the page response results of each corresponding website page in the website under test by executing each interactive action in the interactive flow contained in the test code in the browser page, so as to make the network environment of the browser page conform to the real online environment.
[0095] According to another embodiment of the present invention, the acquisition of each page response result and the calculation of each performance score are processed in a multi-threaded manner; the testing device 700 further includes a load testing module (not shown in the figure), which is used to: when the number of test users reaches a number threshold, the test score of the website under test is the load testing score.
[0096] Figure 8 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied.
[0097] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, and 803, a network 804, and a server 805. Network 804 serves as the medium for providing communication links between terminal devices 801, 802, and 803 and server 805. Network 804 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0098] Users can use terminal devices 801, 802, and 803 to interact with server 805 via network 804 to receive or send messages, etc. Various communication client applications, such as test applications, can be installed on terminal devices 801, 802, and 803 (for example only).
[0099] Terminal devices 801, 802, and 803 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0100] Server 805 can be a server providing various services, such as a backend management server supporting tests conducted by users using terminal devices 801, 802, and 803 (for example only). Terminal devices 801, 802, and 803 can inject test code into a browser page; the test code includes tests of the interaction flow between the user and the website under test; multiple test users are set up, and for each test user, by executing various interactive actions in the interaction flow contained in the test code in the browser page, the page response results of each corresponding website page in the website under test are obtained; based on each of the page response results, a performance score of each website page of the website under test corresponding to each test user is calculated, and the test score of the website under test is obtained by combining the various performance scores, and the processing results (such as the test score, etc. - for example only) are fed back to the terminal devices.
[0101] It should be understood that Figure 8 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0102] The following is for reference. Figure 9 , Figure 9 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Figure 9 The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0103] like Figure 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 902 or programs loaded from storage section 908 into random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the system 900. The CPU 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0104] The following components are connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 910 as needed so that computer programs read from it can be installed into storage section 908 as needed.
[0105] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by central processing unit (CPU) 901, it performs the functions defined above in the system of this invention.
[0106] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0107] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0108] The units described in the embodiments of the present invention can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor can be described as including: a test code injection module, a response result acquisition module, and a test score determination module.
[0109] In some cases, the names of these modules do not constitute a limitation on the module itself. For example, a test code injection module can also be described as "a module for injecting test code into a browser page; the test code contains tests of the interaction flow between the user and the website under test".
[0110] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include: injecting test code into a browser page; the test code containing a test of the interaction flow between a user and a website under test; setting up multiple test users, and for each test user, obtaining page response results of corresponding website pages in the website under test by executing various interactive actions in the interaction flow contained in the test code in the browser page; calculating a performance score for each website page of the website under test corresponding to each test user based on the page response results, and combining the various performance scores to obtain a test score for the website under test.
[0111] The technical solution of the present invention has the following advantages or beneficial effects: by injecting test code into a browser page; the test code includes testing of the interaction flow between the user and the website under test; setting up multiple test users, for each test user, by executing each interactive action in the interaction flow included in the test code in the browser page, obtaining the page response results of each corresponding website page in the website under test; calculating the performance score of each website page of the website under test corresponding to each test user based on the page response results, and combining the various performance scores to obtain the test score of the website under test, the technical solution realizes multi-page, high-accuracy website testing. By simulating various interactive actions of users in the website under test, not only are the responses of each website page triggered and the page response results of each website page obtained; but also, based on the interaction flow simulating the user's real behavior, the obtained page response results are more accurate and objective; in addition, multi-user testing based on multiple test users also realizes concurrent testing of the website under test, thereby achieving the purpose of enriching test scenarios, improving test accuracy, and realizing concurrent testing.
[0112] The specific embodiments described herein do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A testing method, characterized in that, include: Inject test code into the browser page; the test code contains tests of the interaction flow between the user and the website under test; Multiple test users are set up. For each test user, the page response results of each corresponding website page in the test website are obtained by executing each interactive action in the interactive flow contained in the test code in the browser page. The performance score of each website page of the website under test corresponding to each test user is calculated based on the response results of each page, and the test score of the website under test is obtained by combining the performance scores.
2. The method according to claim 1, characterized in that, By executing the various interactive actions in the interactive flow contained in the test code on the browser page, the page response results of the corresponding website pages in the website under test are obtained, including: Assign a corresponding test service to each test user. For each test service: Obtain the website address from the test code, and access the website under test by calling the specified access command based on the website address in the browser page; According to the test steps of each interactive action in the interaction process, the test user is simulated to perform corresponding operations on the website under test, and the page response results of the website page corresponding to each operation are recorded.
3. The method according to claim 1, characterized in that, Based on the response results of each page, a performance score for each website page of the website under test corresponding to each test user is calculated, including: Collect page status data from the response results of each page, and filter out the corresponding multi-dimensional page performance indicators from the page status data. For each page of the website to be tested: The first weight corresponding to each page performance metric is dynamically determined using a pre-trained feature evaluation model. The second weight corresponding to each of the page performance metrics was determined using causal analysis. Based on the first weight and the second weight, determine the weight corresponding to each of the page performance metrics; The performance score of the website page is calculated by weighted fusion based on each weight and the corresponding page performance index.
4. The method according to claim 1, characterized in that, The various interactive actions in the interactive flow included in the execution of the test code on the browser page are implemented based on a user interaction testing framework; the performance score is determined based on a page performance evaluation testing tool.
5. The method according to claim 4, characterized in that, Inject test code into the browser page, including: Using the translation and packaging function integrated in the test framework, each test file in the test code is translated and packaged to generate optimized test files; The optimized test file is loaded into the browser page; the browser page is a blank browser tab.
6. The method according to claim 1, characterized in that, Before obtaining the page response results of each corresponding website page in the website under test by executing each interactive action in the interactive flow contained in the test code in the browser page, the method further includes: Set network speed limits for the browser page to make the network environment of the browser page match the real online environment.
7. The method according to claim 1, characterized in that, The acquisition of each page response result and the calculation of each performance score are processed using a multi-threaded approach. The method further includes: When the number of test users reaches the threshold, the test score of the website under test is the stress test score.
8. A testing device, characterized in that, include: The test code injection module is used to inject test code into the browser page; the test code contains tests on the interaction flow between the user and the website under test. The response result acquisition module is used to set up multiple test users. For each test user, the module executes various interactive actions in the interactive flow contained in the test code on the browser page to obtain the page response results of each corresponding website page on the website under test. The test scoring determination module is used to calculate the performance score of each website page of the website under test corresponding to each test user based on the response results of each page, and to obtain the test score of the website under test by combining the performance scores.
9. A mobile electronic device terminal, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.