Front-end test method and device, electronic equipment and nonvolatile storage medium

By automatically generating front-end test scripts through natural language processing and optimizing test cases by combining historical data, the problem of low efficiency in generating front-end test scripts has been solved, achieving efficient test coverage and resource utilization, and improving test quality and efficiency.

CN120973674APending Publication Date: 2025-11-18CHINA TELECOM INTELLIGENT NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511079638.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-01
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing technologies often result in low efficiency in generating front-end test scripts and difficulty in covering complex scenarios, leading to low test quality and efficiency, and increasing testing costs and maintenance difficulty.

Method used

The test requirement text is parsed using natural language processing technology, test scripts are automatically generated, and test cases are optimized by combining historical test data. It supports parallel execution and intelligent scheduling across multiple browsers and generates compatibility reports.

Benefits of technology

It improved the efficiency of test script generation, ensured test scenario coverage, reduced the time and error rate of manual script writing, improved test coverage and resource utilization, and shortened test time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973674A_ABST
    Figure CN120973674A_ABST
Patent Text Reader

Abstract

The invention discloses a front-end testing method and device, electronic equipment and a nonvolatile storage medium. The method comprises the following steps: acquiring a test demand text, and performing semantic analysis on the test demand text to obtain key test information; according to the key test information and page structure information of the target front-end webpage, an initial test script is determined, the test script comprises a plurality of test cases, and the test cases are used for simulating various operation scenes of a user on the target front-end webpage; according to the historical test data, the test case in the initial test script is optimized, a target test script is obtained, and the test scene coverage degree of the target test script is higher than that of the initial test script; and executing the target test script to test the target front-end webpage to obtain a test result. The technical problems that in the prior art, the generation efficiency of the front-end test script is low, and complex scenes are difficult to cover are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of front-end automated testing technology, and more specifically, to a front-end testing method, apparatus, electronic device, and non-volatile storage medium. Background Technology

[0002] In today's digital age, the development of web front-end applications is progressing rapidly, with their complexity and scale constantly increasing. Front-end automated testing, as a crucial means of ensuring software quality, faces numerous challenges. The testing methods and technical systems in related technologies have revealed many limitations and shortcomings. These shortcomings not only constrain testing quality and efficiency but also increase testing costs and maintenance difficulty. Specifically, the writing of front-end test scripts in related technologies often relies on test engineers with strong technical backgrounds manually writing test scripts. This process is tedious and prone to errors. Furthermore, manually designed test scenarios are often based on personal experience, making it difficult to comprehensively cover all possible business processes and boundary conditions. This leads to potential defects being overlooked during the testing phase, affecting the final quality of the software.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This application provides a front-end testing method, apparatus, electronic device, and non-volatile storage medium to at least solve the technical problems of low generation efficiency and difficulty in covering complex scenarios in the related art.

[0005] According to one aspect of the embodiments of this application, a front-end testing method is provided, comprising: acquiring test requirement text and performing semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on a target front-end webpage; determining an initial test script based on the key test information and the page structure information of the target front-end webpage, wherein the test script contains multiple test cases, and the test cases are used to simulate various operation scenarios of users on the target front-end webpage; optimizing the test cases in the initial test script based on historical test data to obtain a target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script; and executing the target test script to test the target front-end webpage and obtain test results.

[0006] Optionally, the key test information includes: test target information, test step information, and expected test result information. Based on the key test information and the page structure information of the target front-end webpage, determining the initial test script includes: determining the test script framework corresponding to the key test information, wherein the test script framework is used to define the structure and execution flow of test cases; generating a syntax logic tree corresponding to the key test information, and generating operation test statements based on the syntax logic tree and page structure information, wherein the syntax logic tree is used to represent the logical relationships and execution order between test steps; and integrating the operation test statements into the test script framework to obtain the initial test script.

[0007] Optionally, optimizing the test cases in the initial test script based on historical test data to obtain the target test script includes: analyzing and checking the scenario coverage of the test cases in the initial test script based on historical test data to identify uncovered test scenarios. Historical test data includes historical test cases and defect reports. The analysis and check include at least one of the following: checking whether the test cases cover all functionalities of the target front-end webpage, checking whether the test cases cover all boundary conditions, and checking whether the test cases cover all user operation paths; generating new test cases corresponding to the identified uncovered test scenarios and adding the new test cases to the initial test script to obtain candidate test scripts; determining the similarity between different test cases in the candidate test scripts and filtering out redundant test cases in the candidate test scripts based on the similarity to obtain the target test script.

[0008] Optionally, each test case contains a series of test steps; based on similarity, redundant test cases in the candidate test scripts are filtered out to obtain the target test script, including: extracting feature information of the test cases and vectorizing the feature information to obtain the feature vectors corresponding to the test cases, wherein the feature information includes a series of test steps contained in the test cases; determining the similarity parameters between each pair of feature vectors of the test cases in the initial test script, wherein the similarity parameters are used to characterize the degree of similarity between the test cases; if the similarity parameters between two test cases exceed a preset similarity threshold, the two test cases are merged or one of the two test cases is deleted.

[0009] Optionally, executing the target test script includes: determining the load status of the worker nodes in the test system and the task priority of each task in the task set, wherein the task set contains test tasks, which are used to execute the target test script on the worker nodes; determining the probability of the worker nodes executing the test tasks based on the task priority and load status, and determining at least one worker node to execute the test tasks based on the probability; and distributing the target test script to the worker nodes to execute the test tasks in parallel on at least one worker node.

[0010] Optionally, distributing the target test script to worker nodes and executing the test task in parallel on at least one worker node includes: executing the test task through multiple different browsers on each worker node to test the compatibility of the target front-end webpage on different browsers; collecting test data during the test process, wherein the test data includes at least one of the following: webpage screenshots during the test process, log information, performance indicators, performance indicators including at least one of the following: processor utilization, memory usage, log information including at least one of the following: operation steps, exception information, execution time of the test task on the worker node, the execution time being determined by page load time and operation response time.

[0011] Optionally, the method further includes: obtaining the test results of the target test script at each working node, wherein the test results are used to characterize at least the number of test cases that passed the test at the working node in the target test script; analyzing the failure reasons of the test cases that failed based on the test results and test data, generating a test report corresponding to the target front-end webpage based on the failure reasons, and sending the test report to the front-end interactive interface for display.

[0012] According to another aspect of the embodiments of this application, a front-end testing apparatus is also provided, comprising: a key information extraction module, used to acquire test requirement text and perform semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage; an initial script generation module, used to determine an initial test script based on the key test information and the page structure information of the target front-end webpage, wherein the test script contains multiple test cases, and the test cases are used to simulate various operation scenarios of users on the target front-end webpage; a script optimization and adjustment module, used to optimize the test cases in the initial test script based on historical test data to obtain a target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script; and a script execution testing module, used to execute the target test script to test the target front-end webpage and obtain test results.

[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the program executes a front-end testing method during runtime.

[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes a front-end testing method by running the computer program.

[0015] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of a front-end testing method.

[0016] In this embodiment, the method involves acquiring test requirement text and performing semantic analysis to obtain key test information. This key test information characterizes the functional points and test steps that need to be tested on the target front-end webpage. Based on the key test information and the page structure information of the target front-end webpage, an initial test script is determined. This test script contains multiple test cases that simulate various user operation scenarios on the target front-end webpage. Based on historical test data, the test cases in the initial test script are optimized to obtain a target test script. The target test script has higher test scenario coverage than the initial test script. The target test script is then executed to test the target front-end webpage and obtain test results. By parsing test requirements using natural language processing technology and automatically generating test scripts, the time and errors of manually writing scripts can be reduced. Furthermore, the test case optimization mechanism driven by historical data can dynamically adjust the test strategy to ensure test coverage. This solves the technical problems of low efficiency in generating front-end test scripts and difficulty in covering complex scenarios in related technologies. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a front-end testing method according to an embodiment of this application;

[0019] Figure 2 This is a schematic diagram of a front-end testing method flow provided according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of a system architecture and overall process for front-end automated testing according to an embodiment of this application;

[0021] Figure 4 This is a schematic diagram of the operation flow of a front-end automated test according to an embodiment of this application;

[0022] Figure 5 This is a schematic diagram of the process of a test script adaptive generation module according to an embodiment of this application;

[0023] Figure 6This is a schematic diagram of the process of a task intelligent scheduling module provided according to an embodiment of this application;

[0024] Figure 7 This is a schematic diagram of the process of a cross-browser execution and result collection module according to an embodiment of this application;

[0025] Figure 8 This is a schematic diagram of the structure of a front-end testing device provided according to an embodiment of this application. Detailed Implementation

[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0028] To facilitate a better understanding of the embodiments of this application by those skilled in the art, some technical terms or nouns involved in the embodiments of this application are explained as follows:

[0029] Natural Language Processing (NLP) is an important research direction in the field of artificial intelligence. It integrates knowledge from multiple disciplines such as linguistics, computer science, machine learning, mathematics, and cognitive psychology. It is an interdisciplinary field that combines computer science, artificial intelligence, and linguistics, encompassing two main aspects: natural language understanding and natural language generation. Its research content includes multiple levels such as characters, words, phrases, sentences, paragraphs, and texts, serving as a bridge between machine language and human language. Its aim is to enable machines to understand, interpret, and generate human language, achieving effective communication between humans and machines, and enabling computers to perform tasks such as language translation, sentiment analysis, and text summarization.

[0030] Playwright is an open-source automated testing framework primarily used for end-to-end (E2E) testing, supporting automation in modern browsers such as Chromium, Firefox, and WebKit. It helps developers efficiently write cross-browser test scripts by providing a unified API, ensuring the functional consistency of web applications across different environments.

[0031] The testing methods and technical systems in related technologies have revealed numerous limitations and shortcomings. These shortcomings not only restrict testing quality and efficiency but also increase testing costs and maintenance difficulty. Specifically, the technical challenges of related technologies mainly focus on the following aspects:

[0032] 1) High testing threshold: Traditional front-end automated testing requires testers to have solid programming skills and write complex and error-prone test scripts, which makes it difficult for non-technical personnel to participate in testing work, limiting the size and efficiency of the testing team.

[0033] 2) Low test coverage: Test scenarios that rely on testers’ experience and are manually designed are difficult to cover all possible business scenarios and boundary conditions, making it difficult to discover potential problems and affecting software quality.

[0034] 3) Poor adaptability: Frequent changes to front-end page elements and business logic make traditional test scripts prone to failure, requiring a lot of manpower for maintenance and updates, which increases testing costs and risks.

[0035] 4) Insufficient depth of analysis: Traditional test reports only provide simple information on whether a test passed or failed, making it difficult to delve into the reasons behind the problems and failing to provide valuable decision-making support for the development team.

[0036] 5) Low utilization of test resources: When faced with a large number of test tasks, traditional single-machine testing methods cannot make full use of computing resources, resulting in long test times and low efficiency.

[0037] To address the aforementioned issues, this application provides a solution that automatically converts test requirements into structured test scripts using a natural language parsing engine and integrates reinforcement learning algorithms to analyze historical data and defect information. This intelligently optimizes test cases and supplements missing scenarios, supports cross-platform parallel execution across various mainstream browsers, and generates compatibility comparison reports. Furthermore, during test script execution, the Celery distributed task queue enables intelligent task distribution and real-time load balancing, supporting multi-node parallel execution. By constructing a multi-dimensional test data pool, execution logs, performance metrics, error screenshots, and other data are collected in real time, ultimately generating a visual report. This effectively solves core problems in related technology testing solutions, such as high script maintenance costs, low efficiency in cross-browser compatibility testing, and difficulties in large-scale test resource scheduling. A detailed explanation follows.

[0038] According to an embodiment of this application, a method embodiment for front-end testing 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.

[0039] The methods and embodiments provided in this application can be executed on mobile terminals, computer terminals, or similar computing devices. Figure 1 A hardware structure block diagram of a computer terminal (or electronic device) for implementing a front-end testing method is shown. Figure 1 As shown, the computer terminal 10 (or electronic device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0040] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or electronic device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0041] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the front-end testing method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the aforementioned front-end testing method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0042] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0043] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or electronic device).

[0044] Under the above operating environment, this application embodiment provides a front-end testing method. Figure 2 This is a schematic diagram of a front-end testing method flow provided according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0045] Step S202: Obtain the test requirement text and perform semantic analysis on the test requirement text to obtain key test information. The key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage.

[0046] Step S204: Based on the key test information and the page structure information of the target front-end webpage, determine the initial test script. The test script contains multiple test cases, which are used to simulate various user operation scenarios on the target front-end webpage.

[0047] Step S206: Based on historical test data, optimize the test cases in the initial test script to obtain the target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script.

[0048] Step S208: Execute the target test script to test the target front-end webpage and obtain the test results.

[0049] Through the above steps, test requirements are analyzed using natural language processing technology, and test scripts are automatically generated. This reduces the time and errors associated with manually writing scripts. At the same time, the test case optimization mechanism driven by historical data can dynamically adjust test strategies to ensure test coverage. This solves the technical problems of low efficiency in generating front-end test scripts and difficulty in covering complex scenarios in related technologies.

[0050] The front-end testing method in steps S202 to S208 of the embodiments of this application will be further described below.

[0051] The front-end automated testing framework and method in this application embodiment can be applied to the automated testing of various web front-end applications, including functional testing, compatibility testing, performance testing, etc. For example, it can be used to implement front-end automated testing of a new type of fiber optic sensing equipment professional management platform, such as... Figure 3 As shown, the system architecture of front-end automated testing mainly includes: an NLP test script adaptive generation module, a cross-browser execution and result collection module, and a task intelligent scheduling module.

[0052] The NLP test script adaptive generation module, as the core of the AI, is mainly responsible for natural language processing, intelligent script generation, test case optimization, and test result analysis. The natural language processing function receives user-inputted natural language test requirements and converts them into understandable test instructions. The intelligent script generation function automatically generates test scripts (e.g., Playwright test scripts) based on the test instructions and the target web application's page structure information. During script generation, it considers common test scenarios and boundary conditions to improve test coverage. The test case optimization function analyzes historical test data and defect information to optimize generated test cases, supplementing missing test scenarios and ensuring the comprehensiveness and effectiveness of test cases. The test result analysis function intelligently analyzes the test results collected by the Playwright module, identifies the causes of test failures, and generates visual reports.

[0053] The cross-browser execution and result collection module, as a browser automation tool, is primarily responsible for executing AI-generated test scripts, simulating user actions, and collecting test data. The cross-browser testing function supports executing test scripts on multiple browsers, including Chromium, Firefox, and WebKit, ensuring the compatibility of web applications across different browsers. The complex interaction simulation function can simulate complex user operations such as dragging, scrolling, and dynamic loading, meeting the needs of various complex testing scenarios. The test data collection function collects screenshots, logs, performance metrics, and other data during test execution, providing a basis for subsequent test result analysis.

[0054] The intelligent task scheduling module, as a distributed task queue, is mainly responsible for task distribution (distributing the generated test scripts as tasks to multiple worker nodes), scheduling (intelligently scheduling test tasks based on the load of worker nodes and task priorities to ensure efficient utilization of test resources), and parallel processing of test tasks (supporting the parallel execution of multiple test tasks, greatly shortening test time and improving test efficiency).

[0055] The following section provides a further description of the steps performed by each module and the interaction flow between them. Figure 4 This is a schematic diagram of the operation flow of a front-end automated test according to an embodiment of this application, specifically as follows: Figure 4 As shown.

[0056] First, obtain the natural language instructions (i.e., test requirement text) submitted by the requester, and parse them using the NLP test script adaptive generation module to generate the initial test script. The specific steps are as follows.

[0057] In some embodiments of this application, key test information includes: test target information, test step information, and expected test result information. Determining the initial test script based on the key test information and the page structure information of the target front-end webpage includes the following steps: determining the test script framework corresponding to the key test information, wherein the test script framework is used to define the structure and execution flow of test cases; generating a syntax logic tree corresponding to the key test information, and generating operation test statements based on the syntax logic tree and page structure information, wherein the syntax logic tree is used to represent the logical relationships and execution order between test steps; integrating the operation test statements into the test script framework to obtain the initial test script.

[0058] Specifically, such as Figure 5 As shown, after receiving the natural language test requirement text input by the user, it is converted into understandable test instructions. Assuming the test requirement text is T, and the extracted key information set (i.e., the aforementioned key test information) is K, the extraction formula can be expressed as: K = f(T), where f is an information extraction function that extracts key information such as test objectives (G), test steps (S), and expected results (E) from the text T through operations such as syntactic analysis and semantic understanding.

[0059] For example, the test requirement text T is: "Test the login function. Select browser C, enter the correct username and password, click the login button, and verify whether it redirects to the homepage." Then the extracted key test information K = {G = Test login function, S1 = , S2 = Enter the correct username, S3 = Enter the correct password, S4 = Click the login button, E = Redirect to the homepage}.

[0060] Then, intelligent script generation can be performed based on key test information and the page structure information of the target web application, automatically generating the initial test script (taking Playwright script as an example). Assuming the generated test script framework is C and the key test information is K, it can be expressed as: C = g(K), where g is a script generation function that generates a test script framework that conforms to Playwright syntax specifications based on the key information set K.

[0061] This application's embodiments achieve structured generation of test cases by constructing a test script framework and a syntax logic tree, which helps ensure the completeness and logical correctness of test cases. The test script framework provides the basic structure of test cases, while the syntax logic tree clarifies the execution order and condition judgments of test steps. The test cases generated by combining the two can more accurately reflect test requirements, improve the quality and efficiency of test script generation, and ensure comprehensive coverage of test scenarios.

[0062] Furthermore, after obtaining the initial test script, the test cases can be optimized based on historical test data to supplement any missing test scenarios, as follows.

[0063] In some embodiments of this application, optimizing test cases in the initial test script based on historical test data to obtain the target test script includes: analyzing and checking the scenario coverage of test cases in the initial test script based on historical test data to identify uncovered test scenarios. The historical test data includes historical test cases and defect reports. The analysis and checking include at least one of the following: checking whether the test cases cover all functional points of the target front-end webpage, checking whether the test cases cover all boundary conditions, and checking whether the test cases cover all user operation paths; generating new test cases corresponding to the identified uncovered test scenarios and adding the new test cases to the initial test script to obtain candidate test scripts; determining the similarity between different test cases in the candidate test scripts and filtering out redundant test cases in the candidate test scripts based on the similarity to obtain the target test script.

[0064] In this embodiment, historical test data includes test cases, test results, and recorded defect reports generated in previous test cycles. By analyzing this data, it is possible to identify which test scenarios have been adequately covered and which scenarios may have failed to be captured by existing test cases due to changes.

[0065] Specifically, the system first evaluates the initial test script, checking whether it covers all functionalities, boundary conditions, and possible user operation paths of the target front-end webpage. This is because even if the current test cases perform well under specific conditions, some test scenarios may not be covered due to page layout adjustments, the addition or removal of new features, changes in user behavior patterns, etc. By comparing with historical test data, especially previous defect reports, the system can identify newly changed areas or untested scenarios. For example, if there are multiple failure records for a certain function in historical data, but the existing test cases have not fully tested this function, then these functionalities will be considered uncovered. Once uncovered test scenarios are identified, the system will automatically generate related test cases. These new test cases will target those missing or changed scenarios, ensuring more comprehensive test coverage. Finally, the generated new test cases are integrated into the initial test script to form a candidate test script. This version of the script should be more complete and targeted than the previous version.

[0066] For example, suppose we are currently performing automated testing on an e-commerce website. The website recently added a new shopping cart checkout process, but this change is not reflected in the existing test scripts. Historical data contains test cases for functions such as login, product search, and adding items to the shopping cart, as well as defect reports from the checkout process, indicating that the checkout process may encounter problems under certain circumstances (such as using coupons or selecting different payment methods). By analyzing the historical test data, the system finds that while the basic functions of the checkout process are tested, tests for special cases such as coupon usage and payment method selection are not covered. In this case, the system can identify potential untested issues in the checkout process under these scenarios based on the defect reports, and automatically generate test cases for these missing scenarios. For example, it can create test scenarios to examine the performance of different coupon types during checkout, or test the compatibility of various payment methods during checkout. The updated test scripts can more comprehensively test the entire shopping cart checkout process, including the use of various coupons and the selection of payment methods, thereby improving test coverage and reducing potential problems encountered after deployment due to insufficient testing.

[0067] In addition, for the candidate test scripts obtained after supplementing test cases, redundant tests can be filtered out by calculating the similarity between test cases, avoiding repeated execution of the same or similar test scenarios, thereby improving test efficiency, as detailed below.

[0068] In some embodiments of this application, each test case includes a series of test steps; based on similarity, redundant test cases in the candidate test scripts are filtered out to obtain the target test script, which includes the following steps: extracting feature information of the test cases and vectorizing the feature information to obtain the feature vector corresponding to the test cases, wherein the feature information includes a series of test steps contained in the test cases; determining the similarity parameters between each pair of feature vectors of the test cases in the initial test script, wherein the similarity parameters are used to characterize the degree of similarity between the test cases; if the similarity parameters between two test cases exceed a preset similarity threshold, the two test cases are merged or one of the two test cases is deleted.

[0069] Specifically, the similarity parameter between the newly generated test cases and existing test cases is calculated. Assuming that two test cases T1 and T2 each consist of a series of operation steps, each operation step is mapped to a vector vi, resulting in the feature vector corresponding to the test case. The dimension of the vector can be determined based on features such as operation type and operation object. Then, the similarity parameter between the two test cases can be calculated using the cosine similarity formula. When the similarity Sim(T1,T2) is greater than the set threshold Th, the two test cases are considered similar, and one of them can be merged or optimized; finally, the target test script is obtained.

[0070] After obtaining the target test script, the task intelligent scheduling module can be used to schedule the target test script to be distributed to multiple worker nodes for execution. The specific steps are as follows.

[0071] In some embodiments of this application, executing the target test script includes the following steps: determining the load status of the worker nodes in the test system and the task priority of each task in the task set, wherein the task set includes test tasks, and the test tasks are used to execute the target test script on the worker nodes; determining the probability of the worker nodes executing the test tasks based on the task priority and load status, and determining at least one worker node to execute the test tasks based on the probability; and distributing the target test script to the worker nodes, and executing the test tasks in parallel on at least one worker node.

[0072] Specifically, such as Figure 6 As shown, intelligent scheduling can be performed based on the load and task priority of each worker node. The core objective is to assign task tj to the most suitable worker node ni to balance the load and meet priority requirements. Let the current set of worker nodes be N = {n1, n2, ..., n}. m The task set is T = {t1, t2, ..., t}. k}, working node n i The current load is L i Task t j The priority is P j Then task t j Assigned to worker node n i The probability P ij It can be calculated using the following formula:

[0073]

[0074] in It is all working nodes for task t j The allocation probability normalization factor for task t. j Assigned to worker node n i The specific triggering condition is You can choose to make P ij The largest working node n i Execute tasks. Through intelligent scheduling, multiple test tasks can be executed in parallel, and combined with dynamic load balancing algorithms, resource utilization can be effectively improved.

[0075] As an optional implementation, worker nodes can share a data pool or result set when executing test tasks. For example, error states or performance bottlenecks encountered by one node in a test case can be obtained by other nodes in real time, allowing for adjustments to test strategies or optimization of test cases. Additionally, some complex test scenarios may require collaborative execution between multiple worker nodes. For instance, a test case might involve multiple concurrent user operations, requiring different nodes to simultaneously simulate different user behaviors, verifying the system's concurrent processing capabilities and performance stability through the concurrency and response time of network requests.

[0076] This application embodiment comprehensively considers the load of worker nodes and the priority of tasks, and dynamically allocates test tasks by calculating probabilities to ensure the rational use of computing resources, improve the resource utilization and testing efficiency of the testing system, shorten the testing cycle, solve the resource scheduling and load balancing problems in a large-scale distributed testing environment, and further improve the stability and efficiency of the testing system.

[0077] After the target test script is distributed to the worker nodes, cross-browser testing can be performed using the cross-browser execution and result collection module, as detailed below.

[0078] In some embodiments of this application, distributing the target test script to worker nodes and executing test tasks in parallel on at least one worker node includes: executing test tasks through multiple different browsers on each worker node to test the compatibility of the target front-end webpage on different browsers; collecting test data during the test process, wherein the test data includes at least one of the following: webpage screenshots, log information, and performance metrics during the test process, wherein the performance metrics include at least one of the following: processor utilization and memory usage, and the log information includes at least one of the following: operation steps, exception information, and execution time of the test task on the worker node, wherein the execution time is determined by the page load time and operation response time.

[0079] Specifically, such as Figure 7 As shown, the target test script can be executed on various browsers such as Chromium, Firefox, and Safari to ensure the compatibility of the web application across different browsers. By executing the target test script, various complex user interaction operations such as dragging, scrolling, and dynamic loading can be simulated to meet the needs of various complex testing scenarios. Simultaneously, screenshots, logs, performance metrics, and other data are collected during the testing process to provide a basis for subsequent test result analysis. In this embodiment, the collected log information includes execution time, operation steps, and exception information, while performance metrics include CPU utilization and memory usage.

[0080] Among them, test task t j At worker node ni The execution time is Page load time This refers to the operation response time.

[0081] Furthermore, the collected test data can be analyzed using the NLP test script adaptive generation module, as detailed below.

[0082] In some embodiments of this application, the method further includes the following steps: obtaining test results of the target test script on each working node, wherein the test results are at least used to characterize the number of test cases that have passed the test on the working node in the target test script; analyzing the failure reasons of the test cases that failed based on the test results and test data, generating a test report corresponding to the target front-end webpage based on the failure reasons, and sending the test report to the front-end interactive interface for display.

[0083] Specifically, it can intelligently analyze test results, identify the reasons for test failures, and generate visual reports. Let the test case set be C = {c1, c2, ..., c...} i The number of test cases that passed the test is C. pass The number of test cases that failed is C. fail The test pass rate

[0084] This application embodiment can intelligently analyze the reasons for test failures based on test results and test data, and provide repair suggestions, thereby improving the efficiency and accuracy of test result analysis, accelerating the problem-solving speed, solving the problems of difficult interpretation of test results and inaccurate problem location, and further improving the efficiency and quality of testing work.

[0085] This application's solution utilizes an intelligent script generation function, enabling users to automatically generate test scripts simply by providing natural language testing requirements. This significantly reduces the workload of manually writing scripts. Furthermore, the module can automatically adjust and update scripts when page structure or functionality changes, lowering maintenance costs. When generating test scripts, this solution considers common test scenarios and boundary conditions, and optimizes test cases by combining historical test data and defect information, thereby improving test coverage and reducing the omission of potential issues. It also supports execution of test scripts on multiple browsers, automating cross-browser compatibility testing and improving testing efficiency and accuracy. Additionally, the intelligent task scheduling module enables parallel processing of test tasks through task distribution and scheduling, fully utilizing computing resources, significantly shortening testing time, and improving testing efficiency. Finally, the test results are intelligently analyzed and visualized reports are generated, allowing users to intuitively understand the test situation, quickly locate problems, and improve the efficiency of test result analysis.

[0086] According to an embodiment of this application, an embodiment of a front-end testing device is also provided. Figure 8 This is a schematic diagram of a front-end testing device provided according to an embodiment of this application. Figure 8 As shown, the device includes:

[0087] The key information extraction module 80 is used to obtain test requirement text and perform semantic analysis on the test requirement text to obtain key test information. The key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage.

[0088] The initial script generation module 82 is used to determine the initial test script based on key test information and the page structure information of the target front-end webpage. The test script contains multiple test cases, which are used to simulate various user operation scenarios on the target front-end webpage.

[0089] The script optimization and adjustment module 84 is used to optimize the test cases in the initial test script based on historical test data to obtain the target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script.

[0090] The script execution test module 86 is used to execute the target test script to test the target front-end webpage and obtain the test results.

[0091] Optionally, the key test information includes: test target information, test step information, and expected test result information. Based on the key test information and the page structure information of the target front-end webpage, determining the initial test script includes: determining the test script framework corresponding to the key test information, wherein the test script framework is used to define the structure and execution flow of test cases; generating a syntax logic tree corresponding to the key test information, and generating operation test statements based on the syntax logic tree and page structure information, wherein the syntax logic tree is used to represent the logical relationships and execution order between test steps; and integrating the operation test statements into the test script framework to obtain the initial test script.

[0092] Optionally, optimizing the test cases in the initial test script based on historical test data to obtain the target test script includes: analyzing and checking the scenario coverage of the test cases in the initial test script based on historical test data to identify uncovered test scenarios. Historical test data includes historical test cases and defect reports. The analysis and check include at least one of the following: checking whether the test cases cover all functionalities of the target front-end webpage, checking whether the test cases cover all boundary conditions, and checking whether the test cases cover all user operation paths; generating new test cases corresponding to the identified uncovered test scenarios and adding the new test cases to the initial test script to obtain candidate test scripts; determining the similarity between different test cases in the candidate test scripts and filtering out redundant test cases in the candidate test scripts based on the similarity to obtain the target test script.

[0093] Optionally, each test case contains a series of test steps; based on similarity, redundant test cases in the candidate test scripts are filtered out to obtain the target test script, including: extracting feature information of the test cases and vectorizing the feature information to obtain the feature vectors corresponding to the test cases, wherein the feature information includes a series of test steps contained in the test cases; determining the similarity parameters between each pair of feature vectors of the test cases in the initial test script, wherein the similarity parameters are used to characterize the degree of similarity between the test cases; if the similarity parameters between two test cases exceed a preset similarity threshold, the two test cases are merged or one of the two test cases is deleted.

[0094] Optionally, executing the target test script includes: determining the load status of the worker nodes in the test system and the task priority of each task in the task set, wherein the task set contains test tasks, which are used to execute the target test script on the worker nodes; determining the probability of the worker nodes executing the test tasks based on the task priority and load status, and determining at least one worker node to execute the test tasks based on the probability; and distributing the target test script to the worker nodes to execute the test tasks in parallel on at least one worker node.

[0095] Optionally, distributing the target test script to worker nodes and executing the test task in parallel on at least one worker node includes: executing the test task through multiple different browsers on each worker node to test the compatibility of the target front-end webpage on different browsers; collecting test data during the test process, wherein the test data includes at least one of the following: webpage screenshots during the test process, log information, performance indicators, performance indicators including at least one of the following: processor utilization, memory usage, log information including at least one of the following: operation steps, exception information, execution time of the test task on the worker node, the execution time being determined by page load time and operation response time.

[0096] Optionally, the script execution test module 86 is further configured to: obtain the test results of the target test script at each working node, wherein the test results are used to characterize at least the number of test cases that have passed the test at the working node in the target test script; analyze the failure reasons of the test cases that failed based on the test results and test data, and generate a test report corresponding to the target front-end webpage based on the failure reasons, and send the test report to the front-end interactive interface for display.

[0097] It should be noted that each module in the aforementioned front-end testing device can be a program module (e.g., a set of program instructions that implements a specific function) or a hardware module. For the latter, it can take the following forms, but is not limited to them: each of the above modules is represented by a processor, or the functions of each of the above modules are implemented by a processor.

[0098] It should be noted that the front-end testing device provided in this embodiment can be used to perform... Figure 2 The front-end testing method shown above is also applicable to the embodiments of this application, and will not be repeated here.

[0099] This application embodiment also provides a non-volatile storage medium, which includes a stored computer program. The device containing the non-volatile storage medium executes the following front-end testing method by running the computer program: acquiring test requirement text and performing semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage; determining an initial test script based on the key test information and the page structure information of the target front-end webpage, wherein the test script contains multiple test cases, which are used to simulate various user operation scenarios on the target front-end webpage; optimizing the test cases in the initial test script based on historical test data to obtain a target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script; and executing the target test script to test the target front-end webpage and obtain test results.

[0100] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the front-end testing method described in various embodiments of this application: obtaining test requirement text and performing semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage; determining an initial test script based on the key test information and the page structure information of the target front-end webpage, wherein the test script contains multiple test cases, and the test cases are used to simulate various user operation scenarios on the target front-end webpage; optimizing the test cases in the initial test script based on historical test data to obtain a target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script; and executing the target test script to test the target front-end webpage and obtain test results.

[0101] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0102] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0103] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0104] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0105] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0106] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0107] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A front-end testing method, characterized in that, include: Obtain the test requirement text and perform semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage. Based on the key test information and the page structure information of the target front-end webpage, an initial test script is determined. The test script contains multiple test cases, which are used to simulate various user operation scenarios on the target front-end webpage. Based on historical test data, the test cases in the initial test script are optimized to obtain the target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script. Execute the target test script to test the target front-end webpage and obtain the test results.

2. The front-end testing method according to claim 1, characterized in that, The key test information includes: test target information, test step information, and expected test result information; based on the key test information and the page structure information of the target front-end webpage, the initial test script is determined to include: Determine the test script framework corresponding to the key test information, wherein the test script framework is used to define the structure and execution flow of test cases; Generate a syntax logic tree corresponding to the key test information, and generate operation test statements based on the syntax logic tree and the page structure information, wherein the syntax logic tree is used to represent the logical relationship and execution order between test steps; The operation test statements are integrated into the test script framework to obtain the initial test script.

3. The front-end testing method according to claim 1, characterized in that, Based on historical test data, the test cases in the initial test script are optimized to obtain the target test script, which includes: Based on the historical test data, the scenario coverage of the test cases in the initial test script is analyzed and checked to identify uncovered test scenarios. The historical test data includes historical test cases and defect reports. The analysis and check include at least one of the following: checking whether the test cases cover all functional points of the target front-end webpage, checking whether the test cases cover all boundary conditions, and checking whether the test cases cover all user operation paths. Generate new test cases corresponding to the identified uncovered test scenarios, and add the new test cases to the initial test script to obtain candidate test scripts; Determine the similarity between different test cases in the candidate test scripts, and based on the similarity, filter out redundant test cases in the candidate test scripts to obtain the target test script.

4. The front-end testing method according to claim 3, characterized in that, Each test case contains a series of test steps; based on the similarity, redundant test cases are filtered out from the candidate test scripts to obtain the target test script, which includes: Extract the feature information of the test case and vectorize the feature information to obtain the feature vector corresponding to the test case, wherein the feature information includes a series of test steps contained in the test case; Determine the similarity parameters between each pair of feature vectors of the test cases in the initial test script, wherein the similarity parameters are used to characterize the degree of similarity between the test cases; If the similarity parameter between two test cases exceeds a preset similarity threshold, the two test cases will be merged or one of the two test cases will be deleted.

5. The front-end testing method according to claim 1, characterized in that, Executing the target test script includes: Determine the load status of the working nodes in the test system and the task priority of each task in the task set, wherein the task set includes test tasks, and the test tasks are used to execute the target test script on the working nodes; Based on the task priority and the load status, determine the probability that the worker node will execute the test task, and based on the probability, determine at least one worker node that will execute the test task; The target test script is distributed to the working node, and the test task is executed in parallel on at least one of the working nodes.

6. The front-end testing method according to claim 5, characterized in that, Distributing the target test script to the worker node and executing the test task in parallel on at least one of the worker nodes includes: In each of the aforementioned working nodes, the test task is executed through multiple different browsers to test the compatibility of the target front-end webpage on different browsers; Collect test data during the testing process, wherein the test data includes at least one of the following: webpage screenshots, log information, and performance indicators during the testing process, wherein the performance indicators include at least one of the following: processor utilization and memory usage, wherein the log information includes at least one of the following: operation steps, exception information, and the execution time of the test task on the working node, wherein the execution time is determined by the page load time and operation response time.

7. The front-end testing method according to claim 6, characterized in that, The method further includes: Obtain the test results of the target test script on each of the working nodes, wherein the test results are at least used to characterize the number of test cases in the target test script that have passed the test on the working nodes; Based on the test results and test data, analyze the reasons for the failure of the test cases, and generate a test report corresponding to the target front-end webpage based on the reasons for failure. Then, send the test report to the front-end interactive interface for display.

8. A front-end testing device, characterized in that, include: The key information extraction module is used to obtain test requirement text and perform semantic analysis on the test requirement text to obtain key test information, wherein the key test information is used to characterize the functional points and test steps that need to be tested on the target front-end webpage. An initial script generation module is used to determine an initial test script based on the key test information and the page structure information of the target front-end webpage. The test script contains multiple test cases, which are used to simulate various operation scenarios of users on the target front-end webpage. The script optimization and adjustment module is used to optimize the test cases in the initial test script based on historical test data to obtain a target test script, wherein the test scenario coverage of the target test script is higher than that of the initial test script. The script execution test module is used to execute the target test script to test the target front-end webpage and obtain test results.

9. An electronic device, characterized in that, include: A memory and a processor, the processor being configured to run a program stored in the memory, wherein the program, when running, performs the front-end testing method according to any one of claims 1 to 7.

10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the front-end testing method according to any one of claims 1 to 7 by running the computer program.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the front-end testing method according to any one of claims 1 to 7.