Automatic test script generation method and device based on deep learning, equipment and medium

By combining deep learning and dynamic Bayesian classification models with LoRA adaptation technology, a closed-loop self-optimizing system is constructed, which solves the problems of insufficient flexibility and adaptability of existing automated test script generation methods, and realizes efficient and intelligent automated test script generation and continuous optimization.

CN121455830APending Publication Date: 2026-02-03HANGZHOU HONGSHU INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511948765.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Existing automated test script generation methods are insufficient in terms of flexibility, syntax correctness, execution feedback mechanisms, and cross-framework adaptability, making it difficult to meet the needs of rapid iteration and continuous delivery.

Method used

We employ a deep learning-based automated test script generation method, combining a dynamic Bayesian classification model and LoRA adaptation technology. By parsing test cases, conducting risk assessments, performing syntax checks, and identifying failures, we construct a closed-loop self-optimizing system to generate automated test scripts that conform to the target testing framework. Furthermore, we optimize the model through incremental learning of the scheduling function.

Benefits of technology

It enables intelligent, efficient, and continuously optimized automated test scripts, improving testing efficiency and accuracy, reducing manual maintenance costs, and possessing adaptive capabilities to UI changes and environmental fluctuations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121455830A_ABST
    Figure CN121455830A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic test script generation method and device based on deep learning, equipment and a medium, and relates to the technical field of computers. Comprising the following steps: analyzing an obtained test case to extract key test information; using a preset dynamic Bayesian classification model to perform classification evaluation on the test cases based on the key test information to obtain corresponding risk probabilities, and using a preset weight adjustment function to adjust the priorities of the test cases according to the risk probabilities; generating an automatic test script based on the test case by using a preset deep learning model; extracting failure features from the execution result of the automated test script by using a preset failure mining function, and updating the failure features to a preset knowledge base; and utilizing a preset incremental learning scheduling function to optimize a preset dynamic Bayesian classification model and a preset deep learning model based on the execution result. Therefore, intelligentization, high efficiency and sustainable optimization of automatic test script generation can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for generating automated test scripts based on deep learning. Background Technology

[0002] In the field of software testing, the generation and maintenance of automated test scripts have always been crucial for improving testing efficiency and ensuring software quality. As software systems become increasingly larger and more complex, traditional methods of manually writing test scripts are no longer sufficient to meet the demands of rapid iteration and continuous delivery. Therefore, the industry has proposed various automated test script generation methods to reduce reliance on manual intervention and improve the efficiency and accuracy of script generation.

[0003] Existing technical solutions can be mainly categorized as follows: Script generation methods based on rule templates. This method relies on a predefined rule base and script templates, filling the templates by matching keywords or patterns in test cases to generate executable test scripts. Its advantages are simplicity and speed, but its disadvantages are also significant: the rule base needs to be manually defined and maintained, making it difficult to cover complex and ever-changing business scenarios; it has high requirements for the standardization of test case descriptions, lacking flexibility; and when the UI or business logic changes, the templates and rules often need to be manually updated, resulting in high maintenance costs. Script generation methods based on traditional machine learning typically use natural language processing techniques to parse test case text, extracting operations, objects, and expected results, and then mapping them to specific test script code through classification or sequence labeling models. For example, algorithms such as Support Vector Machines and Random Forests are used to classify operation types, or sequence models such as Hidden Markov Models and Conditional Random Fields are used to generate script structures. Compared to rule-based methods, these methods possess some learning capabilities, but still suffer from the following limitations: the model relies on a large amount of labeled data, resulting in high training costs; generalization ability is limited, making it difficult to adapt to new businesses or frameworks; and there is a lack of dynamic adjustment and self-optimization mechanisms, preventing real-time improvement of the generation strategy based on execution feedback. End-to-end generation methods based on deep learning have emerged in recent years with the development of deep learning technology, especially the rise of sequence-to-sequence models and pre-trained language models. These methods can directly generate code sequences from test case text, reducing reliance on intermediate manual annotation. However, existing methods often suffer from the following problems: insufficient syntactic correctness of the generated scripts, requiring additional syntax validation modules; poor adaptability to specific testing frameworks, exhibiting strong generality but insufficient specificity; and a lack of execution feedback mechanisms, making continuous optimization and adjustment based on actual execution results impossible.

[0004] As can be seen from the above, how to achieve intelligent, efficient, and continuously optimized automated test script generation is an urgent problem to be solved. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for generating automated test scripts based on deep learning, which can achieve intelligent, efficient, and continuously optimized automated test script generation. The specific solution is as follows:

[0006] Firstly, this application provides a method for generating automated test scripts based on deep learning, including:

[0007] Obtain test cases and parse them to extract key test information; each test case includes test steps and a description of expected test results.

[0008] The test cases are classified and evaluated based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases, and the priority of the test cases is adjusted according to the risk probability using a preset weight adjustment function.

[0009] An automated test script conforming to the target testing framework is generated based on priority-adjusted test cases using a pre-defined deep learning model; the pre-defined deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer.

[0010] The automated test script is executed to generate corresponding execution results, and a preset failure mining function is used to extract failure features from the execution results and update the failure features to a preset knowledge base; the preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model;

[0011] The preset dynamic Bayesian classification model and the preset deep learning model are optimized based on the execution results using a preset incremental learning scheduling function.

[0012] Optionally, the step of obtaining test cases and parsing the test cases to extract key test information includes:

[0013] Obtain test cases and use a pre-trained language model to perform named entity recognition on the test cases in order to extract the corresponding operation actions;

[0014] Dependency parsing is performed on the test cases to extract the operation objects associated with the operation actions, and corresponding key test information is generated based on the operation actions and the operation objects.

[0015] Optionally, the step of using a preset dynamic Bayesian classification model to classify and evaluate the test cases based on the key test information to obtain the risk probability corresponding to the test cases includes:

[0016] The preset dynamic Bayesian classification model is used to classify and evaluate the test cases based on discrete features of test case type, module label, and step complexity, as well as continuous features of historical execution failure rate and historical execution time, so as to obtain the risk probability corresponding to the test cases.

[0017] The preset dynamic Bayesian classification model includes state nodes and observation nodes; the state nodes include environmental stability nodes, module risk probability nodes, and priority weight nodes; the observation nodes include element location failure rate nodes and call timeout rate nodes.

[0018] Among them, the environmental stability node and the element location failure rate node are dynamic nodes that are updated in real time based on script execution feedback;

[0019] Accordingly, adjusting the priority of the test cases based on the risk probability using a preset weight adjustment function includes:

[0020] The priority of the test cases is adjusted using a preset weight adjustment function based on the risk probability and the script execution feedback.

[0021] Optionally, the step of generating automated test scripts conforming to the target testing framework based on priority-adjusted test cases using a preset deep learning model includes:

[0022] The pre-trained language model in the input layer is used to perform text vectorization on the priority-adjusted test cases to obtain the corresponding text feature vectors. The multi-head self-attention mechanism and feedforward network in the encoding layer are then used to encode the text feature vectors to obtain feature encoding.

[0023] The LoRA adaptation layer is used to perform low-rank adaptive adjustment on the query vector and value vector in the multi-head self-attention mechanism to adapt to the syntax specification of the target testing framework. The decoder layer is then used to decode the adapted feature encoding in a sequence-to-sequence manner to generate an automated test script that conforms to the syntax of the target testing framework.

[0024] Optionally, the deep learning-based automated test script generation method further includes:

[0025] The test framework API constraints and UI element positioning rules in the preset knowledge base are encoded into conditional probability distributions. During the decoding process of the decoder layer, the decoding generation direction is adjusted according to the conditional probability distributions in order to optimize the automated test scripts generated by the decoder layer.

[0026] The automated test script is validated using a syntax validation module, and the automated test script is corrected based on the validation results using the repair rules in the preset knowledge base.

[0027] Optionally, the step of extracting failure features from the execution result using a preset failure mining function and updating the failure features to a preset knowledge base includes:

[0028] Using a preset failure detection function, error screenshots, UI element location information, and DOM structure information corresponding to the failure cases are obtained from the execution results;

[0029] Image features are extracted from the erroneous screenshot to obtain the corresponding image features, and a preset image matching algorithm is used to determine the structural change points based on the UI element positioning information and the DOM structure information;

[0030] New UI element positioning rules are generated based on the image features and the structural change points as failure features, and the failure features are updated to the preset knowledge base.

[0031] Optionally, the step of optimizing the preset dynamic Bayesian classification model and the preset deep learning model based on the execution result using a preset incremental learning scheduling function includes:

[0032] The available computing resources of the current system are obtained by using a preset incremental learning scheduling function, and the prediction bias urgency of the preset dynamic Bayesian classification model and the script failure rate urgency of the preset deep learning model are calculated based on the execution results.

[0033] Based on the urgency of the prediction bias, the urgency of the script failure rate, and the available computing resources, a preset multi-objective optimization algorithm is used to determine the update order and resource allocation strategy of the preset dynamic Bayesian classification model and the preset deep learning model, so as to complete the optimization of the preset dynamic Bayesian classification model and the preset deep learning model.

[0034] Secondly, this application provides an automated test script generation device based on deep learning, comprising:

[0035] The data parsing module is used to acquire test cases and parse the test cases to extract key test information; the test cases include test steps and expected test results descriptions.

[0036] The priority scheduling module is used to classify and evaluate the test cases based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases, and adjust the priority of the test cases according to the risk probability using a preset weight adjustment function.

[0037] The script generation module is used to generate automated test scripts that conform to the target testing framework based on priority-adjusted test cases using a preset deep learning model; the preset deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer.

[0038] The script execution module is used to execute the automated test script to generate corresponding execution results, extract failure features from the execution results using a preset failure mining function, and update the failure features to a preset knowledge base; the preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model;

[0039] The model optimization module is used to optimize the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using a preset incremental learning scheduling function.

[0040] Thirdly, this application provides an electronic device, comprising:

[0041] Memory, used to store computer programs;

[0042] A processor is used to execute the computer program to implement the aforementioned deep learning-based automated test script generation method.

[0043] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned deep learning-based automated test script generation method.

[0044] This application provides a method for generating automated test scripts based on deep learning. The method involves acquiring test cases and parsing them to extract key test information. Each test case includes test steps and expected test results. A preset dynamic Bayesian classification model is used to classify and evaluate the test cases based on the key test information to obtain a risk probability corresponding to each test case. The priority of the test cases is adjusted using a preset weight adjustment function based on the risk probability. An automated test script conforming to a target test framework is generated using a preset deep learning model based on the priority-adjusted test cases. The preset deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer. The automated test script is executed to generate corresponding execution results. A preset failure mining function is used to extract failure features from the execution results and update the failure features in a preset knowledge base. The preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model. A preset incremental learning scheduling function is used to optimize the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results.

[0045] As can be seen from the above, this application constructs an intelligent, adaptive, and efficient automated test script generation system by introducing dynamic Bayesian risk perception, deep learning script generation, and a closed-loop self-optimization mechanism. This system combines test case text parsing with dynamic Bayesian classification to achieve intelligent scheduling of test cases based on risk probability, enabling test execution to focus on high-defect-risk modules and significantly improving testing efficiency. By integrating LoRA adaptation technology with a deep learning model based on an expert knowledge base, it can automatically generate grammatically correct and highly executable test scripts for different testing frameworks, significantly reducing reliance on manual script writing and cross-framework adaptation costs. Furthermore, the system automatically extracts rules from execution feedback and continuously updates the knowledge base through a failure mining function, enabling scripts to adapt to UI changes and environmental fluctuations, effectively solving the problems of difficult maintenance and easy failure of traditional scripts. Finally, by using an incremental learning scheduling function to collaboratively optimize the Bayesian model and the deep learning model and intelligently allocate resources, it improves the utilization of computing resources while ensuring continuous system learning and performance improvement, thereby achieving intelligent, efficient, and sustainable optimization of automated test script generation. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0047] Figure 1 This is a flowchart of an automated test script generation method based on deep learning disclosed in this invention;

[0048] Figure 2 This is a schematic diagram of an automated test script generation device based on deep learning disclosed in this invention;

[0049] Figure 3 This is a structural diagram of the electronic device disclosed in this invention. Detailed Implementation

[0050] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0051] In the field of software testing, the generation and maintenance of automated test scripts have always been crucial for improving testing efficiency and ensuring software quality. As software systems become increasingly larger and more complex, traditional manual test script writing methods are no longer sufficient to meet the demands of rapid iteration and continuous delivery. To address this, the industry has proposed various automated test script generation methods to reduce reliance on manual intervention and improve the efficiency and accuracy of script generation. Existing technical solutions can be broadly categorized as follows: Rule-template-based script generation methods. These methods rely on predefined rule libraries and script templates, filling templates by matching keywords or patterns in test cases to generate executable test scripts. Their advantages include simplicity and speed, but significant drawbacks include the need for manual pre-definition and maintenance of the rule library, making it difficult to cover complex and ever-changing business scenarios; high requirements for the standardization of test case descriptions, resulting in a lack of flexibility; and the need for manual updates to templates and rules when UI or business logic changes, leading to high maintenance costs. Traditional machine learning-based script generation methods typically employ natural language processing to parse test case text, extracting actions, objects, and expected results, and then mapping them to specific test script code using classification or sequence labeling models. For example, algorithms such as Support Vector Machines and Random Forests are used to classify operation types, or sequence models such as Hidden Markov Models and Conditional Random Fields are used to generate script structures. Compared with rule-based methods, these methods have a certain learning ability, but still have the following limitations: the model relies on a large amount of labeled data, resulting in high training costs; generalization ability is limited, making it difficult to adapt to new businesses or new frameworks; and there is a lack of dynamic adjustment and self-optimization mechanisms, making it impossible to improve the generation strategy in real time based on execution feedback. End-to-end generation methods based on deep learning have emerged in recent years with the development of deep learning technology, especially the rise of sequence-to-sequence models and pre-trained language models. These methods can directly generate code sequences from test case text, reducing the reliance on intermediate manual annotation. However, existing methods often have the following problems: insufficient syntactic correctness of the generated scripts, requiring additional syntax verification modules; poor adaptability to specific testing frameworks, with strong generality but insufficient specificity; and a lack of execution feedback mechanisms, making it impossible to continuously optimize and adjust based on actual execution results. Therefore, this application provides an automated test script generation scheme based on deep learning, which can achieve intelligent, efficient, and continuously optimized automated test script generation.

[0052] See Figure 1 As shown in the figure, this application discloses an automated test script generation method based on deep learning, including:

[0053] Step S11: Obtain test cases and parse the test cases to extract key test information.

[0054] In this embodiment, test case documents (such as Word or Excel formats) containing natural language descriptions uploaded by users are received. The test cases should conform to specifications, which require that the test cases include test steps and expected test results. Furthermore, a pre-trained language model (such as BERT) is used to parse the test steps and extract key test fields. Specifically, obtaining test cases and parsing them to extract key test information may include: obtaining test cases and using a pre-trained language model to perform named entity recognition on the test cases to extract corresponding operation actions; performing dependency parsing on the test cases to extract operation objects associated with the operation actions; and generating corresponding key test information based on the operation actions and operation objects. The test steps are descriptions of the operation flow for each step of testing the system; the expected test results are descriptions of the final verification results of the test flow. For example, in some specific implementations, a pre-trained language model is used to perform named entity recognition on the test case text to extract key operation verbs such as "click," "input," and "assert." Then, dependency parsing is performed on the text to extract the objects associated with the operation verbs, i.e., the operation objects (such as "username input box" and "login button"). Combining the extracted operation actions and operation objects, key test fields are constructed.

[0055] Step S12: Use a preset dynamic Bayesian classification model to classify and evaluate the test cases based on the key test information to obtain the risk probability corresponding to the test cases, and adjust the priority of the test cases according to the risk probability using a preset weight adjustment function.

[0056] In this embodiment, the extracted key test information is input into a pre-defined dynamic Bayesian classification model. This model uses the test case type (e.g., normal / abnormal process), its associated functional module, and step complexity as discrete features, and its historical execution failure rate and execution time as continuous features to classify and evaluate test cases, outputting a quantified risk probability to characterize the confidence level of the test case's potential vulnerability in the current context. It is worth noting that continuous features can be pre-discretized using binning or a Gaussian distribution assumption. Specifically, the step of classifying and evaluating test cases based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases may include: classifying and evaluating test cases based on discrete features of test case type, module label, and step complexity, and continuous features of historical execution failure rate and historical execution time, using the preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases; the preset dynamic Bayesian classification model includes state nodes and observation nodes; the state nodes include environment stability nodes, module risk probability nodes, and priority weight nodes; the observation nodes include element location failure rate nodes and call timeout rate nodes; wherein, the environment stability node and the element location failure rate node are dynamic nodes that are updated in real time based on script execution feedback.

[0057] In this embodiment, the core of the dynamic Bayesian model lies in its dynamic nature. The model internally defines state nodes (such as environmental stability S, module risk probability R_m) and observation nodes (such as element location failure rate E_m, call timeout rate T). The values ​​of the observation nodes are obtained in real time from the subsequent script execution results. Based on new observational evidence, the model dynamically updates the posterior probability distribution of the state nodes, achieving online perception of environmental fluctuations and the true risk level of the module. Here, environmental stability S represents the stability of the execution environment, with a value range of [0,1], where 0 represents complete instability and 1 represents complete stability; module risk probability R_m represents the defect risk probability of module m, with a value range of [0,1]; priority weight W represents the priority weight of the test case, with a value range of [1,∞); and element location failure rate E_m represents the element location failure rate of module m, calculated as follows:

[0058] ;

[0059] Furthermore, the call timeout rate T represents the execution call timeout rate, and the calculation formula is as follows:

[0060] ;

[0061] Furthermore, the conditional probability P of the dynamic Bayesian network is dynamically updated based on real-time feedback, specifically including updates to the environmental stability node and the module risk probability node.

[0062] In this embodiment, a preset weight adjustment function is invoked to adjust the priority of the test cases. Specifically, adjusting the priority of the test cases based on the risk probability using the preset weight adjustment function may include:

[0063] The priority of the test cases is adjusted using a preset weight adjustment function based on the risk probability and the script execution feedback. The preset weight adjustment function takes the risk probability (NB_P) output by the dynamic Bayesian model and the latest execution feedback data (such as the number of location failures) as input, and outputs the adjusted risk weight. The calculation formula is as follows:

[0064] ;

[0065] ;

[0066] Where Adjusted_Weight is the adjusted priority weight; W is the dynamic adjustment factor; The adjustment coefficient was determined based on regression analysis of historical data. This is the posterior probability of environmental stability when the location failure rate is observed, used to dynamically update the confidence level of the environmental stability node.

[0067] Step S13: Use a preset deep learning model to generate automated test scripts that conform to the target test framework based on the priority-adjusted test cases.

[0068] In this embodiment, the pre-defined deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer. The input layer uses a pre-trained language model to transform the priority-adjusted test case text into dense text feature vectors. The encoding layer employs a multi-head self-attention mechanism and a feedforward network to deeply encode the text feature vectors, capturing the logical relationships and contextual information between test steps, and outputting feature codes that conform to the framework specifications. The LoRA (Low-Rank Adaptation) layer is crucial for achieving lightweight, multi-framework adaptation. In the self-attention module of the encoding layer, trainable low-rank matrices (BAs) are inserted into the side paths of the query vector Q and the value vector V. By freezing the backbone model parameters and only fine-tuning these low-rank matrices, the model can quickly adapt to the API syntax and encoding specifications of different testing frameworks (such as Playwright or Selenium) with minimal parameter cost. The decoder layer decodes the feature codes adjusted by the LoRA adaptation layer into a script code sequence for the target testing framework in a sequence-to-sequence manner. The output layer generates the final, syntactically correct automated test script. Specifically, the step of generating automated test scripts conforming to the target testing framework based on priority-adjusted test cases using a pre-trained deep learning model may include: using a pre-trained language model in the input layer to perform text vectorization on the priority-adjusted test cases to obtain corresponding text feature vectors; using a multi-head self-attention mechanism and a feedforward network in the encoding layer to encode the text feature vectors to obtain feature encodings; using the LoRA adaptation layer to perform low-rank adaptive adjustment on the query vector and value vector in the multi-head self-attention mechanism to adapt to the syntax specifications of the target testing framework; and using the decoder layer to decode the adapted feature encodings in a sequence-to-sequence manner to generate automated test scripts conforming to the syntax of the target testing framework. For example, in one specific implementation, LoRA technology is used to achieve dynamic adaptation of the test script generation model, freezing the backbone parameters of the pre-trained model and training only the low-rank matrix of the LoRA adaptation layer; adding LoRA modules to the query vector Q and value vector V in the encoding layer as bypasses, and adjusting the weights using a formula, the weight calculation formula is as follows:

[0069] ;

[0070] in, The new weight matrix after incorporating LoRA adaptation; is the original weight matrix; r is the rank of the low-rank matrix; A and B are low-rank matrices; This is the LoRA scaling factor.

[0071] Furthermore, for different testing frameworks (such as Playwright and Selenium), LoRA parameters are fine-tuned using a small amount of labeled data (such as historical successful scripts) to achieve rapid adaptation. When the API of the testing framework changes, the system automatically collects new labeled data and updates the LoRA adaptation layer parameters without retraining the entire model. By maintaining multiple LoRA adaptation layers, the system can simultaneously support multiple testing frameworks (such as Playwright and Selenium), and users only need to select the target framework to generate scripts with the corresponding syntax. The IncreLoRA method is used to dynamically allocate low-rank matrix parameters based on the module importance score. The formula for calculating the importance score is as follows:

[0072] ;

[0073] in, Rate the importance of the module; The rating adjustment coefficient is denoted by ; the dynamic rank allocation increases the rank r value (e.g., r=16) for modules with high importance ratings, and keeps r=8 for modules with low importance ratings.

[0074] In this embodiment, rule support is provided for the script generation and optimization process of the preset deep learning model through the preset knowledge base. Specifically, the deep learning-based automated test script generation method may further include: encoding the test framework API constraints and UI element positioning rules in the preset knowledge base into conditional probability distributions, and adjusting the decoding generation direction according to the conditional probability distributions during the decoding process of the decoder layer to optimize the automated test scripts generated by the decoder layer; validating the automated test scripts using a syntax verification module, and correcting the automated test scripts based on the verification results using the repair rules in the preset knowledge base. For example, in one specific implementation, expert knowledge such as test framework API constraints and UI element positioning rules is introduced in the decoding stage, and the generation direction is adjusted through conditional probability. For example, test framework API rules (such as Playwright's CSS selector specifications) are encoded into conditional probability distributions, and the decoding direction is adjusted through hard constraints (vocabulary restrictions) and soft constraints (probability penalties); the use of outdated Selenium methods is prohibited, and the generation probability of illegal syntax is limited by using a mask. Collect historical scripts that failed to execute, analyze the reasons for failure (such as element location failure, assertion errors, etc.), extract features, and update the expert knowledge base. For example, extract features from failed scripts, such as the CSS selector pattern for element location failure and the specific type of assertion error. Use the Minimal Differentiation Analysis (MDA) method to compare the execution path differences between successful and failed test cases to locate syntax errors or logical vulnerabilities; analyze the reasons for element location failure in the "login" step, and find that the CSS selector #remove-item-2 is no longer effective and needs to be adjusted to a more stable XPATH path. Furthermore, the generated script passes through a syntax validation module, and if errors are found, expert mode is triggered to fix them, ensuring that the generated script can execute correctly.

[0075] Step S14: Execute the automated test script to generate corresponding execution results, extract failure features from the execution results using a preset failure mining function, and update the failure features to a preset knowledge base.

[0076] In this embodiment, the generated script is executed, and new rules are automatically learned from failure cases based on a failure mining function. Specifically, extracting failure features from the execution result using a preset failure mining function and updating the failure features to a preset knowledge base may include: obtaining error screenshots, UI element positioning information, and DOM structure information corresponding to the failure cases from the execution result using the preset failure mining function; extracting image features from the error screenshots to obtain corresponding image features, and determining structural change points based on the UI element positioning information and the DOM structure information using a preset image matching algorithm; generating new UI element positioning rules as failure features based on the image features and the structural change points, and updating the failure features to the preset knowledge base. That is, during execution, the execution status, result (pass / fail / blocked), error type, error information, screenshots, UI element positioning information such as CSS selectors or XPath, and the current DOM structure information are monitored and collected in real time. For failed execution cases, a pre-defined failure mining function is used to extract image features from the failure screenshots (e.g., using the SIFT algorithm). Combining the UI element location information and DOM structure at the time of failure, a graph matching algorithm (e.g., VF2 algorithm) is used to compare the DOM structure with that of successful cases to locate the changed nodes. By integrating the differences in image features and the points of change in DOM structure, a new, more robust UI element location rule is inferred and generated (e.g., "If an element has a certain visual feature and is within a certain DOM structure, then use a certain XPath for location"). This newly generated rule is automatically added to the pre-defined knowledge base as a "failure feature," achieving automatic updates to the knowledge base.

[0077] Step S15: Optimize the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using a preset incremental learning scheduling function.

[0078] In this embodiment, the performance status of two core models is monitored using the preset incremental learning scheduling function: the "prediction bias urgency" (i.e., the difference between its risk assessment and actual failure rate) of the dynamic Bayesian classification model and the "script failure rate urgency" of the deep learning model. Specifically, optimizing the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using the preset incremental learning scheduling function may include: obtaining the available computing resources of the current system using the preset incremental learning scheduling function, and calculating the prediction bias urgency of the preset dynamic Bayesian classification model and the script failure rate urgency of the preset deep learning model based on the execution results; based on the prediction bias urgency, the script failure rate urgency, and the available computing resources, using a preset multi-objective optimization algorithm, determining the update order and resource allocation strategy of the preset dynamic Bayesian classification model and the preset deep learning model to complete the optimization of the preset dynamic Bayesian classification model and the preset deep learning model. That is, updating the urgency values ​​of the Bayesian model and the deep learning model through a custom algorithm, and determining the model update strategy according to the resource constraints of the current execution environment. Furthermore, dynamic weight adjustment and improved congestion calculation are introduced to enhance the balancing ability of the above values. A multi-objective optimization algorithm (e.g., considering defect risk, resource consumption, and update duration) intelligently decides when and how much resource to use to update which model. For example, when resources are scarce, the LoRA parameters of the deep learning model with a soaring failure rate are updated first; when resources are sufficient, both models are updated in parallel. This collaborative optimization mechanism ensures that the system maintains optimal performance under limited resources and can continuously learn from new execution data.

[0079] As can be seen from the above, this application's embodiments achieve intelligent, highly adaptable generation and full lifecycle management of automated test scripts by constructing a closed-loop system of "risk perception - intelligent generation - execution feedback - continuous optimization". By using a dynamic Bayesian model to perform risk assessment and dynamic priority scheduling of test cases, test resources are focused on high-defect-risk areas, significantly improving the effectiveness of test execution and the problem detection rate. Utilizing a deep learning model with an integrated LoRA adaptation layer, combined with rule constraints from an expert knowledge base, syntactically sound and highly executable scripts can be generated, supporting rapid and lightweight adaptation to different testing frameworks. Through a failure mining function, UI change patterns are automatically learned from execution feedback, generating new localization rules and continuously enriching the knowledge base, enabling the scripts to adapt to system changes and significantly reducing manual maintenance costs. Through an incremental learning scheduling function, the update strategies and resource allocation of multiple models are intelligently coordinated, ensuring continuous improvement in system performance while increasing the utilization efficiency of computing resources, achieving sustainable system evolution.

[0080] See Figure 2 As shown in the figure, this application discloses an automated test script generation device based on deep learning, comprising:

[0081] The data parsing module 11 is used to acquire test cases and parse the test cases to extract key test information; the test cases include test steps and test expected results descriptions.

[0082] The priority scheduling module 12 is used to classify and evaluate the test cases based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases, and adjust the priority of the test cases according to the risk probability using a preset weight adjustment function.

[0083] The script generation module 13 is used to generate automated test scripts that conform to the target test framework based on priority-adjusted test cases using a preset deep learning model; the preset deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer.

[0084] The script execution module 14 is used to execute the automated test script to generate corresponding execution results, extract failure features from the execution results using a preset failure mining function, and update the failure features to a preset knowledge base; the preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model.

[0085] The model optimization module 15 is used to optimize the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using a preset incremental learning scheduling function.

[0086] In some specific embodiments, the data parsing module 11 may specifically include:

[0087] The data acquisition unit is used to acquire test cases and use a pre-trained language model to perform named entity recognition on the test cases in order to extract the corresponding operation actions.

[0088] The data parsing unit is used to perform dependency parsing on the test cases to extract the operation objects associated with the operation actions, and generate corresponding key test information based on the operation actions and the operation objects.

[0089] In some specific embodiments, the priority scheduling module 12 may specifically include:

[0090] The risk probability assessment unit is used to classify and assess the test cases based on the discrete features of test case type, module label, and step complexity, as well as the continuous features of historical execution failure rate and historical execution time, using the preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases. The preset dynamic Bayesian classification model includes state nodes and observation nodes. The state nodes include environment stability nodes, module risk probability nodes, and priority weight nodes. The observation nodes include element location failure rate nodes and call timeout rate nodes. The environment stability node and the element location failure rate node are dynamic nodes that are updated in real time based on script execution feedback.

[0091] The priority adjustment unit is used to adjust the priority of the test cases based on the risk probability and the script execution feedback using a preset weight adjustment function.

[0092] In some specific embodiments, the script generation module 13 may specifically include:

[0093] The feature encoding unit is used to perform text vectorization processing on the priority-adjusted test cases using the pre-trained language model in the input layer to obtain the corresponding text feature vectors, and to encode the text feature vectors using the multi-head self-attention mechanism and feedforward network in the encoding layer to obtain feature encoding.

[0094] The script generation unit is used to perform low-rank adaptive adjustment on the query vector and value vector in the multi-head self-attention mechanism using the LoRA adaptation layer to adapt to the syntax specification of the target testing framework, and to use the decoder layer to decode the adapted feature encoding in a sequence-to-sequence manner to generate an automated test script that conforms to the syntax of the target testing framework.

[0095] In some specific embodiments, the script execution module 14 may specifically include:

[0096] The execution result parsing unit is used to obtain error screenshots, UI element positioning information and DOM structure information corresponding to the failure cases from the execution result using a preset failure mining function;

[0097] The structural change point determination unit is used to extract image features from the erroneous screenshot to obtain corresponding image features, and to determine the structural change points based on the UI element positioning information and the DOM structure information using a preset image matching algorithm.

[0098] The failure feature update unit is used to generate new UI element positioning rules as failure features based on the image features and the structural change points, and update the failure features to a preset knowledge base.

[0099] In some specific embodiments, the model optimization module 15 may specifically include:

[0100] The urgency calculation unit is used to obtain the available computing resources of the current system using a preset incremental learning scheduling function, and to calculate the urgency of the prediction bias of the preset dynamic Bayesian classification model and the urgency of the script failure rate of the preset deep learning model based on the execution results.

[0101] The model optimization unit is used to determine the update order and resource allocation strategy of the preset dynamic Bayesian classification model and the preset deep learning model based on the urgency of the prediction bias, the urgency of the script failure rate, and the available computing resources, using a preset multi-objective optimization algorithm, so as to complete the optimization of the preset dynamic Bayesian classification model and the preset deep learning model.

[0102] In some specific embodiments, the deep learning-based automated test script generation device may further include:

[0103] The script optimization unit is used to encode the test framework API constraints and UI element positioning rules in the preset knowledge base into a conditional probability distribution, and adjust the decoding generation direction according to the conditional probability distribution during the decoding process of the decoder layer, so as to optimize the automated test script generated by the decoder layer.

[0104] The script correction unit is used to verify the automated test script using the syntax verification module, and to correct the automated test script based on the verification results using the repair rules in the preset knowledge base.

[0105] Furthermore, embodiments of this application also disclose an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the deep learning-based automated test script generation method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0106] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0107] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0108] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the deep learning-based automated test script generation method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0109] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed method for generating automated test scripts based on deep learning. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0111] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0112] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0113] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0114] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for generating automated test scripts based on deep learning, characterized in that, include: Obtain test cases and parse them to extract key test information; The test cases include test steps and descriptions of expected test results; The test cases are classified and evaluated based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases, and the priority of the test cases is adjusted according to the risk probability using a preset weight adjustment function. An automated test script conforming to the target testing framework is generated based on priority-adjusted test cases using a pre-defined deep learning model; the pre-defined deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer. The automated test script is executed to generate corresponding execution results, and a preset failure mining function is used to extract failure features from the execution results and update the failure features to a preset knowledge base. The preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model; The preset dynamic Bayesian classification model and the preset deep learning model are optimized based on the execution results using a preset incremental learning scheduling function.

2. The method for generating automated test scripts based on deep learning according to claim 1, characterized in that, The process of acquiring test cases and parsing them to extract key test information includes: Obtain test cases and use a pre-trained language model to perform named entity recognition on the test cases in order to extract the corresponding operation actions; Dependency parsing is performed on the test cases to extract the operation objects associated with the operation actions, and corresponding key test information is generated based on the operation actions and the operation objects.

3. The method for generating automated test scripts based on deep learning according to claim 1, characterized in that, The step of classifying and evaluating test cases based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases includes: The preset dynamic Bayesian classification model is used to classify and evaluate the test cases based on discrete features of test case type, module label, and step complexity, as well as continuous features of historical execution failure rate and historical execution time, so as to obtain the risk probability corresponding to the test cases. The preset dynamic Bayesian classification model includes state nodes and observation nodes; the state nodes include environmental stability nodes, module risk probability nodes, and priority weight nodes; the observation nodes include element location failure rate nodes and call timeout rate nodes. Among them, the environmental stability node and the element location failure rate node are dynamic nodes that are updated in real time based on script execution feedback; Accordingly, adjusting the priority of the test cases based on the risk probability using a preset weight adjustment function includes: The priority of the test cases is adjusted using a preset weight adjustment function based on the risk probability and the script execution feedback.

4. The method for generating automated test scripts based on deep learning according to claim 1, characterized in that, The step of generating automated test scripts conforming to the target testing framework based on priority-adjusted test cases using a preset deep learning model includes: The pre-trained language model in the input layer is used to perform text vectorization on the priority-adjusted test cases to obtain the corresponding text feature vectors. The multi-head self-attention mechanism and feedforward network in the encoding layer are then used to encode the text feature vectors to obtain feature encoding. The LoRA adaptation layer is used to perform low-rank adaptive adjustment on the query vector and value vector in the multi-head self-attention mechanism to adapt to the syntax specification of the target testing framework. The decoder layer is then used to decode the adapted feature encoding in a sequence-to-sequence manner to generate an automated test script that conforms to the syntax of the target testing framework.

5. The method for generating automated test scripts based on deep learning according to claim 1, characterized in that, Also includes: The test framework API constraints and UI element positioning rules in the preset knowledge base are encoded into conditional probability distributions. During the decoding process of the decoder layer, the decoding generation direction is adjusted according to the conditional probability distributions in order to optimize the automated test scripts generated by the decoder layer. The automated test script is validated using a syntax validation module, and the automated test script is corrected based on the validation results using the repair rules in the preset knowledge base.

6. The method for generating automated test scripts based on deep learning according to claim 1, characterized in that, The step of extracting failure features from the execution result using a preset failure mining function and updating the failure features to a preset knowledge base includes: Using a preset failure detection function, error screenshots, UI element location information, and DOM structure information corresponding to the failure cases are obtained from the execution results; Image features are extracted from the erroneous screenshot to obtain the corresponding image features, and a preset image matching algorithm is used to determine the structural change points based on the UI element positioning information and the DOM structure information; New UI element positioning rules are generated based on the image features and the structural change points as failure features, and the failure features are updated to the preset knowledge base.

7. The method for generating automated test scripts based on deep learning according to any one of claims 1 to 6, characterized in that, The optimization of the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using a preset incremental learning scheduling function includes: The available computing resources of the current system are obtained by using a preset incremental learning scheduling function, and the prediction bias urgency of the preset dynamic Bayesian classification model and the script failure rate urgency of the preset deep learning model are calculated based on the execution results. Based on the urgency of the prediction bias, the urgency of the script failure rate, and the available computing resources, a preset multi-objective optimization algorithm is used to determine the update order and resource allocation strategy of the preset dynamic Bayesian classification model and the preset deep learning model, so as to complete the optimization of the preset dynamic Bayesian classification model and the preset deep learning model.

8. An automated test script generation device based on deep learning, characterized in that, include: The data parsing module is used to acquire test cases and parse the test cases to extract key test information; The test cases include test steps and descriptions of expected test results; The priority scheduling module is used to classify and evaluate the test cases based on the key test information using a preset dynamic Bayesian classification model to obtain the risk probability corresponding to the test cases, and adjust the priority of the test cases according to the risk probability using a preset weight adjustment function. The script generation module is used to generate automated test scripts that conform to the target testing framework based on priority-adjusted test cases using a preset deep learning model; the preset deep learning model consists of an input layer, an encoding layer, a LoRA adaptation layer, a decoder layer, and an output layer. The script execution module is used to execute the automated test script to generate corresponding execution results, extract failure features from the execution results using a preset failure mining function, and update the failure features to a preset knowledge base; The preset knowledge base provides rule support for the script generation and optimization process of the preset deep learning model; The model optimization module is used to optimize the preset dynamic Bayesian classification model and the preset deep learning model based on the execution results using a preset incremental learning scheduling function.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the deep learning-based automated test script generation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the deep learning-based automated test script generation method as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Use case generation method based on multi-modal data, medium, device and product

    CN122332293A