Method and device for generating test script
By using artificial intelligence models to determine the user operation sequence of the target application and generate test scripts, the problem of high complexity in writing automated test scripts is solved, and the testing efficiency and comprehensiveness are improved.
Patent Information
- Application Number
- CN202411721284.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-11
AI Technical Summary
During the automated testing process, writing automated test scripts is more complex, resulting in high test complexity and low efficiency.
By obtaining user interface interaction object information of the target application, an artificial intelligence model is used to determine the user operation sequence, and a test script is generated based on these operation data.
Reduces the complexity and time of generating test scripts, improves the comprehensiveness and efficiency of testing, and reduces the need for manual scripting.
Smart Images

Figure CN119597667A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for generating a test script. Background Art
[0002] In order to ensure the quality of the application as much as possible, the application needs to be tested before it goes online. Automated testing is a common testing method.
[0003] However, during the automated testing process, testers are required to write automated testing scripts for the application, and writing automated testing scripts is relatively complex, resulting in high complexity and low efficiency of automated testing. Summary of the invention
[0004] In one aspect, the present application provides a method for generating a test script, comprising:
[0005] Obtaining interactive object information of a user interface in a target application to be tested, wherein the interactive object information is used to characterize at least one interactive object in the user interface;
[0006] Based on the interactive object information, at least one user operation sequence is determined using an artificial intelligence model, wherein the user operation sequence at least includes: at least one user operation data that can be generated by a user interacting with an interactive object in the user interface;
[0007] Based on each user operation data in the user operation sequence, a test script for testing the target application is generated.
[0008] In a possible implementation, the user operation data includes at least: identification information of a target interactive object operated by the user, and an operation type of the user interacting with the target interactive object, the target interactive object belonging to the at least one interactive object;
[0009] The generating a test script for testing the target application based on each user operation data in the user operation sequence includes:
[0010] For each user operation data in the user operation sequence, based on the operation type corresponding to the user operation data and the script code templates corresponding to different operation types, determine a target script code template suitable for the user operation data;
[0011] Based on the target script code template and the identification information of the target interactive object, generating a test code corresponding to the user operation data;
[0012] Based on the test code corresponding to each user operation data in the user operation sequence, a test script for testing the target application is determined.
[0013] In yet another possible implementation, the determining at least one user operation sequence based on the interactive object information by using an artificial intelligence model includes:
[0014] Based on the interactive object information, at least one interactive sequence is predicted using a prediction model, the interactive sequence comprising: at least one set of interactive data generated by the user interacting with the interactive object in the user interface, each set of interactive data comprising user operation data generated by the interactive operation between the user and the interactive object and response data of the target application to the interactive operation;
[0015] Based on the user operation data and the response data in each interaction data in the interaction sequence, using the policy network model of the intelligent agent, screening out at least one target interaction sequence whose response data matches the user operation data from the at least one interaction sequence;
[0016] Each user operation data in the target interaction sequence is determined as a user operation sequence to obtain at least one user operation sequence.
[0017] In another possible implementation, based on the user operation data and the response data in each interaction data in the interaction sequence, using the policy network model of the agent to screen out at least one target interaction sequence whose response data matches the user operation data from the at least one interaction sequence includes:
[0018] For each group of interaction data in each interaction sequence, based on the user operation data in the interaction data, the agent's policy network model is used to decide the predicted response action corresponding to the user operation data;
[0019] If the predicted response actions corresponding to the user operation data in the interaction sequence match the response data, the interaction sequence is determined as a target interaction sequence with correct response data, and at least one screened target interaction sequence is obtained.
[0020] In another possible implementation, the prediction model is obtained by training using sample interaction object information in a user interface sample of at least one application sample as a training sample and taking the minimum difference between a predicted interaction sequence and an actual interaction sequence corresponding to the application sample as a training target, wherein the sample interaction object information corresponding to the application sample is used to characterize at least one sample interaction object in the user interface sample of the application sample;
[0021] The strategy network model of the intelligent agent is obtained by combining the predicted interaction sequence of the application sample predicted by the prediction model with reinforcement learning training.
[0022] In another possible implementation, the prediction model is a trained long short-term memory network model;
[0023] The prediction model is trained in the following way:
[0024] Obtaining sample interaction object information of at least one application sample and an actual interaction sequence of the application sample;
[0025] For each application sample, based on the sample interaction object information of the application sample, predicting at least one predicted interaction sequence using the long short-term memory network model to be trained;
[0026] If it is determined based on the predicted interaction sequences and actual interaction sequences of each application sample that the training conditions have not been met, adjust the model parameters of the long short-term memory network model, and return to execute the operation of predicting at least one predicted interaction sequence using the long short-term memory network model to be trained until the training conditions are met to obtain a trained decision network model.
[0027] In another possible implementation, the policy network model of the agent is trained in the following manner:
[0028] Obtain at least one predicted interaction sequence of at least one application sample predicted by the trained prediction model, wherein the predicted interaction sequence includes at least one predicted interaction data, and the predicted interaction data includes: predicted user operation data and predicted response data corresponding to the application sample;
[0029] For each predicted interaction sequence of each application sample, the agent-based decision network model predicts the response probability of the application sample executing different response actions under the premise that the application sample has the predicted user operation data in the predicted interaction sequence;
[0030] Based on the predicted response data corresponding to the predicted user operation data and the response probability of the application sample performing different response actions, the value network model of the intelligent agent is used to determine the reward and punishment index value;
[0031] Based on the reward and punishment index value, the decision network model and the value network model of the agent are optimized, and the operation of predicting the response probability of the application sample performing different response actions based on the decision network model of the agent is returned until the training end condition is reached.
[0032] In yet another possible implementation, the method further includes:
[0033] Detecting that the degree of change of the interactive object information of the target application exceeds a set threshold, re-determining the training samples for training the prediction model based on the latest interactive object information currently updated by the target application, and using the re-determined training samples to train the prediction model and the decision network model of the intelligent agent;
[0034] Based on the latest updated interactive object information of the target application and the retrained prediction model and agent decision network model, return to execute the operation of using the prediction model to predict at least one interaction sequence so as to redefine the test script of the target application.
[0035] In yet another possible implementation, the detecting that a change degree of the interactive object information of the target application exceeds a set threshold includes:
[0036] Obtain a first user interface screenshot of a historical version of a target application and a second user interface screenshot of a current target application;
[0037] Extracting a first interface feature of the first user interface screenshot and a second interface feature of the second user interface screenshot;
[0038] If the feature matching degree between the first interface feature and the second interface feature is less than a set threshold, it is determined that the degree of change of the interactive object information of the target application exceeds the set threshold.
[0039] On the other hand, the present application provides a device for generating a test script, comprising:
[0040] An information obtaining unit, used to obtain interactive object information of a user interface in a target application to be tested, wherein the interactive object information is used to characterize at least one interactive object in the user interface;
[0041] A sequence determination unit, configured to determine at least one user operation sequence using an artificial intelligence model based on the interactive object information, wherein the user operation sequence at least includes: at least one user operation data that can be generated by a user interacting with an interactive object in the user interface;
[0042] The script generating unit is used to generate a test script for testing the target application based on each user operation data in the user operation sequence. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0044] Figure 1 A flowchart of a method for generating a test script provided by the present application;
[0045] Figure 2 A schematic diagram of another flow chart of the method for generating a test script provided by the present application;
[0046] Figure 3 A schematic diagram of another flow chart of the method for generating a test script provided by the present application;
[0047] Figure 4 A schematic diagram of an implementation process of training the LSTM network model in this application;
[0048] Figure 5 A schematic diagram of the composition structure of the LSTM network model;
[0049] Figure 6 A schematic diagram of an implementation process of training a decision network model in this application;
[0050] Figure 7 An example diagram of a framework for implementing the present application solution;
[0051] Figure 8 A schematic diagram of the structure of a device for generating a test script provided by the present application;
[0052] Fig. 9 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0053] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation mode of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0054] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0055] like Figure 1, showing a schematic diagram of an implementation flow of a method for generating a test script provided in an embodiment of the present application. The method of this embodiment can be applied to electronic devices, which may be laptop computers, desktop computers, and other personal computer devices, or servers, etc., without limitation.
[0056] The method of this embodiment may include:
[0057] S101, obtaining interactive object information of a user interface in a target application to be tested.
[0058] The interactive object information is used to characterize at least one interactive object in the user interface. The interactive objects in the user interface may be various controls or other objects that can interact with the user. For example, various buttons, menus, slidable progress bars, and information input boxes that can be used to input information in the user interface, which are objects that can enable the user to interact with the application, are all interactive objects.
[0059] For example, the interactive object information may at least include identification information of each interactive object in the user interface of the target application. The identification information of the interactive object may be the name of the interactive object, the interface address or other identification information, which is not limited.
[0060] The interactive object information may also include attribute information of each interactive object. For example, the attribute information of the interactive object may include but is not limited to the function of the interactive object, at least one intention of operating the interactive object, the position in the user interface, and the operability of the interactive object, etc., without limitation.
[0061] S102: Determine at least one user operation sequence using an artificial intelligence model based on the interactive object information.
[0062] The user operation sequence includes at least one user operation data generated by the user interacting with the interactive object in the user interface. The user operation data is used to characterize the interactive behavior of the user with the interactive object. Based on this, the user operation data can reflect information such as the interactive object operated by the user and the specific interactive behavior with the interactive object.
[0063] For example, the user operation data includes at least: identification information of the target interactive object operated by the user, the operation type of the user's interaction with the target interactive object, and the behavior data of the user's interaction with the target interactive object. For the sake of distinction, the interactive object operated by the user indicated in the user operation data is called the target interactive object. Therefore, the target interactive object belongs to at least one interactive object in the application interface of the target application.
[0064] The operation type of the user's interaction with the target interactive object is the interaction mode of the user's interaction with the target interactive object, or the operation mode of the user's operation on the target interactive object. For example, the operation type on the target interactive object may include but is not limited to: click, slide, touch, and drag, etc. Of course, depending on the target interactive object, the operation type supported by the target interactive object will also be different, and accordingly, the possible operation type of the user's operation on the target object will also be different.
[0065] Among them, the behavioral data of the user's interaction with the target interactive object may include: the moment and duration of the interaction with the target interactive object, and the adjustment amount (volume or progress, etc.) or input data triggered by the target interactive object, etc., without any restriction.
[0066] Among them, the artificial intelligence model can be pre-trained. By pre-training the artificial intelligence model, the artificial intelligence model can combine the relevant information of each interactive object in the user interface of the target application, predict the user operations that the user can perform in the user interface and the user operation data that can be generated by the user operations, and obtain a predicted user operation sequence.
[0067] In the present application, there may be many possibilities for artificial intelligence models, and the artificial intelligence model may include one or more models without limitation.
[0068] S103: Generate a test script for testing the target application based on each user operation data in the user operation sequence.
[0069] It is understandable that, when the target application has a user interface, it is necessary to test the response of the target application to various operation behaviors in the user interface, etc. In the present application, the electronic device can remember the various user operation data that the artificial intelligence model predicts that the user may generate when interacting with the interactive object in the user interface, thereby providing a reliable data basis for generating a test script.
[0070] There are many possibilities for the specific implementation of generating the test script based on the user operation data in the user operation sequence, and there is no limitation to this.
[0071] For example, in a possible implementation, a script generation program for generating a test script may be pre-configured in the electronic device. On this basis, based on the user operation data in the user operation sequence, the script generation program is called, and a test script may be generated by the script generation program. The script generation program may be developed according to actual needs; or an open source script generation tool may be selected, for example, the open source automated testing tool Appium may be used to generate a test script, etc., without limitation.
[0072] It is understandable that, for each user operation sequence, the present application can generate a test script. Of course, it is also possible to use the test scripts generated for each user operation sequence as a whole as the final generated test script.
[0073] From the above content, it can be seen that after obtaining the interactive object information of each interactive object in the user interface of the target application to be tested, the present application can determine the user operation sequence that can be generated by the user interacting with the interactive objects in the user interface based on the interactive object information and using the artificial intelligence model. On this basis, based on the user operation data in the user operation sequence that can be generated in the user interface, a test script for testing the target application can be generated, so that the tester does not need to manually write the test script in combination with the characteristics of the user interface of the target application, which reduces the complexity of generating the test script and improves the efficiency of generating the test script.
[0074] Moreover, when testers manually write test scripts, it is difficult to make the written test scripts comprehensively cover all possible user operation scenarios in the user interface of the target application. In this application, based on the interactive object information in the user interface of the target application, with the help of an artificial intelligence model, all possible user operation sequences can be predicted more comprehensively, which is conducive to generating corresponding test scripts for different operation scenarios, improving the comprehensiveness of the target application test, and naturally improving the test effect.
[0075] The following describes an implementation method for generating a test script based on each user operation data in a user operation sequence. Figure 2 , shows another flow chart of the method for generating a test script provided in an embodiment of the present application. The method of this embodiment may include:
[0076] S201, obtaining interactive object information of a user interface in a target application to be tested.
[0077] The interactive object information is used to characterize at least one interactive object in the user interface. For example, the interactive object information may include identification information of each interactive object in the user interface, and may also include attribute information of each interactive object, etc., as described above, and will not be repeated here.
[0078] S202: Determine at least one user operation sequence using an artificial intelligence model based on the interactive object information.
[0079] The user operation sequence includes at least: at least one user operation data generated by the user interacting with the interactive object in the user interface;
[0080] In this embodiment, the user operation data at least includes: identification information of the target interactive object operated by the user, and the operation type of the user's interaction with the target interactive object. The target interactive object belongs to at least one interactive object. Of course, the user operation data may also include the aforementioned behavior data of the user's interaction with the target interactive object, etc., which is not limited thereto.
[0081] S203: For each user operation data in the user operation sequence, based on the operation type corresponding to the user operation data and the script code templates corresponding to different operation types, determine a target script code template suitable for the user operation data.
[0082] In the present application, corresponding script code templates are pre-configured for different types of operations on interactive objects. For example, a click operation on an interactive object may be configured with a script code template applicable to the click operation, and an input operation for inputting information to an interactive object may be configured with a script code template applicable to the input operation.
[0083] Among them, the script code template corresponding to each operation type defines the basic structure and style of the test script under this operation type. Of course, it can also include the basic code of some test items involved in the test script applicable to this operation type, etc. It can be set according to actual needs and there is no restriction on this.
[0084] In addition, since the interactive objects targeted by the same operation type and the behavior data of the specific operation interactive objects may also be different, the script code template may also include: at least one object information filling area for attribute information such as identification information of the interactive object to be filled in, and at least one behavior information filling area for the operation behavior to be filled in. Accordingly, when generating the test code later, the corresponding position of the script code template may be filled in according to the information of the interactive object of the actual interaction and the specific behavior data in the user operation data.
[0085] S204, generating a test code corresponding to the user operation data based on the target script code template and the identification information of the target interactive object.
[0086] The identification information of the target interactive object may provide a basis for generating a call statement for calling the target interactive object in the test code.
[0087] For example, the script generation program is called to fill in the target script code template based on the identification information of the target interactive object and other information in the user operation data according to the set template syntax or filling rules, so as to obtain a generated test script. Of course, in actual applications, the script generation program may also need to parse and convert the user operation data before generating the test script, which will not be described in detail.
[0088] This application does not impose any restrictions on the specific implementation process of generating test code based on the target script code template.
[0089] S205: Determine a test script for testing the target application based on the test code corresponding to each user operation data in the user operation sequence.
[0090] For example, the test codes corresponding to each operation data sequence are grouped into a test script to obtain a test script generated based on the user operation sequence.
[0091] In the present application, the user's operation behavior in the user interface can be simulated through the test script, so that the target application can be tested by running the test script.
[0092] It is understandable that after generating the test script, the present application may also store the test script in a script storage location specified by the user.
[0093] It is understandable that in any of the above embodiments of the present application, after generating the test script, the present application can also execute the test script. During the test script execution process, the response data of the target application and the log information corresponding to the target application can also be obtained and recorded.
[0094] Accordingly, after completing the test of the target application based on the test script, the present application can analyze the response of the target application to user operations and whether the target application has any anomalies, etc., in combination with the application's response data and log information. For example, whether the response of the target application meets expectations and whether there are response errors. Based on the test results of the target application and the user's feedback on the test situation, the artificial intelligence model and script generation program can also be adjusted to improve the test coverage and accuracy.
[0095] As can be seen from the foregoing introduction, the artificial intelligence model of the present application may have many possible situations. For example, the artificial intelligence model may be a large language model, or a combination of multiple intelligent models, etc.
[0096] In a possible implementation, in order to more accurately determine the user operations that the user can perform in the user interface of the target application, the artificial intelligence model in this application may include a prediction model and an agent strategy decision model. Figure 3 For explanation. Figure 3 , shows a schematic diagram of an implementation flow of a method for generating a test script provided in an embodiment of the present application, and this embodiment may include:
[0097] S301, obtaining interactive object information of a user interface in a target application to be tested.
[0098] The interactive object information is used to represent at least one interactive object in the user interface.
[0099] S302: predict at least one interaction sequence using a prediction model based on the interaction object information.
[0100] The interaction sequence includes: at least one set of interaction data generated by the user interacting with the interaction object in the user interface. Each set of interaction data includes user operation data generated by the interaction operation between the user and the interaction object, and the target application's response data to the interaction operation. It can be seen that each set of interaction data includes a set of user operation data and response data that correspond to each other.
[0101] The user operation data is the operation data generated by the user operating the interactive object in the user interface, and the response data corresponding to the user operation data is used to represent the response result generated by the target application in response to the user operation data.
[0102] For example, assuming that the user operation data includes: a user's click operation on a video play button, the response data may include data related to the video play executed by the target application in response to the click operation on the video play button.
[0103] It should be noted that the interaction sequence predicted by the prediction model is not an interaction sequence generated by real users' operations on interactive objects in the user interface of the target application, but an interaction sequence obtained by analyzing the user operation data corresponding to the user operations that can be performed in the user interface and the response data that the target application should generate in response to the user operation data based on the interaction object information of the interactive objects in the user interface.
[0104] The prediction model may be any neural network model or other machine learning model. For example, the prediction model may be a long short-term memory (LSTM) network model.
[0105] In the present application, the prediction model can be obtained by pre-training. For example, the prediction model can be obtained by training using sample interaction object information in a user interface sample of at least one application sample as a training sample and taking the minimum difference between the predicted interaction sequence and the actual interaction sequence corresponding to the application sample as a training target.
[0106] The sample interaction object information corresponding to the application sample is used to characterize at least one sample interaction object in the user interface sample of the application sample.
[0107] In this application, for the sake of distinction, the interactive object information used as a training sample is referred to as sample interactive object information, and the application to which the sample interactive object information belongs is referred to as an application sample. Based on this, it can be seen that the sample interactive object information of the application sample may include the identification information and attribute information of each sample interactive object in the user interface sample of the application sample, and the attribute information of the sample interactive object includes the purpose of the sample interactive object and the supported operation mode and other information. For details, please refer to the relevant introduction of the attribute information of the interactive object above, which will not be repeated here.
[0108] In the process of training the prediction model, the interaction sequence predicted by the prediction model based on the sample interaction object is called the predicted interaction sequence. Similar to the interaction sequence, the predicted interaction sequence may include: the predicted user operation data that the prediction model predicts the user may perform in the user interface sample, and the predicted response data generated by the application sample for the predicted user data.
[0109] The actual interaction sequence corresponding to the application sample is an interaction sequence that can actually be generated in the user interface sample corresponding to the application sample and is pre-marked for the application sample. The actual interaction sequence corresponding to the application sample can be constructed by the user, or based on the user's actual operation in the user interface sample of the application sample, the user operation data and the actual response data generated by the application sample are obtained, and each pair of user operation data and response data constitutes an actual interaction sequence. Of course, there are other ways to obtain the actual interaction sequence of the application sample, and this application does not limit this.
[0110] In the present application, there are many possibilities for the specific implementation of training the prediction model based on the sample interaction object information corresponding to each application sample, such as using any supervised training method for training, and the specific training process is not limited.
[0111] S303, based on the user operation data and response data in each interaction data in the interaction sequence, using the agent's policy network model, screen out at least one target interaction sequence whose response data matches the user operation data from at least one interaction sequence.
[0112] Among them, the intelligent agent includes a strategy network model (also referred to as the strategy model). The strategy network model of the intelligent agent can be obtained through reinforcement learning, and the specific training process is not restricted.
[0113] In a possible implementation, in the present application, the strategy network model of the agent can be obtained by training based on the predicted interaction sequence of the application sample predicted by the prediction model in combination with reinforcement learning. The specific implementation of training the strategy network model of the agent based on each predicted interaction sequence in combination with the reinforcement learning method can adopt any agent training method, without limitation.
[0114] It can be understood that the strategy network model of the intelligent agent combined with the user operation data in the interaction data can decide the response action of the target application. Based on the decided response action and the response data corresponding to the user operation data, the optimal user operation data can be determined, and the interaction sequence corresponding to the optimal user operation data can be determined as the target interaction sequence.
[0115] For example, in a possible implementation, for each group of interaction data in each interaction sequence, based on the user operation data in the interaction data, the policy network model of the intelligent agent is used to determine the predicted response action corresponding to the user operation data. If the predicted response action corresponding to each user operation data in the interaction sequence matches the response data, the interaction sequence is determined as the target interaction sequence with the correct response data, and at least one target interaction sequence is screened out.
[0116] It can be understood that the response data corresponding to the user operation data is the data corresponding to the response action made by the target application under the user operation data predicted by the prediction model. Based on this, for any user operation data, if the predicted response action predicted by the decision network model based on the user operation data is consistent with the response data corresponding to the user operation data, it means that the group of interaction data predicted by the prediction model is the interaction data that can be generated in the target application.
[0117] In the present application, after the prediction model predicts the interaction sequence, the decision network model of the intelligent agent is used to screen the interaction sequence, which can make the accuracy of each interaction data in the screened interaction sequence higher, and can more realistically reflect the user operation behavior that can be received in the target application and the response actions that can be made by the target application, thereby facilitating the subsequent more accurate generation of test scripts suitable for the target application.
[0118] S304: For each target interaction sequence, determine each user operation data in the target interaction sequence as a user operation sequence to obtain at least one user operation sequence.
[0119] The user operation data in each target interaction sequence constitute a user operation sequence. Accordingly, at least one user operation sequence can be determined based on at least one target interaction sequence.
[0120] S305 , for each user operation sequence, generating a test script for testing the target application based on each user operation data in the user operation sequence.
[0121] The specific implementation of generating a test script for each user operation sequence can be found in the related introduction of the previous embodiment, which will not be repeated here.
[0122] In order to facilitate the understanding of the specific implementation of the training prediction model and the decision network model of the intelligent agent, the training process of these two models is introduced below using a possible implementation method as an example.
[0123] like Figure 4 , shows a schematic diagram of a training process for training a prediction model in an embodiment of the present application. In this embodiment, the prediction model is obtained by training an LSTM network model as an example. The training process may include:
[0124] S401: Obtain sample interaction object information of at least one application sample and an actual interaction sequence of each application sample.
[0125] The sample interaction object information of the application sample is used to characterize at least one sample interaction object in the user interface sample of the application sample. The meaning of the sample interaction object is the same as that of the previous interaction object, but for the sake of distinction, the interaction object of the application sample is called the sample interaction object.
[0126] For example, the sample interaction object information may include identification information of each sample interaction object in the application sample, the role or function of each sample interaction object, the operation mode supported by each sample interaction object, and the interface attributes of each sample interaction object, etc., without limitation.
[0127] The actual interaction sequence may include at least one set of actual interaction data. The actual interaction data is interaction data obtained based on real user operation behaviors on the user interface sample of the application sample. The actual interaction data includes: the actual user operation data of the user and the actual response data obtained by the application sample responding to the actual operation data.
[0128] Each set of actual interaction data in the actual interaction sequence may be collected by means of an automated testing tool or by other means, without limitation.
[0129] The actual user operation data in the actual interaction data may include: sample interaction objects of user interaction, operation types of the user and the sample interaction objects (such as click, slide, pause or drag, etc.) and specific operation behavior information.
[0130] In order to distinguish different users and the interactions between users and sample interaction objects during each use of the application sample, the actual user operation data also includes the user's unique identifier and session identifier. The session identifier is used to identify a session in which the user uses the application sample. A session refers to a continuous operation of the user in the application sample, which starts when the user opens the application sample and ends when the user closes the application sample.
[0131] Of course, the actual user operation data may also include the marked operation intention, dialogue state, and adjustment amount involved in the operation intention, etc., without limitation. The operation intention may be the user's intention to interact with the sample interaction object, such as the operation intention may be to play a video, fast forward to a specific time point, pause a video, or adjust the volume, etc. The dialogue state may record the realization of the purpose that the user needs to achieve during a conversation, etc. The adjustment amount involved in the operation intention may be the specific value of the volume or progress involved in the operation intention.
[0132] The actual response data is response-related data generated based on the actual user operation data, for example, it may include whether to respond to the actual operation data and the response result.
[0133] It is understandable that after obtaining the actual interaction data, the present application may also perform data preprocessing such as noise removal and outlier removal on the actual interaction data, and use the preprocessed actual interaction data as actual interaction data for training. There is no restriction on the specific implementation process of data preprocessing.
[0134] In order to facilitate the computer program to process the actual user interaction sequence, each actual interaction data in the actual interaction sequence can also be converted into corresponding features through vector mapping.
[0135] For example, assume that the correspondence between different data and coding values is preset as follows:
[0136] Click: 0;
[0137] play_button:1;
[0138] drag: 2;
[0139] progress_bar:3;
[0140] searching: 4;
[0141] seeking: 5;
[0142] video_id: 6;
[0143] time: 7; 123:8; 5:30:9;
[0146] Among them, "123" indicates that the video ID is "123". Assume that "5:30" indicates time, and the video ID is represented by time.
[0147] Based on this, assuming that the actual interaction data shows that the user performed a click operation (click), the target was the play button (play_button), the timestamp was 10 (this timestamp corresponds to the video ID "123"), the response of the triggered application was searching, and there was no adjustment amount, then the feature value converted from the actual interaction data can be represented as [0, 1, 8, 4,0].
[0148] Of course, the above is a simple description of feature conversion of actual interaction data, and the conversion can be performed according to actual needs without limitation.
[0149] S402: For each application sample, based on the sample interaction object information of the application sample, predict at least one predicted interaction sequence using the long short-term memory network model to be trained.
[0150] After the sample interaction object information of the application sample is input into the LSTM network model, the LSTM network model can predict at least one interaction sequence that the application sample can generate. For the sake of distinction, the interaction prediction predicted by LSTM is called a predicted interaction sequence.
[0151] The predicted interaction sequence may include at least one predicted interaction data, and the predicted interaction data includes: predicted user operation data and predicted response data corresponding to the application sample. The predicted response data is predicted by the LSTM network model, and is the response data generated by the application sample when the application sample has the predicted user operation data.
[0152] Among them, the basic structure of the LSTM network model can be as follows Figure 5 shown.
[0153] Depend on Figure 5 It can be seen that the LSTM network model can receive input data at each time step and the hidden state at the previous time step , and also get the cell state of the previous time step .
[0154] The core of the LSTM network model lies in the gating mechanism, such as Figure 5 As shown in the three dotted boxes in the figure, the three dotted boxes from left to right represent the forget gates. , Input Gate and output gate .
[0155] These forgotten gates , Input Gate and output gate The gating signal is based on the weight matrix and bias, combined with the input and hidden state, calculated by the activation function. Figure 5 middle Represents a logical function. is the hyperbolic tangent function.
[0156] Among them, the cell state It is the core of the LSTM network model, which is responsible for storing and transmitting long-term information. At each time step, the cell state will be based on the forget gate. Decide what information to keep based on the input gate and the current input data Update its information.
[0157] Finally, the LSTM network model is based on the output gate and the updated cell state , calculate the hidden state of the current time step , this hidden state It can be passed to the next layer of the LSTM network model or as the final output.
[0158] It can be understood that the above is only a brief introduction to the LSTM network model, and there is no restriction on the specific implementation process of data prediction by the LSTM network.
[0159] S403: If it is determined based on the predicted interaction sequences and actual interaction sequences of each application sample that the training conditions have not been met, adjust the model parameters of the long short-term memory network model, and return to execute the operation of predicting at least one predicted interaction sequence using the long short-term memory network model to be trained until the training conditions are met.
[0160] It can be understood that when the training conditions are met, the currently trained LSTM model can be determined as the trained prediction model.
[0161] The training conditions can be set according to actual needs based on the training goal that the predicted interaction sequence of each application sample is as similar as possible to the actual interaction sequence, and there is no restriction on this. For example, the training condition can be that the loss function value determined based on the predicted interaction sequence and the actual interaction sequence of each application sample has converged, or the number of training iterations has reached a set number, and there is no restriction on this.
[0162] It is understandable that the above is explained by taking the prediction model trained by the LSTM network model as an example, but if the LSTM network model is replaced with other network models, the above training process is also applicable without specific limitation.
[0163] The following is an introduction to the process of training the decision network model of the intelligent agent. Figure 6, shows a schematic diagram of an implementation process of a decision network model for training an intelligent agent provided in an embodiment of the present application. The method of this embodiment may include:
[0164] S601, obtaining at least one predicted interaction sequence of at least one application sample predicted by a trained prediction model.
[0165] Each predicted interaction sequence includes at least one predicted interaction data, and the predicted interaction data includes: predicted user operation data and predicted response data corresponding to the application sample. For the predicted user operation data and predicted response data, please refer to the previous related introduction, which will not be repeated here.
[0166] S602, for each predicted interaction sequence of each application sample, the agent-based decision network model predicts the response probability of the application sample executing different response actions, provided that the application sample has predicted user operation data in the predicted interaction sequence.
[0167] In this application, the intelligent agent can be considered to be composed of a decision network model and a value network model, wherein the decision network model is used to output decisions, that is, to determine the response action, and the value network model is used to determine the reward score, that is, the reward and punishment index value mentioned later.
[0168] Among them, the specific implementation of the decision network model of the intelligent agent predicting the response probability that the application sample may perform multiple different response actions can be unrestricted.
[0169] S603, based on the predicted response data corresponding to the predicted user operation data and the response probability of the application sample executing different response actions, using the value network model of the intelligent agent, determine the reward and punishment index value.
[0170] Among them, the value network model can calculate the reward and punishment index value, among which, if the response action output by the decision network model is a correct response, the reward and punishment index value is positive; if the response action output by the decision network model is an error, the reward and punishment index value is negative.
[0171] For example, the intelligent body will set the initial state, in which the policy parameters initialized in the decision network model, the initial value function of the value network model, the initial environment and some training parameters (such as the learning rate and reward discount factor of the value network model and decision network model) will be set.
[0172] The policy network model of the agent will take the predicted user operation data output by the LSTM network model as input, and based on the set action selection rules, predict the response action through key steps such as data sampling, gradient calculation, policy update, importance sampling ratio calculation and policy gradient clipping. On this basis, by limiting the amplitude of policy updates, the training process can be ensured to converge stably.
[0173] Among them, the policy network model can have many possibilities. For example, the policy network model can choose the Proximal Policy Optimization (PPO) algorithm in deep learning, and use the Clipped Surrogate Objective as the objective function as the rule for the policy network model to select actions.
[0174] When an agent performs actions in the environment, it needs to find a balance between trying new actions to discover possible high rewards and choosing the best action based on known information. The agent selects an action based on the current strategy, and after executing the action, the environment returns a new state and reward. Among them, in the environment, the sample interaction object information and predicted operation data currently in the application sample are the current state, and the actions that the agent may perform are the response actions that the application sample may perform, such as playing a video, fast forwarding to a specific position, and adjusting the volume. If the application sample responds correctly, a positive reward is given, that is, the reward and punishment index value is a positive number; if the application sample cannot respond or responds incorrectly, a negative reward is given, that is, the reward and punishment index value is a negative number.
[0175] It is understandable that algorithms such as Q-learning can be used in the process of training the intelligent agent without any specific restrictions.
[0176] S604, based on the reward and punishment index values, optimize the decision network model and value network model of the agent, and return to execute the operation of step S602 until the training end condition is met.
[0177] Among them, optimizing the decision network model and the value network model can be to adjust the parameters of the policy function in the decision network model and the parameters of the value function in the value network model.
[0178] The training end condition can be set as needed. For example, the number of training iterations can be increased by one each time step S603 is executed. If the current number of training iterations reaches the set number of training iterations, it is determined that the training condition is met. For another example, based on the predicted response data corresponding to the predicted user operation data and the response probability of the application sample performing different response actions, it is determined that the prediction accuracy exceeds the set threshold, or the loss function value converges, etc., and the training condition is determined to be met, without specific restrictions.
[0179] When the training end conditions are met, the current decision network model is the final trained decision network model.
[0180] certainly, Figure 6 This is only one implementation method of training the decision network model of an intelligent agent, and other implementation methods are also applicable to this application.
[0181] It is understandable that the layout of the user interface of the target application may change. In order to generate test scripts more efficiently and accurately when the user interface changes, in this application, if the change degree of the interactive object information of the target application is detected to exceed the set threshold, this application will re-determine the training samples used to train the prediction model based on the latest interactive object information currently updated by the target application, and use the re-determined training samples to train the prediction model and the decision network model of the intelligent agent.
[0182] The training samples reused for training the prediction model may be sample interaction object information and sample interaction sequences on other application samples with similar user interfaces updated by the target application, without specific limitation.
[0183] Accordingly, based on the latest interactive object information currently updated by the target application and the retrained prediction model and the decision network model of the intelligent agent, it is possible to return to execute operations such as using the prediction model to predict at least one interaction sequence, so as to redetermine the test script of the target application after the user interface is updated.
[0184] Among them, determining whether the degree of change of the interactive object information of the target application exceeds a set threshold can be implemented in a variety of ways. For example, in one possible implementation, a first user interface screenshot of a historical version of the target application and a second user interface screenshot of the current target application can be obtained. On this basis, the first interface feature of the first user interface screenshot and the second interface feature of the second user interface screenshot can be extracted. Accordingly, if the feature matching degree between the first interface feature and the second interface feature is less than the set threshold, it is determined that the degree of change of the interactive object information of the target application exceeds the set threshold.
[0185] The historical version of the target application is the target application that is most recently updated at the current moment.
[0186] Among them, the user interface screenshot of the target application refers to the screenshot of the user interface of the target application. For the sake of easy distinction, the screenshot of the user interface corresponding to the historical version of the target application is called the first user interface screenshot, and the screenshot of the user interface of the target application at the current moment is called the second user interface screenshot.
[0187] The interface features of the user interface screenshot may be obtained by extracting image features, without any specific limitation.
[0188] For ease of understanding, the implementation process of this case can be found in Figure 7 ,like Figure 7 A schematic diagram showing an example framework for implementing the solution of the present application is shown.
[0189] Depend on Figure 7 It can be seen that the present application can obtain the interaction data of application samples (such as operation data of clicks, slides, etc. and corresponding response data) as training sample data through data collection.
[0190] After preprocessing the training sample data such as removing noise and outliers and labeling data, the LSTM network model can be trained based on the training sample data, and further reinforcement learning training can be performed to train the decision network model of the intelligent agent. Figure 7 , training the LSTM model involves vector conversion and Z standard score processing, and training the agent's decision network model involves Q-Learing algorithm and the interaction between the agent and the environment. For the training of the LSTM network model and the agent's decision network model, please refer to the previous introduction and will not be repeated here.
[0191] After the LSTM network model and the decision network model are trained, a test script can be generated for the target application according to the relevant description of the previous embodiment. Based on the test situation of the test script, the test script can also be evaluated for quality, etc., without specific restrictions.
[0192] On this basis, the present application can also periodically or irregularly trigger the detection of whether there is an increase in the user interface of the target application, such as: Figure 7 By extracting and matching features from screenshots of the user interface, it is possible to determine whether the degree of change in the user interface of the target application exceeds a set threshold. If so, data collection and model training operations will be performed again, and the test script will be regenerated.
[0193] Corresponding to a method for generating a test script of the present application, the present application also provides a device for generating a test script.
[0194] like Figure 8 , showing a schematic diagram of a composition structure of a device for generating a test script in the present application, the device of this embodiment may include:
[0195] An information obtaining unit 801 is used to obtain interactive object information of a user interface in a target application to be tested, wherein the interactive object information is used to characterize at least one interactive object in the user interface;
[0196] A sequence determination unit 802 is used to determine at least one user operation sequence based on the interactive object information by using an artificial intelligence model, wherein the user operation sequence at least includes: at least one user operation data that can be generated by the user interacting with the interactive object in the user interface;
[0197] The script generating unit 803 is used to generate a test script for testing the target application based on each user operation data in the user operation sequence.
[0198] In a possible implementation, the user operation data determined by the sequence determination unit includes at least: identification information of a target interactive object operated by the user, and an operation type of the user interacting with the target interactive object, the target interactive object belonging to the at least one interactive object;
[0199] This script generates units including:
[0200] A template determination subunit, configured to determine, for each user operation data in the user operation sequence, a target script code template suitable for the user operation data based on the operation type corresponding to the user operation data and the script code templates corresponding to different operation types;
[0201] A code generation subunit, configured to generate a test code corresponding to the user operation data based on the target script code template and the identification information of the target interactive object;
[0202] The script generation subunit is used to determine a test script for testing the target application based on the test code corresponding to each user operation data in the user operation sequence.
[0203] In yet another possible implementation, the sequence determination unit includes:
[0204] a sequence prediction subunit, configured to predict at least one interaction sequence using a prediction model based on the interaction object information, wherein the interaction sequence includes: at least one set of interaction data generated by the user interacting with the interaction object in the user interface, each set of interaction data including user operation data generated by the interaction operation between the user and the interaction object and response data of the target application to the interaction operation;
[0205] A sequence screening subunit, configured to screen out at least one target interaction sequence whose response data matches the user operation data from the at least one interaction sequence using a policy network model of an intelligent agent based on the user operation data and the response data in each interaction data in the interaction sequence;
[0206] The sequence determination subunit is used to determine each user operation data in the target interaction sequence as a user operation sequence to obtain at least one user operation sequence.
[0207] In yet another possible implementation, the sequence screening subunit includes:
[0208] An action decision subunit, for, for each group of interaction data in each interaction sequence, based on the user operation data in the interaction data, using the agent's strategy network model to decide a predicted response action corresponding to the user operation data;
[0209] The sequence matching subunit is used to determine the interaction sequence as a target interaction sequence with correct response data if the predicted response action corresponding to each user operation data in the interaction sequence matches the response data, thereby obtaining at least one screened target interaction sequence.
[0210] In another possible implementation, the prediction model is obtained by training using sample interaction object information in a user interface sample of at least one application sample as a training sample and taking the minimum difference between a predicted interaction sequence and an actual interaction sequence corresponding to the application sample as a training target, wherein the sample interaction object information corresponding to the application sample is used to characterize at least one sample interaction object in the user interface sample of the application sample;
[0211] The strategy network model of the intelligent agent is obtained by combining the predicted interaction sequence of the application sample predicted by the prediction model with reinforcement learning training.
[0212] In another possible implementation, the prediction model is a trained long short-term memory network model;
[0213] The device also includes a first training unit, which is used to train the prediction model in the following manner:
[0214] Obtaining sample interaction object information of at least one application sample and an actual interaction sequence of the application sample;
[0215] For each application sample, based on the sample interaction object information of the application sample, predicting at least one predicted interaction sequence using the long short-term memory network model to be trained;
[0216] If it is determined based on the predicted interaction sequences and actual interaction sequences of each application sample that the training conditions have not been met, adjust the model parameters of the long short-term memory network model, and return to executing the operation of predicting at least one predicted interaction sequence using the long short-term memory network model to be trained until the training conditions are met.
[0217] In another possible implementation, the device further includes a second training unit, configured to obtain the policy network model of the agent through training in the following manner:
[0218] Obtain at least one predicted interaction sequence of at least one application sample predicted by the trained prediction model, wherein the predicted interaction sequence includes at least one predicted interaction data, and the predicted interaction data includes: predicted user operation data and predicted response data corresponding to the application sample;
[0219] For each predicted interaction sequence of each application sample, the agent-based decision network model predicts the response probability of the application sample executing different response actions under the premise that the application sample has the predicted user operation data in the predicted interaction sequence;
[0220] Based on the predicted response data corresponding to the predicted user operation data and the response probability of the application sample performing different response actions, the value network model of the intelligent agent is used to determine the reward and punishment index value;
[0221] Based on the reward and punishment index value, the decision network model and the value network model of the intelligent agent are optimized, and the operation of predicting the response probability of the application sample performing different response actions based on the decision network model of the intelligent agent is returned until the training end condition is reached to obtain the trained decision network model.
[0222] In yet another possible implementation, the device for generating a test script further includes:
[0223] A model retraining unit, configured to detect that the degree of change of the interactive object information of the target application exceeds a set threshold, re-determine the training samples used to train the prediction model based on the latest interactive object information currently updated by the target application, and train the prediction model and the decision network model of the intelligent agent using the re-determined training samples;
[0224] A script regeneration unit is used to return to execute the operation of predicting at least one interaction sequence using the prediction model based on the latest interactive object information currently updated by the target application and the retrained prediction model and the decision network model of the intelligent agent, so as to redefine the test script of the target application.
[0225] In yet another possible implementation, the device further includes:
[0226] A screenshot obtaining unit, used to obtain a first user interface screenshot of a target application of a historical version and a second user interface screenshot of the current target application;
[0227] A feature extraction unit, configured to extract a first interface feature of the first user interface screenshot and a second interface feature of the second user interface screenshot;
[0228] The change confirmation unit is used to determine that the degree of change of the interactive object information of the target application exceeds a set threshold if the feature matching degree between the first interface feature and the second interface feature is less than a set threshold.
[0229] The present application also provides an electronic device. Fig. 9 , which shows a schematic diagram of a composition structure of the electronic device, and the electronic device at least includes a processor 901 and a memory 902;
[0230] The processor 901 is used to execute the method for generating a test script as described in any one of the above embodiments;
[0231] The memory 902 is used to store programs required for the processor to perform operations.
[0232] It can be understood that the electronic device may further include a display unit 903 and an input unit 904 .
[0233] Of course, the electronic device may also have Fig. 9 There may be more or fewer components, without limitation.
[0234] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any method for generating a test script provided in the embodiment of the present application.
[0235] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any one of the methods for generating a test script provided in the embodiment of the present application.
[0236] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0237] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0238] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0239] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for generating a test script, comprising: Obtaining interactive object information of a user interface in a target application to be tested, wherein the interactive object information is used to characterize at least one interactive object in the user interface; Based on the interactive object information, at least one user operation sequence is determined using an artificial intelligence model, wherein the user operation sequence at least includes: at least one user operation data that can be generated by a user interacting with an interactive object in the user interface; Based on each user operation data in the user operation sequence, a test script for testing the target application is generated.
2. The method for generating a test script according to claim 1, wherein the user operation data at least comprises: Identification information of a target interactive object operated by a user, and an operation type of the user interacting with the target interactive object, wherein the target interactive object belongs to the at least one interactive object; The generating a test script for testing the target application based on each user operation data in the user operation sequence includes: For each user operation data in the user operation sequence, based on the operation type corresponding to the user operation data and the script code templates corresponding to different operation types, determine a target script code template suitable for the user operation data; Based on the target script code template and the identification information of the target interactive object, generating a test code corresponding to the user operation data; Based on the test code corresponding to each user operation data in the user operation sequence, a test script for testing the target application is determined.
3. The method for generating a test script according to claim 1, wherein determining at least one user operation sequence based on the interactive object information using an artificial intelligence model comprises: Based on the interactive object information, at least one interactive sequence is predicted using a prediction model, the interactive sequence comprising: at least one set of interactive data generated by the user interacting with the interactive object in the user interface, each set of interactive data comprising user operation data generated by the interactive operation between the user and the interactive object and response data of the target application to the interactive operation; Based on the user operation data and the response data in each interaction data in the interaction sequence, using the policy network model of the intelligent agent, screening out at least one target interaction sequence whose response data matches the user operation data from the at least one interaction sequence; Each user operation data in the target interaction sequence is determined as a user operation sequence to obtain at least one user operation sequence.
4. The method for generating a test script according to claim 3, wherein based on the user operation data and the response data in each interaction data in the interaction sequence, the strategy network model of the intelligent agent is used to screen out at least one target interaction sequence whose response data matches the user operation data from the at least one interaction sequence, comprising: For each group of interaction data in each interaction sequence, based on the user operation data in the interaction data, the agent's policy network model is used to decide the predicted response action corresponding to the user operation data; If the predicted response actions corresponding to the user operation data in the interaction sequence match the response data, the interaction sequence is determined as a target interaction sequence with correct response data, and at least one screened target interaction sequence is obtained.
5. The method for generating a test script according to claim 3 or 4, wherein the prediction model is obtained by training using sample interaction object information in a user interface sample of at least one application sample as a training sample, and taking the minimum difference between a predicted interaction sequence and an actual interaction sequence corresponding to the application sample as a training target, wherein: The sample interaction object information corresponding to the application sample is used to characterize at least one sample interaction object in the user interface sample of the application sample; The strategy network model of the intelligent agent is obtained by combining the predicted interaction sequence of the application sample predicted by the prediction model with reinforcement learning training.
6. The method for generating a test script according to claim 5, wherein the prediction model is a trained long short-term memory network model; The prediction model is trained in the following way: Obtaining sample interaction object information of at least one application sample and an actual interaction sequence of the application sample; For each application sample, based on the sample interaction object information of the application sample, predicting at least one predicted interaction sequence using the long short-term memory network model to be trained; If it is determined based on the predicted interaction sequences and actual interaction sequences of each application sample that the training conditions have not been met, adjust the model parameters of the long short-term memory network model, and return to execute the operation of predicting at least one predicted interaction sequence using the long short-term memory network model to be trained until the training conditions are met to obtain a trained decision network model.
7. According to the method for generating a test script according to claim 5, the strategy network model of the agent is trained by: At least one predicted interaction sequence of at least one application sample predicted by the trained prediction model is obtained, wherein the predicted interaction sequence includes at least one predicted interaction data, and the predicted interaction data includes: Predicting user operation data and predicted response data corresponding to the application sample; For each predicted interaction sequence of each application sample, the agent-based decision network model predicts the response probability of the application sample executing different response actions under the premise that the application sample has the predicted user operation data in the predicted interaction sequence; Based on the predicted response data corresponding to the predicted user operation data and the response probability of the application sample performing different response actions, the value network model of the intelligent agent is used to determine the reward and punishment index value; Based on the reward and punishment index value, the decision network model and the value network model of the agent are optimized, and the operation of predicting the response probability of the application sample performing different response actions based on the decision network model of the agent is returned until the training end condition is reached.
8. The method for generating a test script according to claim 5, further comprising: Detecting that the degree of change of the interactive object information of the target application exceeds a set threshold, re-determining the training samples for training the prediction model based on the latest interactive object information currently updated by the target application, and using the re-determined training samples to train the prediction model and the decision network model of the intelligent agent; Based on the latest updated interactive object information of the target application and the retrained prediction model and agent decision network model, return to execute the operation of using the prediction model to predict at least one interaction sequence so as to redefine the test script of the target application.
9. The method for generating a test script according to claim 8, wherein the step of detecting that the degree of change of the interactive object information of the target application exceeds a set threshold comprises: Obtain a first user interface screenshot of a historical version of a target application and a second user interface screenshot of a current target application; Extracting a first interface feature of the first user interface screenshot and a second interface feature of the second user interface screenshot; If the feature matching degree between the first interface feature and the second interface feature is less than a set threshold, it is determined that the degree of change of the interactive object information of the target application exceeds the set threshold.
10. A device for generating a test script, comprising: An information obtaining unit, used to obtain interactive object information of a user interface in a target application to be tested, wherein the interactive object information is used to characterize at least one interactive object in the user interface; A sequence determination unit, configured to determine at least one user operation sequence using an artificial intelligence model based on the interactive object information, wherein the user operation sequence at least includes: at least one user operation data that can be generated by a user interacting with an interactive object in the user interface; The script generating unit is used to generate a test script for testing the target application based on each user operation data in the user operation sequence.