Selenium automated script generation method and system based on AI algorithm
Automatically generate Selenium automation scripts through AI algorithms, combining transfer learning and low-code platform, solving the problem of time-consuming and labor-intensive generation of traditional automated scripts and low management efficiency, realizing efficient script generation and rapid deployment.
Patent Information
- Application Number
- CN202411612786.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2044-11-13
AI Technical Summary
Traditional automated script generation requires manual writing of a lot of code, which is time-consuming and labor-intensive, and is difficult to deal with new tasks or environmental changes, and is inefficient in management and collaboration.
Selenium automated script generation method based on AI algorithm is adopted, scripts are automatically generated through AIGC technology, pre-trained neural network models are used for transfer learning, and multi-terminal real-time collaboration and version management are achieved in combination with low-code development platform.
It greatly improves script generation efficiency, reduces the need for manual coding, quickly adapts to new tasks, improves the ability to deal with task changes, and solves the problem of inefficient multi-person collaboration and management, significantly speeding up the R&D and delivery of automated tests.
Smart Images

Figure CN119127721B_ABST
Abstract
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 is ubiquitous in our daily lives, and all walks of life are inseparable from the support of software. However, to ensure the reliability of software during use, software testing is an indispensable part. Traditional functional testing takes a lot of time, and the coding process of automated testing is time-consuming and labor-intensive. Therefore, automated scripts have emerged to automate software testing.
[0003] The existing technology has the following defects:
[0004] 1. Traditional automation script generation often requires manual writing of large amounts of code, which is time-consuming and labor-intensive. Furthermore, the automation scripts need to be rewritten when faced with new tasks or environments, and the ability to cope with task changes is poor.
[0005] 2. After the automation script is generated, the management and collaboration of the existing automation scripts are usually relatively 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
[0006] The purpose of the present invention is to provide a Selenium automated script generation method and system based on AI algorithms. By automatically generating scripts through AIGC technology, the need for manual coding is reduced, and the efficiency of script generation is greatly improved. 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.
[0007] To achieve the above objectives, the present invention provides the following technical solution: a Selenium automated script generation method based on an AI algorithm, the generation method comprising the following steps:
[0008] The generation system collects and organizes existing automation scripts, cleans and tags the automation scripts, and uses them as input and output for the neural network model.
[0009] Perform preliminary settings of the neural network model based on the target task, and use the trained automated script and loss function to optimize the neural network model parameters;
[0010] Use transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewarding or punishing the performance of the neural network model through a positive and negative feedback mechanism, the neural network model outputs the final automation script.
[0011] Use the low-code development platform to test and deploy automated scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts.
[0012] 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:
[0013] 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 positional encoding to incorporate positional information into the input embeddings.
[0014] After initializing the learning rate, we gradually increase the learning rate using a learning rate warm-up strategy, select a batch size to balance training speed and memory consumption, and use the AdamW optimizer for parameter optimization.
[0015] After converting several automated scripts into input feature vectors, they are organized into a dataset, which is then divided into a training set, a validation set, and a 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.
[0016] 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 backpropagation algorithm to update the neural network model parameters according to the loss value.
[0017] In a preferred embodiment, the number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions are selected based on the test task information, including the following steps:
[0018] Obtain the data volume, task dependency depth, and sequence length of the test task, and calculate the selection index based on the data volume, task dependency depth, and sequence length. The expression is:
[0019] , where is the selection 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 greater than 0;
[0020] The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions need to be adjusted. 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, 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, and the input / output embedding dimensions need to be adjusted.
[0021] In a preferred embodiment, 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:
[0022] The initial number of Transformer layers and the initial number of attention heads per layer are adjusted by selecting an index. 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;
[0023] 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. 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.
[0024] In a preferred embodiment, a 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:
[0025] Collect the dataset for 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 retain the parts related to the new task for training;
[0026] Adjust the size of the fully connected layers of the neural network model based on the complexity of the new task and the characteristics of the data;
[0027] After multiple rounds of training and feedback adjustments, the neural network model outputs an optimized automation script.
[0028] In a preferred embodiment, a low-code development platform is used to test and deploy automated scripts, and the Codeup-OpenAPI open interface is integrated to implement multi-terminal real-time collaboration and version management of automated scripts, including the following steps:
[0029] 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. When the automation script is executed, 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.
[0030] The low-code development platform integrates CI / CD functions, deploying automated scripts to the test environment with one click, and automatically handling script version management, dependency installation, and permission configuration;
[0031] Use Codeup-OpenAPI to integrate the generated automation script with the platform's version management system, allowing multiple developers to modify the same automation script simultaneously through Codeup-OpenAPI;
[0032] 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.
[0033] In a preferred embodiment, the generation system collects and organizes existing automation scripts, cleans and tags the automation scripts, and uses them as input and output of the neural network model, including the following steps:
[0034] Acquire and aggregate automation scripts from existing projects or platforms, categorize and archive the collected scripts, and mark the functional modules and key steps involved in the scripts;
[0035] Pre-process the automation scripts, remove redundant code, repeated logic, and irrelevant debugging information, and perform code standardization, including format unification and variable naming standardization;
[0036] Perform semantic annotation based on the structure and function of the script, mark key operation steps, input and output parameters, logical judgment information, and annotate exception handling and error logs;
[0037] The cleaned and labeled automation script is represented as a vector or feature map.
[0038] Selenium automated script generation system based on AI algorithm, including organization module, optimization module, output module, and management module;
[0039] Arrangement module: The generation system collects and organizes existing automation scripts, cleans and tags the automation scripts, and uses them as input and output of the neural network model;
[0040] Optimization module: performs preliminary settings of the neural network model based on the target task, and uses the trained automated script and loss function to optimize the neural network model parameters;
[0041] Output module: Use transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewarding or punishing the performance of the neural network model through a positive and negative feedback mechanism, the neural network model outputs the final automation script.
[0042] 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.
[0043] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0044] 1. The present invention cleans and marks the automated scripts as the input and output of the neural network model, performs preliminary settings for the neural network model based on the target task, uses the trained automated 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 a positive and negative feedback mechanism to reward or punish the neural network model according to its performance, so that the neural network model outputs the final automated script. Automatically generating scripts through AIGC technology reduces the need for manual coding and significantly 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.
[0045] 2. This invention uses a low-code development platform to test and deploy automated scripts, integrating 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, resolving the code conflicts and inefficient management issues that may arise 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 tests. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments described in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0047] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION
[0048] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0049] 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:
[0050] The generation system collects and organizes existing automation scripts, cleans and marks the automation scripts and uses them as input and output of the neural network model. The neural network model is preliminarily set based on the target task, and the trained automation scripts and loss functions are used to optimize the neural network model parameters. The pre-trained neural network model is applied to new tasks using transfer learning technology. The performance indicators of the current neural network model are represented by the state space, and the adjustable parameters or structure of the neural network model are represented by the action space. After rewarding or punishing the performance of the neural network model through a positive and negative feedback mechanism, the neural network model outputs the final automation script. The automation script is tested and deployed using a low-code development platform, and the Codeup-OpenAPI open interface is integrated to achieve multi-terminal real-time collaboration and version management of automation scripts.
[0051] 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 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 the neural network model according to its performance, 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. 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.
[0052] This application uses a low-code development platform to test and deploy automated scripts, integrating 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, resolving the code conflicts and inefficient management issues that may arise 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.
[0053] The system collects and organizes existing automation scripts. These scripts are cleaned and tagged to ensure they are suitable for model input and output. This step optimizes the code by standardizing formatting, standardizing comments, and removing redundant sections, improving the efficiency and accuracy of subsequent processing.
[0054] Based on the needs of automated testing, the system selects an appropriate model architecture and algorithm (such as a decision tree, neural network, or deep learning model) and performs preliminary model settings based on the target task. Subsequently, it uses trained automated scripts and appropriate loss functions to optimize model parameters, continuously improving model performance and prediction accuracy. For further optimization, the system also dynamically adjusts hyperparameters (such as the learning rate and batch size) to enhance model training results.
[0055] The system uses transfer learning technology to apply neural network models pre-trained on large-scale data to new tasks. Transfer learning leverages existing knowledge and adapts the model to the characteristics and requirements of the new task by fine-tuning some or all parameters. This approach not only allows for rapid learning of new tasks but also avoids training large models from scratch, saving significant computing resources.
[0056] 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.
[0057] State space: represents the performance indicators of the current model, such as accuracy, execution speed, etc.
[0058] Action space: represents the parameters or structures that can be adjusted by the model, including learning rate, number of layers, number of neurons, etc.
[0059] Reward function: Through a positive and negative feedback mechanism, the model is rewarded or penalized 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, gradually improving the effectiveness of automated script generation.
[0060] The system introduces a low-code development platform designed to reduce the need for testers to manually code, enabling them to more quickly build and deploy automated testing applications. By providing visual drag-and-drop tools, a pre-set component library, and property configuration capabilities, testers can intuitively build test projects. This approach significantly simplifies the task of writing code from scratch, improves the efficiency of testing and application deployment, and accelerates the overall software development process.
[0061] To enhance multi-person online collaboration, the system integrates the Codeup-OpenAPI open interface, enabling real-time, multi-terminal collaboration and version management for automated scripts. This system not only efficiently manages API documentation but also, through intelligent completion and code generation tools, helps team members more quickly complete version updates and maintenance, ensuring continuous improvement in code quality. This multi-person collaboration model further enhances API management efficiency and the overall efficiency of automated script development.
[0062] Example 2: The generation system collects and organizes existing automation scripts, cleans and tags the automation scripts and uses them as input and output of the neural network model, including the following steps:
[0063] Acquire and aggregate automation scripts from existing projects or platforms, ensuring that the collected data covers diverse tasks and application scenarios. Categorize and archive the collected scripts, labeling the functional modules and key steps involved in the scripts to prepare for subsequent cleaning and labeling.
[0064] Preprocess the script to remove redundant code, duplicate logic, and irrelevant debugging information to ensure the code is concise and efficient for subsequent model processing. Standardize the code, including formatting and variable naming, to reduce unnecessary complexity.
[0065] Based on the structure and function of the script, semantic annotation is performed to mark key operation steps, input and output parameters, logical judgments, and other information to facilitate model understanding and processing. Common exception handling and error logs are annotated to provide more training data on exception handling for the model.
[0066] Convert the cleaned and labeled scripts into an input format suitable for the neural network model, typically represented as vectors, feature maps, etc. Determine the model's input features and target outputs, i.e., the goals the model needs to learn based on the script data, such as script generation rules and logic optimization.
[0067] Let's assume we're working on a software testing project and have existing automated scripts testing the account management functionality of a banking application. Key automated testing tasks include login verification, account balance query, and transfer operations. Next, we'll process these scripts into the input and output of a neural network model using the following steps.
[0068] Collect automation scripts from existing testing frameworks (such as Selenium or JUnit). For example, the automation scripts for a banking application may include the following operations: login verification script, account balance query script, and transfer operation script.
[0069] 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. Login scripts should be filed in the "account verification" category, and transfer operations should be filed in the "fund operation" category. The specific steps of the script (such as input, verification, and feedback) should be archived and marked.
[0070] Remove redundant code, such as repeated debugging information or log output. For example, if there are multiple repeated print statements in a login script, remove these redundant parts and clean up, retaining the necessary log and execution step information.
[0071] Format uniformity: Ensure that all code follows uniform indentation rules and variable naming conventions, such as changing usrname to username, to avoid spelling errors and inconsistencies.
[0072] Consistency in variable naming: For example, standardize similar variable names in multiple scripts, such as unifying userID as username.
[0073] 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.
[0074] 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.
[0075] 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:
[0076] Input vector: [step1, step2, step3, ...];
[0077] Target output: automatically generated script logic, such as a successful transfer operation.
[0078] 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 generate a complete script that meets these parameters.
[0079] Initially set up the neural network model based on the target task, and use the trained automated script and loss function to optimize the neural network model parameters, including the following steps:
[0080] The number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions are selected appropriately based on the test task information. To capture the order of the sequence, positional encoding is used to incorporate positional information into the input embeddings, preserving input order dependencies.
[0081] Learning rate: Initialize a small learning rate (such as 0.0001) to ensure stable training of the neural network model. Use a warm-up strategy to gradually increase the learning rate to stabilize the optimization process.
[0082] Batch size: Choose a batch size (such as 32 or 64) to balance training speed and memory consumption.
[0083] Optimizer: The AdamW optimizer is used for parameter optimization. This optimizer, combined with weight decay, can better handle large-scale neural network training tasks.
[0084] 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 improve the accuracy of the neural network model in the script generation task.
[0085] After converting several automated scripts into input feature vectors, they organized the data into a dataset, which was then divided into a training set, a validation set, and a test set. The training set was used for neural network model training, the validation set was used for hyperparameter tuning, and the test set was used for final neural network model evaluation.
[0086] Through the forward propagation process, the neural network model generates a prediction of the script from the natural language input, calculates the loss between the output script of the neural network model and the real automated script, uses the cross entropy loss function, and uses the backpropagation algorithm to update the neural network model parameters according to the loss value to minimize the error.
[0087] 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 to limit the maximum norm of the gradient and maintain training stability. Use the Dropout layer (usually set between 0.1 and 0.3) to prevent the neural network model from overfitting.
[0088] 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. This involves the following steps:
[0089] Obtain the data volume, task dependency depth, and sequence length of the test task, and calculate the selection index based on the data volume, task dependency depth, and sequence length. The expression is:
[0090] , where is the selection 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 greater than 0;
[0091] The larger the selection index, the greater the overall complexity of the test task, and the larger the number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions required. The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions need to be adjusted. 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, 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, and the input / output embedding dimensions need to be adjusted.
[0092] Data volume typically refers to the number of samples or dataset size used in a test task. Task dependency depth is determined by analyzing the task's flowchart or dependency tree to identify the dependencies between different steps or modules. The more levels of dependency there are, the greater the depth. Sequence length can be determined by annotating the start and end times of an operation, defining the total number of steps from the starting point to the end point.
[0093] When it is determined that the initial number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions need to be adjusted, the adjustment steps are:
[0094] The initial number of Transformer layers and the initial number of attention heads per layer are adjusted by selecting an index. 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, For the purpose of index selection, 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;
[0095] 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. 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.
[0096] Suppose we have a set of automation scripts whose goal is to generate corresponding automation scripts based on requirements described in natural language. For example, a software needs to test the login function under different conditions. The input natural language description might be: "Test the user login function with valid and invalid credentials."
[0097] Set the Transformer model to a 6-layer encoder and decoder structure.
[0098] The self-attention mechanism uses 8 attention heads per layer.
[0099] The input and output embedding dimensions are 512 to maintain a balance between information richness and training speed.
[0100] Use positional encoding to embed sequential information (such as the order of steps) into the model.
[0101] The learning rate is set to 0.0001, and a learning rate warm-up strategy is adopted to gradually increase the learning rate.
[0102] The batch size is set to 64, which is suitable for processing larger amounts of data.
[0103] 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.
[0104] The cross-entropy loss function is used to evaluate the gap between the model-generated script and the actual script.
[0105] The dataset is divided into training set (70%), validation set (20%) and test set (10%).
[0106] The training set is used to train the model, and the validation set is used for hyperparameter tuning.
[0107] Use transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewarding or punishing the performance of the neural network model through the positive and negative feedback mechanism, the neural network model outputs the final automation script, including the following steps:
[0108] 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 the data set of 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.
[0109] The parameters of some layers in the pre-trained neural network model are frozen, retaining only the parts relevant to the new task for training to preserve the model's existing knowledge. Typically, the first few layers (such as feature extraction layers) are retained, while the later layers (such as decision layers) are adjusted and trained. Based on the complexity of the new task and the characteristics of the data, the model's output layer (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.
[0110] The state space represents the performance metrics of the current neural network model. Common performance metrics include accuracy, loss, and the quality of the generated script. The action space represents the adjustable parameters or structures in the neural network model, primarily including the learning rate, number of layers, number of attention heads, and activation function selection. Each action corresponds to a model parameter adjustment, and positive or negative feedback is provided to the model based on its performance in the new task. For example, positive feedback is provided when the model-generated script is close to the target script; negative feedback is provided when it deviates significantly from the target. In this way, the model can gradually learn the optimal strategy.
[0111] After multiple rounds of training and feedback adjustments, the model will output an optimized automation script. At this point, the model can more accurately generate automation scripts that meet the requirements of new tasks.
[0112] Specific examples of the above scheme are as follows:
[0113] Collected existing manual test cases and logs for the software module. These test cases detailed information such as input parameters, expected outputs, test steps, and exception handling;
[0114] 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 the neural network model can understand. Input data includes:
[0115] Input parameters: such as input box values and button click events.
[0116] Expected output: such as test result logs or UI responses.
[0117] Exception handling: record the system's exception returns or logs.
[0118] A test case for 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.
[0119] We used a Transformer model that had been pre-trained on other automated script generation tasks. The first few layers of this model had already learned common script generation patterns and operation steps. The parameters of the first few layers of the model were frozen because their general feature extraction capabilities remained valid for the new task. Only the parameters of the last few layers were retained for training to adapt to the specific requirements of the new task. The first few layers of the pre-trained model had already learned how to extract common features from the input data, such as input parameters and operation steps. We decided to freeze these layers and adjust only the last few layers to generate automated scripts suitable for this software module.
[0120] Since the new task is much more complex than the original task and includes more input parameters and logical judgments, we 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 accommodate 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.
[0121] Using the dataset for the new task, the frozen model is trained for multiple rounds. After each round of training, the model's accuracy and loss are calculated by comparing the automated scripts generated by the model with real manual test cases. The learning rate and model parameters are adjusted based on the model's performance. When the generated automated script successfully executes in actual tests, the model is given positive feedback to increase the probability of the model generating similar scripts. When the script fails, negative feedback is provided to adjust the generation strategy. After multiple rounds of training, the model begins to gradually generate more accurate automated scripts. For example, the model originally only generated basic input and click operations, but now it can generate more complex logical judgments and exception handling steps.
[0122] After multiple rounds of training and feedback optimization, the model outputs a final automated script. This script has been verified to meet the expected testing requirements and is capable of automatically executing functional tests of software modules. The model's performance is evaluated using a test set. The model-generated automated script demonstrates efficiency and accuracy in new tasks, reducing the workload of manual testing.
[0123] The final output automation script includes the following:
[0124] Enter the user ID, enter the amount, and click the Confirm button.
[0125] Check whether the page displays a success message.
[0126] If an error occurs, log it and catch the exception to automatically retry the operation.
[0127] Use a low-code development platform to test and deploy automated scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts. This includes the following steps:
[0128] Script import: Import the generated automation scripts into the low-code development platform, which provides a simplified user interface that allows developers to operate without extensive manual coding. Complex logic can be completed by dragging and dropping components or entering a small amount of code.
[0129] Script visualization: On low-code platforms, scripts can be displayed visually, making it easier for developers to understand and quickly adjust them. For example, a graphical interface can be used to visualize the test process, input parameters, and expected output structure.
[0130] 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.
[0131] Script execution and debugging: Execute automated scripts to verify that they can complete the intended functional testing tasks. Low-code platforms often include debugging features that allow you to insert breakpoints during script execution, view input and output data, and troubleshoot potential issues.
[0132] 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.
[0133] Continuous Integration / Continuous Deployment (CI / CD) Pipeline: Low-code development platforms integrate CI / CD capabilities, integrating automated scripts with the application deployment process. Once a script passes testing, it automatically enters the deployment process, ensuring that the script automatically executes the corresponding testing tasks and supporting continuous iterative software development.
[0134] Deployment environment selection: Select an appropriate deployment environment, such as development, testing, pre-production, production, etc. Ensure that the script deployment environment is compatible with the business application environment and support seamless switching between different environments.
[0135] Automated Deployment: Use the low-code platform to deploy scripts with one click and publish them to the test environment. The platform automatically handles script version management, dependency installation, and related permission configuration.
[0136] Open API connection: Use Codeup-OpenAPI to integrate generated automation scripts with the platform's version management system. Codeup-OpenAPI provides version control, collaborative development interfaces, and supports multi-terminal synchronization.
[0137] Real-time collaboration: Codeup-OpenAPI allows multiple developers to modify the same automation script simultaneously. 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.
[0138] Version Management: Every time you update and submit a script, Codeup's version control feature automatically creates a new version record, enabling version backtracking and comparison. Deep integration between the low-code platform and Codeup enables version history tracking of automated scripts, ensuring every change is traceable.
[0139] Cross-platform deployment: Through low-code platforms, automated scripts can be quickly deployed to multiple end environments, such as web, mobile, and servers. Low-code platforms usually have built-in cross-platform compatibility, ensuring that scripts can run seamlessly on different terminals.
[0140] Real-time Update Synchronization: With Codeup-OpenAPI, every script update is synchronized to multiple endpoints in real time. Whether on the web or mobile side, users can access the latest version of the script in real time, ensuring a consistent testing environment across all platforms.
[0141] Permission Management: Within 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 them. This permission management mechanism seamlessly integrates with Codeup-OpenAPI to ensure code security and operational transparency.
[0142] Auditing and Monitoring: The platform supports auditing of automated script operations, recording each user's operation traces. Combined with Codeup's logging function, this allows for effective monitoring of automated script modifications and execution, and timely identification of potential security risks.
[0143] Specific examples of the above scheme are as follows:
[0144] Imagine you're 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 accelerate the development, testing, and deployment of automated scripts, and integrate Codeup-OpenAPI for multi-terminal collaboration and version management. Below are the specific steps to implement this process.
[0145] Scenario: An automated test script has been generated using AI for the payment process (including payment success, payment failure, refund process, etc.).
[0146] Operation: Import the automation script into the low-code development platform, which will automatically parse and present the script as a visual process. For example, the platform will identify the steps of sending a payment request, verifying the payment status, and handling exceptions.
[0147] Developers can drag and drop components in the graphical interface to adjust the automated testing process and add or delete steps.
[0148] 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 and payment failure).
[0149] Action: On a low-code platform, you can easily insert breakpoints at certain steps in the test process, such as after a payment request is sent or before a payment result is returned. Breakpoints can pause the script execution, allowing you to inspect request parameters, response data, and log information.
[0150] 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).
[0151] 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.
[0152] Scenario: You want to publish debugged automation scripts to a test environment for continuous integration and deployment, ensuring that these tests can be automatically executed every time the code is updated.
[0153] Operations: Low-code platforms integrate CI / CD capabilities, allowing for one-click deployment of automated scripts. Scripts can be published to a test environment, and the platform automatically handles dependency installation and permission configuration.
[0154] 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.
[0155] 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.
[0156] Operation: By integrating Codeup-OpenAPI, you can integrate automation scripts with Codeup's version control system. Multiple developers can use Codeup-OpenAPI to modify scripts simultaneously and view each other's changes in real time.
[0157] 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.
[0158] Scenario: The automated scripts for the payment module need to be deployed simultaneously on the web and mobile terminals to ensure consistent testing on different platforms.
[0159] Operation: Codeup-OpenAPI's collaborative functionality allows script updates to be synchronized across different endpoints in real time. Whether on the web or mobile side, all updates are applied in real time, ensuring that testing is performed simultaneously across all endpoints.
[0160] 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;
[0161] 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;
[0162] Optimization module: performs preliminary settings of the neural network model based on the target task, uses the trained automated script and loss function to optimize the neural network model parameters, and sends the pre-trained neural network model to the output module;
[0163] Output module: Uses transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewards or penalties are given based on the performance of the neural network model through a positive and negative feedback mechanism, the neural network model outputs the final automation script, which is then sent to the management module.
[0164] 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.
[0165] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters in the formulas are set by technicians in this field according to actual conditions.
[0166] Throughout this specification, references to terms such as "one embodiment," "example," or "specific example" indicate that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0167] The preferred embodiments of the present invention disclosed above are intended only to help illustrate the present invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the present invention to specific embodiments. Obviously, many modifications and variations are possible based on the contents of this specification. These embodiments are selected and described in detail in this specification to better explain the principles and practical applications of the present invention, thereby enabling those skilled in the art to better understand and utilize the present invention. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. Selenium automated 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, and uses them as input and output for the neural network model. Perform preliminary settings of the neural network model based on the target task, and use the trained automated script and loss function to optimize the neural network model parameters; The selection index is calculated based on the data volume, task dependency depth, and sequence length. The comparison between the selection index and the index threshold determines whether the number of initial Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions need to be adjusted. The data volume refers to the number of samples used in the test task. The task dependency depth is obtained through the task flowchart or dependency tree analysis. The sequence length refers to the number of all steps from the starting point to the end point. Use transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewarding or punishing the performance of the neural network model through a positive and negative feedback mechanism, the neural network model outputs the final automation script. Use the low-code development platform to test and deploy automated scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts.
2. The method for generating Selenium automated scripts based on an AI algorithm according to claim 1, wherein: Initially set up the neural network model based on the target task, and use the trained automated script and loss function 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 positional encoding to incorporate positional information into the input embeddings. After initializing the learning rate, we gradually increase the learning rate using a learning rate warm-up strategy, select a batch size to balance training speed and memory consumption, and use the AdamW optimizer for parameter optimization. After converting several automated scripts into input feature vectors, they are organized into a dataset, which is then divided into a training set, a validation set, and a 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 backpropagation algorithm to update the neural network model parameters according to the loss value.
3. The method for generating Selenium automated scripts based on an AI algorithm according to claim 2, wherein: 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. This involves the following steps: Obtain the data volume, task dependency depth, and sequence length of the test task, and calculate the selection index based on the data volume, task dependency depth, and sequence length. The expression is: , where is the selection 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 greater than 0; The obtained selection index is compared with the preset index threshold. The index threshold is used to determine whether the initial number of Transformer layers, the number of heads of each attention mechanism, and the input / output embedding dimensions need to be adjusted. 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, 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, and the input / output embedding dimensions need to be adjusted.
4. The method for generating Selenium automated scripts based on an AI algorithm according to claim 3, wherein: When it is determined that the initial number of Transformer layers, the number of attention heads per layer, and the input / output embedding dimensions need to be adjusted, the adjustment steps are: The initial number of Transformer layers and the initial number of attention heads per layer are adjusted by selecting an index. 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. 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 an AI algorithm according to claim 4, wherein: Use transfer learning technology to apply the pre-trained neural network model to the new task. The neural network model outputs the final automation script, which includes the following steps: Collect the dataset for 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 retain the parts related to the new task for training; Adjust the size of the fully connected layers of the neural network model based on 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 an AI algorithm according to claim 5, characterized in that: Use a low-code development platform to test and deploy automated scripts, and integrate the Codeup-OpenAPI open interface to achieve multi-terminal real-time collaboration and version management of automated scripts. This includes 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. When the automation script is executed, 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, deploying automated scripts to the test environment with one click, and automatically handling script version management, dependency installation, and permission configuration; Use Codeup-OpenAPI to integrate the generated automation script with the platform's version management system, allowing multiple developers to modify the same automation script simultaneously 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 an AI algorithm according to claim 6, wherein: The generation system collects and organizes existing automation scripts, cleans and tags the automation scripts, and uses them as the input and output of the neural network model. The following steps are included: Acquire and aggregate automation scripts from existing projects or platforms, categorize and archive the collected scripts, and mark the functional modules and key steps involved in the scripts; Pre-process 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 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 as 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 organizes existing automation scripts, cleans and tags the automation scripts, and uses them as input and output of the neural network model; Optimization module: performs preliminary settings of the neural network model based on the target task, and uses the trained automated script and loss function to optimize the neural network model parameters; Output module: Use transfer learning technology to apply pre-trained neural network models to new tasks. The state space represents the performance indicators of the current neural network model, and the action space represents the adjustable parameters or structure of the neural network model. After rewarding or punishing the performance of the neural network model through a positive and negative feedback mechanism, 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
Coordination scheduling algorithm based on deep neural network
CN118607870A
Model training method based on NLP large model
CN118734924A