AI algorithm-based Selenium automatic script generation method and system

Through the Selenium automated script generation method based on AI algorithm, AIGC technology and pre-trained models are used to quickly generate scripts, combined with low-code platforms to realize multi-terminal collaboration and version management, solving the problem of time-consuming and labor-intensive generation of traditional automated scripts and low management efficiency. Improve the ability to deal with task changes and the development speed of automated testing.

CN119127721AActive Publication Date: 2024-12-13JIANGXI MALI INTELLIGENT TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411612786.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2024-12-13
Estimated Expiration
2044-11-13

AI Technical Summary

Technical Problem

Traditional automated script generation requires manual writing of a large amount of code, which is time-consuming and labor-intensive, and needs to be re-written when facing new tasks or environments. It has poor ability to deal with task changes and low management and collaboration efficiency.

Method used

Using Selenium automated script generation method based on AI algorithms, automatically generate scripts through AIGC technology, use pre-trained neural network models to quickly adapt to new tasks, combine with low-code development platform to realize multi-terminal real-time collaboration and version management, reducing manual coding requirements and management Complexity.

Benefits of technology

It greatly improves script generation efficiency, reduces the workload of training from scratch, improves the ability to deal with task changes, simplifies the deployment and management of automated scripts, and solves the problems of code conflicts and low management efficiency in multi-person development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127721A_ABST
    Figure CN119127721A_ABST
Patent Text Reader

Abstract

The invention discloses a Selenium automatic script generation method and system based on an AI algorithm, and relates to the technical field of script generation. Preliminary setting of a neural network model is performed based on a target task, and a trained automatic script and a loss function are used to optimize neural network model parameters, so that the accuracy of the neural network model is improved; and applying the pre-trained neural network model to a new task by using a transfer learning technology, representing a performance index of the current neural network model through a state space, representing an adjustable parameter or structure of the neural network model through an action space, and performing reward or punishment according to the expression of the neural network model through a positive and negative feedback mechanism. And enabling the neural network model to output a final automation script. The script is automatically generated through the AIGC technology, the requirement for manual coding is reduced, the script generation efficiency is greatly improved, the pre-trained neural network model can quickly adapt to a new task, the workload of training from zero is reduced, and the task change coping capacity is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of script generation, and in particular to a Selenium automated script generation method and system based on an AI algorithm. Background Art

[0002] With the continuous advancement of Internet technology, software can be seen everywhere in our daily life, and all walks of life cannot do without the support of software. However, in order to ensure the reliability of software in use, software testing is an indispensable part. Traditional functional testing takes a lot of time, and the writing of code in the process of automated testing is time-consuming and laborious. Therefore, automated scripts have emerged, which are used to perform automated testing on software. The prior art has the following defects: 1. Traditional automation script generation often requires manual writing of a large amount of code, which is time-consuming and labor-intensive. In addition, the automation script needs to be rewritten when facing new tasks or environments, and the ability to cope with task changes is poor; 2. After the automation script is generated, the management and collaboration of the existing automation scripts are usually scattered, lacking efficient real-time collaboration and version control mechanisms. In addition, the deployment process of the automation script is often complicated, especially requiring manual operations and multiple debugging, which reduces the management efficiency of the automation script. Summary of the invention

[0003] The purpose of the present invention is to provide a Selenium automated script generation method and system based on an AI algorithm. The script is automatically generated by AIGC technology, which reduces the need for manual coding and greatly improves the efficiency of script generation. The pre-trained neural network model can quickly adapt to new tasks, reducing the workload of training from scratch and improving the ability to cope with task changes.

[0004] In order to achieve the above object, the present invention provides the following technical solution: a Selenium automation script generation method based on an AI algorithm, the generation method comprising the following steps: The generation system collects and organizes existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model; Perform preliminary settings of the neural network model based on the target task, and use the trained automated scripts and loss functions to optimize the neural network model parameters; Use transfer learning technology to apply pre-trained neural network models to new tasks, use state space to represent the performance indicators of the current neural network model, use action space to represent the adjustable parameters or structure of the neural network model, and use positive and negative feedback mechanisms to reward or punish the neural network model according to its performance, so that the neural network model outputs the final automation script; Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts.

[0005] In a preferred embodiment, a preliminary setting of a neural network model is performed based on the target task, and the trained automated script and loss function are used to optimize the neural network model parameters, including the following steps: Select the number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions based on the test task information, and use position encoding to add position information to the input embedding; After initializing the learning rate, use the learning rate warm-up strategy to gradually increase the learning rate, select the batch size to balance the training speed and memory consumption, and use the AdamW optimizer for parameter optimization; Convert several automated scripts into input feature vectors and organize them into data sets, which are divided into training set, validation set and test set. The training set is used for neural network model training, the validation set is used for hyperparameter tuning, and the test set is used for final neural network model evaluation. Through the forward propagation process, the neural network model generates predictions of the script from the natural language input, evaluates the loss value between the automated script generated by the neural network model and the actual script through the cross-entropy loss algorithm, and uses the back-propagation algorithm to update the neural network model parameters according to the loss value.

[0006] In a preferred embodiment, the number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions are selected according to the test task information, including the following steps: The data volume, task dependency depth, and sequence length of the test task are obtained, and the selection index is calculated based on the data volume, task dependency depth, and sequence length. The expression is: , where To select the index, is the amount of data, is the task dependency depth, is the sequence length, , , are the proportional coefficients of data volume, task dependency depth, and sequence length, respectively, and , , All are greater than 0; The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether it is necessary to adjust the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions. If the selection index is less than or equal to the index threshold, it is determined that the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions do not need to be adjusted. If the selection index is greater than the index threshold, it is determined that the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions need to be adjusted.

[0007] In a preferred embodiment, when it is determined that the number of initial Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions need to be adjusted, the adjustment steps are: By selecting the index, the initial number of Transformer layers and the initial number of attention heads in each layer are adjusted. The adjustment algorithm is: , where is the number of Transformer layers after adjustment, is the number of attention mechanisms per layer after adjustment, is the initial number of Transformer layers, is the initial number of attention mechanisms per layer, is the selection index; When it is determined that the initial input / output embedding dimension does not need to be adjusted, the initial input / output embedding dimension is selected as 512, and when it is determined that the initial input / output embedding dimension needs to be adjusted, the adjusted input / output embedding dimension is selected as 1024.

[0008] In a preferred embodiment, the pre-trained neural network model is applied to a new task using transfer learning technology, and the neural network model outputs a final automation script, including the following steps: Collect the data set of the new task, convert the input data of the new task into the format of the neural network model, freeze some layer parameters in the pre-trained neural network model, and keep the parts related to the new task for training; Adjust the size of the fully connected layers of the neural network model according to the complexity of the new task and the characteristics of the data; After multiple rounds of training and feedback adjustments, the neural network model outputs an optimized automation script.

[0009] In a preferred embodiment, a low-code development platform is used to test and deploy automation scripts, and the Codeup-OpenAPI open interface is integrated to realize multi-terminal real-time collaboration and version management of automation scripts, including the following steps: Import the generated automation script into the low-code development platform. The low-code development platform provides a user interface for developers to operate. On the low-code platform, the automation script is displayed in a visual form. The low-code platform inserts breakpoints during the execution of the automation script to view input and output data. After the automation script is completed, the low-code platform provides a test result report. The low-code development platform integrates CI / CD functions, deploys automated scripts to the test environment with one click, and automatically handles script version management, dependency installation, and permission configuration; Use Codeup-OpenAPI to integrate the generated automation script with the platform's version management system, so that multiple developers can modify the same automation script at the same time through Codeup-OpenAPI; Every time an automation script is updated and submitted, Codeup's version control function will automatically create a new version record. With the collaboration of Codeup-OpenAPI, each update of the automation script is synchronized to multiple ports in real time.

[0010] In a preferred embodiment, the generation system collects and organizes existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model, including the following steps: Acquire and aggregate automation scripts from existing projects or platforms, classify and archive the collected scripts, and mark the functional modules and key steps involved in the scripts; Preprocess the automation scripts, remove redundant code, repeated logic and irrelevant debugging information, and perform code standardization, including format unification and variable naming standardization; Perform semantic annotation based on the structure and function of the script, mark the key operation steps, input and output parameters, logical judgment information, and annotate exception handling and error logs; The cleaned and labeled automation script is represented in the form of a vector or feature map.

[0011] Selenium automated script generation system based on AI algorithm, including sorting module, optimization module, output module and management module; Arrangement module: The generation system collects and arranges existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model; Optimization module: Preliminary setting of the neural network model based on the target task, and optimization of the neural network model parameters using the trained automated script and loss function; Output module: Use transfer learning technology to apply the pre-trained neural network model to new tasks, use the state space to represent the performance indicators of the current neural network model, use the action space to represent the adjustable parameters or structure of the neural network model, and use the positive and negative feedback mechanism to reward or punish the performance of the neural network model, so that the neural network model outputs the final automation script; Management module: Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts.

[0012] In the above technical solution, the technical effects and advantages provided by the present invention are: 1. The present invention uses the automated script as the input and output of the neural network model after code cleaning and marking, performs preliminary settings of the neural network model based on the target task, uses the trained automated script and loss function to optimize the parameters of the neural network model, uses the transfer learning technology to apply the pre-trained neural network model to the new task, represents the performance indicators of the current neural network model through the state space, represents the adjustable parameters or structure of the neural network model through the action space, and uses the positive and negative feedback mechanism to reward or punish according to the performance of the neural network model, so that the neural network model outputs the final automated script. The script is automatically generated by AIGC technology, which reduces the need for manual coding and greatly improves the efficiency of script generation. The pre-trained neural network model can quickly adapt to new tasks, reduces the workload of training from scratch, and improves the ability to cope with task changes.

[0013] 2. The present invention uses a low-code development platform to test and deploy automated scripts, and integrates the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts. By integrating the Codeup-OpenAPI open interface, the solution supports multi-person online collaboration, real-time updates, and version management of automated scripts, solving the problems of code conflicts and inefficient management that may occur during the development process of multiple people. Through the low-code development platform, the deployment process of automated scripts is simplified, allowing testers to quickly complete testing and application deployment through visual tools, significantly accelerating the development and delivery of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0015] Figure 1The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0016] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0017] Example 1: Please refer to Figure 1 As shown, the Selenium automated script generation method based on the AI ​​algorithm described in this embodiment includes the following steps: The generation system collects and organizes existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model, preliminarily sets the neural network model based on the target task, uses the trained automation scripts and loss function to optimize the neural network model parameters, uses transfer learning technology to apply the pre-trained neural network model to new tasks, represents the performance indicators of the current neural network model through the state space, represents the adjustable parameters or structure of the neural network model through the action space, and uses the positive and negative feedback mechanism to reward or punish according to the performance of the neural network model, so that the neural network model outputs the final automation script, uses the low-code development platform to test and deploy the automation script, and integrates the Codeup-OpenAPI open interface to realize multi-terminal real-time collaboration and version management of automation scripts.

[0018] This application uses the code of the automated script as the input and output of the neural network model after cleaning and marking it, performs preliminary settings of the neural network model based on the target task, uses the trained automated script and loss function to optimize the parameters of the neural network model, uses the transfer learning technology to apply the pre-trained neural network model to the new task, represents the performance indicators of the current neural network model through the state space, represents the adjustable parameters or structure of the neural network model through the action space, and uses the positive and negative feedback mechanism to reward or punish according to the performance of the neural network model, so that the neural network model outputs the final automated script. Automatically generating scripts through AIGC technology reduces the need for manual coding and greatly improves the efficiency of script generation. Pre-trained neural network models can quickly adapt to new tasks, reducing the workload of training from scratch and improving the ability to cope with task changes.

[0019] This application uses a low-code development platform to test and deploy automated scripts, and integrates the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts. By integrating the Codeup-OpenAPI open interface, the solution supports multi-person online collaboration, real-time updates, and version management of automated scripts, solving the problems of code conflicts and inefficient management that may occur during the multi-person development process. Through the low-code development platform, the deployment process of automated scripts is simplified, allowing testers to quickly complete testing and application deployment through visual tools, significantly accelerating the development and delivery of automated testing.

[0020] The system collects and organizes existing automation scripts. These scripts are cleaned and tagged to ensure that they are suitable as input and output of the model. This step optimizes the code by unifying the format, standardizing comments, and removing redundant parts to improve the efficiency and accuracy of subsequent processing.

[0021] According to the needs of automated testing, the system selects the appropriate model architecture and algorithm (such as decision trees, neural networks, or deep learning models), and performs preliminary model settings based on the target tasks. Subsequently, the trained automated scripts and appropriate loss functions are used to optimize the model parameters, thereby continuously improving the model performance and prediction accuracy. For further optimization, the system will also dynamically adjust hyperparameters (such as learning rate, batch size, etc.) to enhance the model training effect.

[0022] The system uses transfer learning technology to apply neural network models pre-trained on large-scale data to new tasks. Transfer learning can use existing knowledge to fine-tune some or all parameters to adapt the model to the characteristics and requirements of new tasks. This method not only allows you to quickly get started with new tasks, but also avoids training large models from scratch, saving a lot of computing resources.

[0023] During the automated script generation process, the system will define the state space, action space, and reward function to enhance the model's self-optimization capabilities.

[0024] State space: represents the performance indicators of the current model, such as accuracy, execution speed, etc.

[0025] Action space: represents the parameters or structures that can be adjusted by the model, including learning rate, number of layers, number of neurons, etc.

[0026] Reward function: Through positive and negative feedback mechanisms, the model is rewarded or punished based on its performance. The system continuously learns the optimal decision-making strategy through the reward function, ensuring that the model can be intelligently optimized based on performance indicators and gradually improve the effect of automated script generation.

[0027] The system introduces a low-code development platform, which aims to reduce the need for testers to manually code, allowing them to build and deploy automated testing applications more quickly. By providing visual drag-and-drop tools, preset component libraries, and property configuration functions, testers can intuitively build test projects. This approach greatly simplifies the work of writing code from scratch, improves the efficiency of testing and application deployment, and accelerates the overall process of software development.

[0028] In order to improve the online collaboration capabilities of multiple people, the system integrates the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts. The system can not only efficiently manage API documents, but also help team members complete version updates and maintenance more quickly through intelligent completion and code generation tools to ensure continuous improvement of code quality. The multi-person collaboration mode further improves the management efficiency of APIs and the overall development efficiency of automated scripts.

[0029] Embodiment 2: The generation system collects and organizes existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model, including the following steps: Obtain and aggregate automation scripts from existing projects or platforms to ensure that the collected data covers different tasks and application scenarios. Categorize and archive the collected scripts, mark the functional modules and key steps involved in the scripts, and prepare for subsequent cleaning and labeling work.

[0030] Preprocess the script to remove redundant code, repeated logic, and irrelevant debugging information to ensure that the code is concise and efficient for subsequent model processing. Standardize the code, including format unification and variable naming standardization, to reduce unnecessary complexity.

[0031] According to the structure and function of the script, semantic annotation is performed to mark key operation steps, input and output parameters, logical judgment and other information to facilitate model understanding and processing. Common exception handling and error logs are marked to provide the model with more training data on exception handling.

[0032] Convert the cleaned and labeled scripts into an input format suitable for the neural network model, usually expressed in the form of vectors, feature maps, etc. Determine the input features and target outputs of the model, that is, the goals that the model needs to learn based on the script data, such as script generation rules, logic optimization, etc.

[0033] Suppose we are in a software testing project, and the existing automated scripts are used to test the account management function of a bank application. The main automated testing tasks include login verification, account balance query, transfer operations, etc. Next, these scripts are processed into the input and output of the neural network model through the following steps.

[0034] Collect automation scripts from existing testing frameworks (such as Selenium or JUnit). For example, the automation scripts of a banking application may include the following operations: login verification script, script for querying account balance, script for transfer operation.

[0035] The collected scripts should include different scenarios, such as correct and incorrect credential input during login, successful and failed operations during transfer, and classify the scripts, filing login scripts in the "account verification" category, filing transfer operations in the "fund operation" category, and filing and labeling the specific steps of the scripts (such as input, verification, and feedback).

[0036] Remove redundant code: such as repeated debugging information or log output. Suppose there are multiple repeated print statements in the login script, remove these redundant parts, and after cleaning, keep the necessary log and execution step information.

[0037] Format uniformity: Make sure all code follows uniform indentation rules and variable naming conventions, such as changing usrname to username, to avoid spelling errors and inconsistencies.

[0038] Consistency in variable naming: For example, standardize similar variable names in multiple scripts, such as unifying userID as username.

[0039] Key step marking: According to the function of the script, mark the key steps in the login verification, such as entering the user name, entering the password, clicking the login button, and verifying the login result.

[0040] Exception handling annotation: Annotate abnormal scenarios, such as error log output when the account balance is insufficient, as training data for the model to identify and handle abnormal scenarios.

[0041] Convert to vector format: Convert the processed script content into a feature vector for neural network input. Each step of the automation script can be converted into a vector representation, for example: Input vector: [step1, step2, step3, ...]; Target output: automatically generated script logic, such as a successful transfer operation.

[0042] Determine the model input features: Input parameters such as username, password, amount, etc. are used as input features. The target output of the model is to be able to generate a complete script that meets these parameters.

[0043] Based on the target task, the neural network model is initially set up, and the trained automated script and loss function are used to optimize the neural network model parameters, including the following steps: The number of Transformer layers, the number of attention heads in each layer, and the input / output embedding dimensions are selected according to the test task information. In order to capture the order information of the sequence, position encoding is used to add the position information to the input embedding to maintain the input order dependency. Learning rate: Initialize a small learning rate (such as 0.0001) to ensure stable training of the neural network model. And use the learning rate warm-up strategy to gradually increase the learning rate to stabilize the optimization process.

[0044] Batch size: Choose a batch size (such as 32 or 64) to balance training speed and memory consumption.

[0045] Optimizer: The AdamW optimizer is used for parameter optimization. This optimizer combines weight decay and can better handle large-scale neural network training tasks.

[0046] Loss function: Cross-Entropy-Loss is selected to evaluate the gap between the automated script generated by the neural network model and the actual script. This loss function helps to improve the accuracy of the neural network model in the script generation task.

[0047] After converting several automated scripts into input feature vectors, they are organized into data sets, which are divided into training sets, validation sets, and test sets. The training set is used for neural network model training, the validation set is used for hyperparameter tuning, and the test set is used for final neural network model evaluation.

[0048] Through the forward propagation process, the neural network model generates predictions of the script from the natural language input, calculates the loss between the output script of the neural network model and the true automated script, uses the cross entropy loss function, and uses the back propagation algorithm to update the neural network model parameters according to the loss value to minimize the error.

[0049] Through the validation set performance during the training process, adjust hyperparameters such as learning rate and batch size to find the optimal configuration. In order to avoid gradient explosion, use gradient clipping technology, limit the maximum norm of the gradient, maintain training stability, and use the Dropout layer (usually set between 0.1 and 0.3) to prevent the neural network model from overfitting.

[0050] Select the appropriate number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions based on the test task information, including the following steps: The data volume, task dependency depth, and sequence length of the test task are obtained, and the selection index is calculated based on the data volume, task dependency depth, and sequence length. The expression is: , where To select the index, is the amount of data, is the task dependency depth, is the sequence length, , , are the proportional coefficients of data volume, task dependency depth, and sequence length, respectively, and , , All are greater than 0; The larger the selection index is, the greater the overall complexity of the test task is, and the larger the number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions are required. The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether it is necessary to adjust the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions. If the selection index is less than or equal to the index threshold, it is determined that there is no need to adjust the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions. If the selection index is greater than the index threshold, it is determined that the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions need to be adjusted.

[0051] The data volume usually refers to the number of samples or data set size used in the test task. The task dependency depth is analyzed through the task flowchart or dependency tree to find out the dependencies between different operation steps or modules. The more levels of dependency, the greater the depth. The sequence length can be determined by marking the start and end time of the operation, defining the number of all steps from the starting point to the end point.

[0052] When it is determined that the number of initial Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions need to be adjusted, the adjustment steps are: By selecting the index, the initial number of Transformer layers and the initial number of attention heads in each layer are adjusted. The adjustment algorithm is: , where is the number of Transformer layers after adjustment, is the number of attention mechanisms per layer after adjustment, is the initial number of Transformer layers, is the initial number of attention mechanisms per layer, To select the index, it should be noted that in this application, the initial number of Transformer layers is the minimum number of layers, usually 6 layers, and the initial number of attention mechanism heads in each layer is the minimum number of heads, usually 8; When it is determined that the initial input / output embedding dimension does not need to be adjusted, the initial input / output embedding dimension is selected as 512, and when it is determined that the initial input / output embedding dimension needs to be adjusted, the adjusted input / output embedding dimension is selected as 1024.

[0053] Suppose we have a set of automation scripts, and the goal is to generate corresponding automation scripts based on the requirements described in natural language. Take a simple scenario as an example, a software needs to test the login function under different conditions, and the input natural language description may be: "Test the user's login function under valid and invalid credentials."

[0054] Set the Transformer model to a 6-layer encoder and decoder structure.

[0055] The self-attention mechanism uses 8 attention heads in each layer.

[0056] The input and output embedding dimensions are 512 to maintain a balance between information richness and training speed.

[0057] Use positional encoding to embed sequential information, such as the order of steps, into the model.

[0058] The learning rate is set to 0.0001, and a learning rate warm-up strategy is adopted to gradually increase the learning rate.

[0059] The batch size is set to 64, which is suitable for processing larger amounts of data.

[0060] The AdamW optimizer is used to optimize the parameters of the Transformer model and combine it with weight decay to reduce the risk of overfitting.

[0061] The cross-entropy loss function is used to evaluate the gap between the model-generated script and the actual script.

[0062] The dataset is divided into training set (70%), validation set (20%) and test set (10%).

[0063] The training set is used to train the model, and the validation set is used for hyperparameter tuning.

[0064] Use transfer learning technology to apply the pre-trained neural network model to new tasks, use the state space to represent the performance indicators of the current neural network model, use the action space to represent the adjustable parameters or structure of the neural network model, and use the positive and negative feedback mechanism to reward or punish the performance of the neural network model, so that the neural network model outputs the final automation script, including the following steps: Conduct a detailed analysis of the new task to determine its key features (such as input type, output requirements, task scenarios, etc.), ensure that the new task has a certain similarity with the task of the pre-trained model to facilitate the effectiveness of transfer learning, collect data sets for the new task, and convert the input data of the new task into a format acceptable to the model, which usually includes steps such as input feature vectorization and normalization.

[0065] Freeze some layer parameters in the pre-trained neural network model and keep only the parts related to the new task for training to retain the model's existing knowledge. Usually, the first few layers (such as feature extraction layers) are retained, and the latter layers (such as decision layers) are adjusted and trained. According to the complexity of the new task and data characteristics, the output layer of the model (such as the size of the fully connected layer) is adjusted to ensure that the model can adapt to the target output of the new task.

[0066] The state space represents the performance indicators of the current neural network model. Common performance indicators include accuracy, loss value, quality of generated scripts, etc. The action space represents the adjustable parameters or structures in the neural network model, mainly including learning rate, number of layers, number of attention heads, activation function selection, etc. Each action corresponds to a model parameter adjustment, and the model is given positive or negative feedback based on its performance in the new task. For example, when the script generated by the model is close to the target script, positive feedback is given; when it deviates greatly from the target, negative feedback is given. In this way, the model can gradually learn the optimal strategy.

[0067] After multiple trainings and feedback adjustments, the model will output optimized automation scripts. At this point, the model can more accurately generate automation scripts that meet the requirements of new tasks.

[0068] A specific example of the above scenario is as follows: Collected existing manual test cases and logs for the software module. These test cases record input parameters, expected outputs, test steps, exception handling and other information in detail; Convert manual test cases into structured data format. Specifically, convert the input parameters, test steps, expected outputs and other information of each test step into input feature vectors that can be understood by the neural network model. The input data includes: Input parameters: such as input box value and button click event.

[0069] Expected output: such as test result logs or UI responses.

[0070] Exception handling: record the system's exception returns or logs.

[0071] A test case of a certain step is recorded as input parameters [user ID, input amount, confirmation button] and expected output [display success prompt]. This information is converted into a vector [0.1, 0.5, 0.8] and used as input features.

[0072] A Transformer model that has been pre-trained on other automated script generation tasks is used. The first few layers of this model have learned common script generation patterns and operation steps. The parameters of the first few layers of the model are frozen because the general feature extraction capabilities of these layers are still valid in the new task. Only the parameters of the last few layers are retained for training to adapt to the special needs of the new task. The first few layers of the pre-trained model have learned how to extract common features from the input data, such as input parameters, operation steps, etc. It is decided to freeze these layers and only adjust the last few layers to generate automated scripts suitable for this software module.

[0073] Since the new task is much more complex than the original task, including more input parameters and logical judgments, it was decided to adjust the output layer of the model to adapt to the needs of the new task. The size of the last fully connected layer was adjusted from the original 100 neurons to 200 neurons to adapt to the more complex script generation task. When generating automated scripts, the new task contains more input steps, so the number of neurons in the output layer was adjusted so that the model can generate more detailed and complex test scripts.

[0074] Use the dataset of the new task to perform multiple rounds of training on the frozen model. After each round of training, the accuracy and loss value of the model are calculated by comparing the automated scripts generated by the model with the actual manual test cases. According to the performance of the model, the learning rate and model parameters are adjusted. When the generated automated script is successfully executed in the actual test, the model is given positive feedback to increase the probability of the model generating similar scripts; when the script fails, negative feedback is given to adjust the generation strategy. After multiple trainings, the model begins to gradually generate more accurate automated scripts. For example, the original model only generated basic input and click operations, but now it can generate more complex logical judgments and exception handling steps.

[0075] After multiple rounds of training and feedback optimization, the model outputs the final automated script. The script has been verified to meet the expected test requirements and can automatically perform functional testing of software modules. The performance of the model is evaluated through the test set. The automated script generated by the model is efficient and accurate in new tasks and can reduce the workload of manual testing.

[0076] The final output automation script includes the following: Enter the user ID, enter the amount, and click the Confirm button.

[0077] Check whether the page displays a success message.

[0078] If an error occurs, log it and catch the exception to automatically retry the operation.

[0079] Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts, including the following steps: Script import: Import the generated automation script into the low-code development platform, which provides a simplified user interface for developers to operate without a lot of manual coding. Complex logic can be completed by dragging and dropping components or entering a small amount of code.

[0080] Script visualization: On low-code platforms, scripts can be presented in a visual form, making it easier for developers to understand and quickly adjust them. For example, you can see the structure of the test process, input parameters, and expected outputs through a graphical interface.

[0081] Test environment configuration: Configure the corresponding test environment in the low-code platform, including designated test servers, simulation devices, virtual machines, etc. Ensure that the environment when the automation script is running is as consistent as possible with the actual production environment.

[0082] Script execution and debugging: Execute the automated script to check whether it can complete the expected functional testing tasks. Low-code platforms usually have debugging functions that can insert breakpoints during script execution, view input and output data, and troubleshoot potential problems.

[0083] Result analysis: After the automated script is completed, the low-code platform will provide a detailed test result report, including passed test cases, failed test steps, logs and error information, etc., to facilitate further optimization of the script.

[0084] Continuous Integration / Continuous Deployment (CI / CD) Pipeline: The low-code development platform integrates CI / CD functions, which can combine automated scripts with the application deployment process. After the script passes the test, it automatically enters the deployment process to ensure that the script automatically executes the corresponding test tasks and supports the continuous iterative development of the software.

[0085] Deployment environment selection: Select the appropriate deployment environment, such as development, testing, pre-production, production, etc. Ensure that the deployment environment of the script is compatible with the business application environment and support seamless switching between different environments.

[0086] Automated deployment: Deploy scripts with one click through the low-code platform and publish them to the test environment. The platform automatically handles script version management, dependency installation, and related permission configuration.

[0087] Open interface connection: Use Codeup-OpenAPI to integrate the generated automation script with the platform's version management system. Codeup-OpenAPI provides version control and collaborative development interfaces and supports multi-terminal synchronization.

[0088] Real-time collaboration: With Codeup-OpenAPI, multiple developers can modify the same automation script at the same time. The platform provides a real-time synchronization mechanism to ensure that team members can collaborate on the same code base on different devices or platforms without conflicts.

[0089] Version management: Every time you update and submit a script, Codeup's version control function will automatically create a new version record, supporting version backtracking and comparison. Through the deep integration of the low-code platform and Codeup, the version history tracking of automated scripts can be achieved to ensure that every change can be traced.

[0090] Cross-platform deployment: Through the low-code platform, automation scripts can be quickly deployed to multiple terminal environments, such as Web, mobile, servers, etc. Low-code platforms usually have cross-platform compatibility capabilities to ensure that scripts can run seamlessly on different terminals.

[0091] Real-time update synchronization: With the collaboration of Codeup-OpenAPI, every update of the script can be synchronized to multiple ports in real time. Whether it is the web terminal or the mobile terminal, users can obtain the latest version of the script in real time to ensure the consistency of the test environment on each terminal.

[0092] Permission management: In a low-code platform, different permissions can be assigned to different team members. For example, some developers can only view and run scripts, while others can edit and deploy scripts. The permission management mechanism is seamlessly integrated with Codeup-OpenAPI to ensure code security and operational transparency.

[0093] Audit and monitoring: The platform supports auditing the operation records of automation scripts and recording the operation traces of each user. Combined with the log function of Codeup, it can effectively monitor the modification and execution of automation scripts and promptly discover potential security risks.

[0094] A specific example of the above scenario is as follows: Suppose you are developing a payment module for an e-commerce platform and want to use automated test scripts to verify the correctness of the payment process. You decide to use a low-code development platform to speed up the development, testing, and deployment of automated scripts, and integrate Codeup-OpenAPI for multi-terminal collaboration and version management. The following are the specific steps to implement this process.

[0095] Scenario: AI has been used to generate an automated test script for the payment process (including payment success, payment failure, refund process, etc.).

[0096] Operation: Import the automation script into the low-code development platform, which will automatically parse and present the script in a visual process. For example, the platform will identify the steps of sending a payment request, verifying the payment status, and handling exceptions.

[0097] Developers can drag and drop components in the graphical interface to adjust the automated testing process and add or delete steps.

[0098] Scenario: You want to debug the payment process during test execution, especially to verify the input and output data for different payment states (such as payment success, payment failure).

[0099] Operation: On the low-code platform, you can easily insert breakpoints for certain steps in the test process, such as after the payment request is sent or before the payment result is returned. Breakpoints can pause the script and allow you to check request parameters, response data, and log information.

[0100] When you run the script, a payment request is sent to a payment gateway (such as PayPal or Stripe), and you can use breakpoints to inspect the data returned by the gateway (such as a status code indicating whether the payment was successful or failed).

[0101] After the script is completed, the low-code platform will automatically generate a detailed test report, showing the input and output data and test results of all steps during the script execution process.

[0102] Scenario: You want to publish debugged automation scripts to the test environment for continuous integration and deployment to ensure that these tests can be automatically executed every time the code is updated.

[0103] Operation: The low-code platform integrates CI / CD functions, allowing one-click deployment of automation scripts. Scripts can be published to the test environment, and the platform automatically handles dependency installation and permission configuration.

[0104] When the payment module code is updated, the CI / CD function will automatically execute these automated tests to ensure that each update does not introduce new problems.

[0105] Scenario: Multiple developers need to modify the automation scripts of the same payment module at the same time and synchronize these modifications on multiple ports.

[0106] Operation: By integrating Codeup-OpenAPI, you can integrate automation scripts with Codeup's version control system. Multiple developers can modify scripts simultaneously through Codeup-OpenAPI and view each other's changes in real time.

[0107] Every time a developer updates and submits a script, Codeup automatically generates a new version record and records all the change details for easy backtracking and review.

[0108] Scenario: The automated scripts of the payment module need to be deployed to the web and mobile terminals simultaneously to ensure consistent testing on different platforms.

[0109] Operation: Codeup-OpenAPI's collaboration feature allows each update of the script to be synchronized to different ports in real time. Whether it is the web or mobile terminal, all updates can be applied in real time to ensure that the test is carried out synchronously on each port.

[0110] Example 3: Please refer to Figure 1 As shown, the Selenium automated script generation system based on the AI ​​algorithm described in this embodiment includes a sorting module, an optimization module, an output module, and a management module; Arrangement module: The generation system collects and arranges existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model, and sends the automation scripts to the optimization module; Optimization module: Perform preliminary settings of the neural network model based on the target task, use the trained automation script and loss function to optimize the neural network model parameters, and send the pre-trained neural network model to the output module; Output module: Use transfer learning technology to apply the pre-trained neural network model to new tasks, use the state space to represent the performance indicators of the current neural network model, use the action space to represent the adjustable parameters or structure of the neural network model, and use the positive and negative feedback mechanism to reward or punish the performance of the neural network model, so that the neural network model outputs the final automation script, which is sent to the management module; Management module: Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts.

[0111] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.

[0112] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0113] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.

Claims

1. Selenium automation script generation method based on AI algorithm, characterized by: The generation method comprises the following steps: The generation system collects and organizes existing automation scripts, cleans and tags the automation scripts as input and output of the neural network model; Perform preliminary settings of the neural network model based on the target task, and use the trained automated scripts and loss functions to optimize the neural network model parameters; Use transfer learning technology to apply pre-trained neural network models to new tasks, use state space to represent the performance indicators of the current neural network model, use action space to represent the adjustable parameters or structure of the neural network model, and use positive and negative feedback mechanisms to reward or punish the performance of the neural network model, so that the neural network model outputs the final automation script; Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts.

2. The method for generating Selenium automated scripts based on AI algorithm according to claim 1, characterized in that: Based on the target task, the neural network model is initially set up, and the trained automated script and loss function are used to optimize the neural network model parameters, including the following steps: Select the number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions based on the test task information, and use position encoding to add position information to the input embedding; After initializing the learning rate, use the learning rate warm-up strategy to gradually increase the learning rate, select the batch size to balance the training speed and memory consumption, and use the AdamW optimizer for parameter optimization; Convert several automated scripts into input feature vectors and organize them into data sets, which are divided into training set, validation set and test set. The training set is used for neural network model training, the validation set is used for hyperparameter tuning, and the test set is used for final neural network model evaluation. Through the forward propagation process, the neural network model generates predictions of the script from the natural language input, evaluates the loss value between the automated script generated by the neural network model and the actual script through the cross-entropy loss algorithm, and uses the back-propagation algorithm to update the neural network model parameters according to the loss value.

3. The method for generating Selenium automated scripts based on AI algorithm according to claim 2, characterized in that: Select the number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions based on the test task information, including the following steps: The data volume, task dependency depth, and sequence length of the test task are obtained, and the selection index is calculated based on the data volume, task dependency depth, and sequence length. The expression is: , where To select the index, is the amount of data, is the task dependency depth, is the sequence length, , , are the proportional coefficients of data volume, task dependency depth, and sequence length, respectively, and , , All are greater than 0; The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether it is necessary to adjust the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions. If the selection index is less than or equal to the index threshold, it is determined that the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions do not need to be adjusted. If the selection index is greater than the index threshold, it is determined that the initial number of Transformer layers, the number of heads of each attention mechanism layer, and the input / output embedding dimensions need to be adjusted.

4. The method for generating Selenium automated scripts based on AI algorithm according to claim 3, characterized in that: When it is determined that the number of initial Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions need to be adjusted, the adjustment steps are: By selecting the index, the initial number of Transformer layers and the initial number of attention heads in each layer are adjusted. The adjustment algorithm is: , where is the number of Transformer layers after adjustment, is the number of attention mechanisms per layer after adjustment, is the initial number of Transformer layers, is the initial number of attention mechanisms per layer, is the selection index; When it is determined that the initial input / output embedding dimension does not need to be adjusted, the initial input / output embedding dimension is selected as 512, and when it is determined that the initial input / output embedding dimension needs to be adjusted, the adjusted input / output embedding dimension is selected as 1024.

5. The method for generating Selenium automated scripts based on AI algorithm according to claim 4, characterized in that: Use transfer learning technology to apply the pre-trained neural network model to new tasks. The neural network model outputs the final automation script, which includes the following steps: Collect the data set of the new task, convert the input data of the new task into the format of the neural network model, freeze some layer parameters in the pre-trained neural network model, and keep the parts related to the new task for training; Adjust the size of the fully connected layers of the neural network model according to the complexity of the new task and the characteristics of the data; After multiple rounds of training and feedback adjustments, the neural network model outputs an optimized automation script.

6. The method for generating Selenium automated scripts based on AI algorithm according to claim 5, characterized in that: Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts, including the following steps: Import the generated automation script into the low-code development platform. The low-code development platform provides a user interface for developers to operate. On the low-code platform, the automation script is displayed in a visual form. The low-code platform inserts breakpoints during the execution of the automation script to view input and output data. After the automation script is completed, the low-code platform provides a test result report. The low-code development platform integrates CI / CD functions, deploys automated scripts to the test environment with one click, and automatically handles script version management, dependency installation, and permission configuration; Use Codeup-OpenAPI to integrate the generated automation script with the platform's version management system, so that multiple developers can modify the same automation script at the same time through Codeup-OpenAPI; Every time an automation script is updated and submitted, Codeup's version control function will automatically create a new version record. With the collaboration of Codeup-OpenAPI, each update of the automation script is synchronized to multiple ports in real time.

7. The method for generating Selenium automated scripts based on AI algorithm according to claim 6, characterized in that: The generation system collects and organizes existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model, including the following steps: Acquire and aggregate automation scripts from existing projects or platforms, classify and archive the collected scripts, and mark the functional modules and key steps involved in the scripts; Preprocess the automation scripts, remove redundant code, repeated logic and irrelevant debugging information, and perform code standardization, including format unification and variable naming standardization; Perform semantic annotation based on the structure and function of the script, mark the key operation steps, input and output parameters, logical judgment information, and annotate exception handling and error logs; The cleaned and labeled automation script is represented in the form of a vector or feature map.

8. A Selenium automated script generation system based on an AI algorithm, used to implement the generation method according to any one of claims 1 to 7, characterized in that: Including sorting module, optimization module, output module and management module; Arrangement module: The generation system collects and arranges existing automation scripts, cleans and marks the automation scripts as input and output of the neural network model; Optimization module: Preliminary setting of the neural network model based on the target task, and optimization of the neural network model parameters using the trained automated script and loss function; Output module: Use transfer learning technology to apply the pre-trained neural network model to new tasks, use the state space to represent the performance indicators of the current neural network model, use the action space to represent the adjustable parameters or structure of the neural network model, and use the positive and negative feedback mechanism to reward or punish the performance of the neural network model, so that the neural network model outputs the final automation script; Management module: Use the low-code development platform to test and deploy automation scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automation scripts.

Citation Information

Patent Citations

  • Electric quantity prediction method based on neural network

    CN117439069A

  • Code quality control method and device based on large language model

    CN117992069A

  • Code generation model fine tuning method and device based on clustering and natural language strategy optimization algorithm

    CN118468982A

  • Coordination scheduling algorithm based on deep neural network

    CN118607870A

  • Life cycle risk management and control method based on neural network algorithm

    CN118694673A

Cited By

  • UI automatic script editing system and method based on screenshot recognition

    CN120085969A

  • UI Automation Script Editing System and Method Based on Screenshot Recognition

    CN120085969B

  • A script automatic generation method based on a pipelined neural network architecture

    CN122925199A