Sandbox automatic testing method and equipment based on computer vision and machine learning and computer storage medium
Through computer vision and machine learning technology, we build an operational element and business scenario recognition model, which solves the problems of poor adaptability and poor interface recognition of traditional automated testing tools on smart phone devices, and achieves comprehensive automated testing of smart phone device applications. and safety assessment.
Patent Information
- Application Number
- CN202410837210.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-26
AI Technical Summary
Traditional rule-based automated testing tools are difficult to write universal rules for application processing on smart phone devices. They lack adaptability when faced with complex and changeable application scenarios, and the interface recognition effect is poor, especially when there are interface changes and third parties. Frame failure.
The sandbox automated testing method based on computer vision and machine learning is used to collect operation video data, extract screen layout information and feature elements, and build an operable element classification model and a business scenario recognition model to achieve automated testing.
It achieves comprehensive and reliable automated testing of smartphone device applications, can identify potential security vulnerabilities and abnormal behaviors, has real-time monitoring and continuous optimization capabilities, and improves the accuracy and robustness of testing.
Smart Images

Figure CN118656301A
Abstract
Description
Technical Field
[0001] The invention belongs to the field of automated testing technology, and in particular relates to a sandbox automated testing method, equipment and computer storage medium based on computer vision and machine learning. Background Art
[0002] In the prior art, rule-based automated testing tools face a series of challenges in processing applications on smartphone devices. Traditional automated testing tools usually rely on parsing and rule matching of interface xml elements to perform depth-first or breadth-first traversal operations. However, this method is difficult to write general rules to cover all possible situations when facing a variety of mobile applications, especially applications that cross-integrate multiple business scenarios, such as office, dating, finance, shopping, etc. Even more complex situations, such as live streaming. Traditional methods also face the problem of inaccurate interface change recognition, such as it is difficult to distinguish whether the change in control focus is a new pop-up dialog box or an advertising page, and in the case of an overlong ListView, flipping pages up and down causes the overall update of the interface body. It can be seen that these methods often lack universal adaptability to many application scenarios, have limited coverage, and have poor interface recognition effects.
[0003] In extreme cases, when the interface layout does not change, but the display subject in the layout is replaced, the traditional method will completely fail. The most typical scenario is game applications. Mobile games on mobile terminals usually integrate third-party frameworks, which are completely independent of the mobile phone interface layout. All interface switching in the game occurs within the third-party framework; the outermost system-based interface layout does not change. At this point, the traditional application behavior automatically triggers the system to completely lose its function. Summary of the invention
[0004] The purpose of the present invention is to solve the problems in the prior art and propose a sandbox automation testing method, device and computer storage medium based on computer vision and machine learning, which can provide a comprehensive and reliable automation tool for application security compliance detection and software development testing, and is more practical for the complex and changeable application scenarios in smart phone devices.
[0005] In order to achieve the above object, the present invention adopts the following technical scheme.
[0006] The sandbox automated testing method based on computer vision and machine learning comprises collecting operation video data of a sandbox terminal, and saving a screen layout information file and an operation mark sequence file of the video data according to a timestamp;
[0007] The video data is divided into operation slices of a plurality of scenes, the slices are framed, each frame of the extracted image is preprocessed, and feature elements in the preprocessed image are extracted by a feature extraction algorithm and the screen layout information file;
[0008] The extracted feature elements are input into a computer vision network model for training, an operable element classification model is constructed, the operable element classification model identifies the operable elements in the video data, the operable elements are input into a machine learning model for self-supervised learning training, a business scenario recognition model is constructed, and the business scenario recognition model outputs prediction results according to the collected video data for automated testing.
[0009] Furthermore, the video recording data includes user operation behaviors, interface interactions and application scenario conversions of the terminal.
[0010] Furthermore, the operation mark sequence file records user interaction events during the use of the terminal, each event includes a screen coordinate position, and the screen coordinate position of each event is saved one by one according to the timestamp.
[0011] Furthermore, the operation slicing of dividing the video data into several scenes includes, during the operation of each terminal, identifying returning to the application homepage as a sign of the end of a scene operation, and dividing the video data into different operation scenes according to the identification sign.
[0012] Further, extracting frames from slices includes:
[0013] After extracting frames from the slices, the interface changes are determined based on image similarity, and the identified independent interfaces are retained to obtain a set of ordered images of the video slices representing an operation scene. The corresponding screen layout information file is obtained based on the timestamp of the retained frames.
[0014] Furthermore, the step of inputting the extracted characteristic elements into a machine learning model for training and constructing an operational element classification model includes:
[0015] The extracted feature elements are manually labeled, and the labeled feature elements are divided into a feature element training set and a feature element test set. The feature element training set is input into the machine learning model for model training, and the feature element test set is input into the trained machine learning model for model verification to obtain an operational element classification model.
[0016] Furthermore, the step of inputting the operable elements into a self-supervised learning model for self-supervised learning training to construct a business scenario recognition model includes:
[0017] After obtaining the image frame sequence representing the scene and the information of the operable elements in the image, a single complete scene is regarded as a single sentence, and the orderly arranged interface pictures and interface operation objects in a single scene are regarded as words, and semantic training is performed using a machine learning model.
[0018] Furthermore, it also includes,
[0019] Collect new operation video data of the sandbox terminal, and use the feedback mechanism to optimize the business scenario recognition model. Adjust the parameters of the business scenario recognition model by comparing and analyzing the prediction results with actual user behaviors.
[0020] In order to achieve the above-mentioned objectives, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a program running on the processor, and when the processor runs the program, the steps of the sandbox automated testing method based on computer vision and machine learning are executed as described above.
[0021] In order to achieve the above objectives, the present invention also provides a computer-readable storage medium on which computer instructions are stored. When the computer instructions are executed, the steps of the sandbox automated testing method based on computer vision and machine learning as described above are executed.
[0022] Beneficial Effects
[0023] The present invention proposes a sandbox automated testing method, device and computer storage medium based on computer vision and machine learning, which has the following beneficial effects:
[0024] (1) Comprehensiveness and accuracy: Combining computer vision and machine learning technologies, it can comprehensively evaluate the security, performance, and reliability of software programs in smartphone devices and accurately identify potential security vulnerabilities and abnormal behaviors.
[0025] (2) Automation and efficiency: The tool can automatically perform test tasks, reduce manual intervention, and improve test efficiency. It no longer relies on predefined rules, but instead performs intelligent triggering by simulating user behavior.
[0026] (3) Real-time monitoring and feedback: By collecting data in real time in the sandbox environment, abnormal behavior can be discovered and reported in a timely manner, allowing problems to be resolved quickly.
[0027] (4) Continuous optimization: Machine learning models continuously learn and improve to adapt to changing application scenarios and improve the accuracy and robustness of tests.
[0028] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0030] Figure 1 A flowchart of the sandbox automated testing method based on computer vision and machine learning of the present invention;
[0031] Figure 2 A schematic diagram of interface element feature extraction in sandbox automated testing based on computer vision and machine learning of the present invention;
[0032] Figure 3 A schematic diagram of the training of an interface operable element recognition model in sandbox automated testing based on computer vision and machine learning of the present invention;
[0033] Figure 4 A schematic diagram of identifying and classifying operable elements in a sandbox automated testing interface based on computer vision and machine learning of the present invention;
[0034] Figure 5 This is a schematic diagram of a business scenario recognition model constructed in the sandbox automated testing interface based on computer vision and machine learning of the present invention. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0036] Example 1
[0037] Figure 1 The following is a flow chart of the sandbox automated testing method based on computer vision and machine learning according to the present invention. Figure 1 , the sandbox automated testing method based on computer vision and machine learning of the present invention is described in detail.
[0038] In step 101, operation video data of the sandbox terminal is collected, and a screen layout information file and an operation mark sequence file of the video data are saved according to a timestamp.
[0039] Preferably, the use videos of APPs on smartphone devices are collected, for example, at least 1,000 different APPs or 1,000 use videos are collected, which record the user's operations on the device, including screenshots, user interaction events, etc. The video data covers the user's operation behavior on the APP, interface interaction, and conversion of application scenarios.
[0040] Preferably, during the video recording process, an XML file containing screen layout information and a matching operation mark sequence file are saved according to timestamps (per second).
[0041] Preferably, in the operation mark sequence, events such as user clicks, slides, text inputs, etc. during the use of the APP are recorded, each event includes a screen coordinate position, and is saved one by one according to the timestamp.
[0042] In this embodiment, the sandbox refers to the software and hardware environment required for the APP to run, which can be an actual Android phone with a specific ROM burned in, a customized development board, or even a customized simulator compatible with the ARM instruction set. The sandbox is required to be able to collect and retain all-round data of the APP operation process, such as screenshots and videos.
[0043] In step 102, the video data is divided into operation slices of a plurality of scenes, the slices are framed, each frame image is preprocessed, and feature elements in the preprocessed image are extracted using a feature extraction algorithm and the screen layout information file.
[0044] Preferably, the video is divided into different operation scenes. During the operation of each APP, "return to the application homepage" is identified as a sign of the end of a scene operation. According to this rule, the application operation video is divided into operation slices of several scenes.
[0045] Preferably, after extracting frames from the slices, the interface changes are determined based on the image similarity, and all identifiable independent interfaces are retained. In this way, a set of ordered images representing the video slices of an operation scene is obtained, and the corresponding layout XML file is found based on the timestamps of the retained frames.
[0046] Preferably, each frame of image is preprocessed, including denoising, enhancement, edge detection and other preprocessing operations, to prepare for the subsequent feature extraction step.
[0047] Preferably, if Figure 2 As shown, various feature extraction algorithms, such as edge detection, corner detection, color histogram, etc., are used, combined with the layout information in the XML file, to extract key feature elements from the processed image, such as the position, size, color, etc. of the interface elements. These features help the system identify various operable objects on the interface.
[0048] In step 103, the extracted feature elements are input into a computer vision network model for training, an operable element classification model is constructed, the operable element classification model identifies the operable elements in the video data, the operable elements are input into a machine learning model for self-supervised learning training, a business scenario recognition model is constructed, and the business scenario recognition model outputs prediction results according to the collected video data for automated testing.
[0049] Preferably, if Figure 3 As shown in the figure, the operational element recognition model is implemented based on a supervised learning model. First, it is necessary to manually annotate the key feature elements of the interface element feature extraction, divide the annotated key feature elements into a training set and a test set, input the training set into the Faster R-CNN model for training, and then input the test set into the trained Faster R-CNN model for testing to obtain the operational element recognition model. Figure 4 As shown, the operable element recognition model is used to automatically identify the operable object information on the interface to be detected, including elements that users can interact with, such as buttons, text boxes, sliders, etc., and the identified operable objects are classified and marked according to their attributes.
[0050] Preferably, the steps of building a business scenario recognition model can be specifically performed as follows: after obtaining the image sequence representing the scene and the information of the operable objects in each image, each complete scene is regarded as a sentence, and the orderly arranged interface images and interface operation objects in each scene are regarded as words; the APP operation scenario intelligent recognition model generated by the Transformer architecture training is used for semantic training. In this process, the system does not need to mark the data in advance, but automatically discovers the patterns and structures in the data by observing the data. The patterns include scene classification of interfaces and interface sequences with similar specific features; the structures include the summary and understanding of the behavior trigger sequences that may exist in specific scenarios, as well as the inherent correlation between the scenes and interface switches caused by the behavior triggers.
[0051] In this embodiment, the business scenario recognition model is implemented based on an unsupervised learning model, such as Figure 5 As shown in the figure, the business scenario recognition model automatically analyzes the APP usage video to identify different business scenarios. It can recognize the patterns between user behavior and interface interaction, automatically segment the video, and mark different business scenarios. For example, when a user enters the home page from the login interface and then enters the settings page, the system can accurately identify the switching of these scenarios.
[0052] In this embodiment, Figure 5As shown, the frames marked with operable object information are input into the Transformer encoder according to the frame feature sequence, and the frame feature sequence and the position encoding of the operable object are input into the Transformer encoder for model training to obtain a business scene recognition model, output the feature representation of the frame sequence, perform business scene prediction, predict the business scene and behavior of the next frame, and perform operations on the corresponding scene. It also includes delivering the same operation to similar identified scenes. The frame feature sequence includes a record of click behavior of interface elements. Through position encoding, the behavior can be mapped to the operable object, and the corresponding operable object can be found through the position of the interface element click behavior in the entire interface and the position of the frame feature sequence.
[0053] Preferably, new APP usage video data is continuously collected and the feedback mechanism is used to optimize the unsupervised learning model. By comparing and analyzing the actual user behavior, the system adjusts the model parameters to improve the accuracy and stability of the recognition of business scenarios and operable objects.
[0054] The present invention can identify the business scenarios and operable objects of the APP in real time, providing data support for subsequent automated testing. When abnormal behavior or security vulnerabilities are found, the system can report them in a timely manner to help developers fix the problems. Through these steps, the system can automatically identify the operable objects and business scenarios of the APP using unsupervised learning technology, providing a strong foundation for automated testing.
[0055] The invention proposes a sandbox automated testing tool based on computer vision and machine learning, which combines APP operation data, interface layout data, and screenshot and recording data, and uses machine vision technology to self-learn interface changes and interface operable elements; segment APP operation behaviors based on business scenarios, and use this as training corpus to build a machine learning model based on self-supervised learning; use the attention mechanism to parse the inherent business logic and contextual association of the learning application scenario, and then fully automate the test operation for the reproduced scenario. It is used to perform automated testing and security assessment on software programs in smart phone devices. The tool combines computer vision technology and machine learning algorithms, and can simulate user behavior and execute software programs in a controlled environment to detect possible security vulnerabilities or abnormal behaviors. During the test, the tested software runs in a customized sandbox, and the behavior and network data of the sample software can be collected and detected in real time. Computer vision technology is used to capture the interactive interface of the software program, identify changes and switching of the interface; analyze interface elements, and parse the control objects that can be clicked, slid, zoomed, and inputted in the interface; and the machine learning algorithm is used to identify the business scenarios of the application, understand and learn the inherent associations between interface changes during continuous operation, and then execute logical behavior triggering.
[0056] Those skilled in the art can understand that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention is described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions recorded in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A sandbox automated testing method based on computer vision and machine learning, characterized in that: include: Collecting the operation video data of the sandbox terminal, and saving the screen layout information file and the operation mark sequence file of the video data according to the timestamp; The video data is divided into operation slices of a plurality of scenes, the slices are framed, each frame of the extracted image is preprocessed, and feature elements in the preprocessed image are extracted by a feature extraction algorithm and the screen layout information file; The extracted feature elements are input into a computer vision network model for training, an operable element classification model is constructed, the operable element classification model identifies the operable elements in the video data, the operable elements are input into a machine learning model for self-supervised learning training, a business scenario recognition model is constructed, and the business scenario recognition model outputs prediction results according to the collected video data for automated testing.
2. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The video recording data includes the user operation behavior of the terminal, interface interaction and conversion of application scenarios.
3. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The operation mark sequence file records user interaction events during the use of the terminal, each event includes a screen coordinate position, and the screen coordinate position of each event is saved one by one according to the timestamp.
4. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The operation slices for dividing the video data into several scenes include, during the operation of each terminal, identifying returning to the application homepage as a sign of the end of a scene operation, and dividing the video data into different operation scenes according to the identification sign.
5. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The extracting of frames from slices comprises: After extracting frames from the slices, the interface changes are determined based on image similarity, and the identified independent interfaces are retained to obtain a set of ordered images of the video slices representing an operation scene. The corresponding screen layout information file is obtained based on the timestamp of the retained frames.
6. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The extracting characteristic elements are input into the machine learning model for training, and the construction of the operational element classification model includes: The extracted feature elements are manually labeled, and the labeled feature elements are divided into a feature element training set and a feature element test set. The feature element training set is input into the machine learning model for model training, and the feature element test set is input into the trained machine learning model for model verification to obtain an operational element classification model.
7. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: The step of inputting the operable elements into the self-supervised learning model for self-supervised learning training and constructing the business scenario recognition model comprises: After obtaining the image frame sequence representing the scene and the information of the operable elements in the image, a single complete scene is regarded as a single sentence, and the orderly arranged interface pictures and interface operation objects in a single scene are regarded as words, and semantic training is performed using a machine learning model.
8. The sandbox automated testing method based on computer vision and machine learning according to claim 1, characterized in that: Also includes, Collect new operation video data of the sandbox terminal, and use the feedback mechanism to optimize the business scenario recognition model. Adjust the parameters of the business scenario recognition model by comparing and analyzing the prediction results with actual user behaviors.
9. An electronic device, characterized in that: It includes a memory and a processor, wherein the memory stores a program running on the processor, and when the processor runs the program, the sandbox automated testing method based on computer vision and machine learning described in any one of claims 1-8 is executed.
10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed, the sandbox automated testing method based on computer vision and machine learning described in any one of claims 1 to 8 is executed.
Citation Information
Patent Citations
Automatic test method based on machine learning and terminal
CN108763068A
Mobile terminal automatic software testing method based on control function labeling
CN112148608A
Image detection method and device, electronic equipment and storage medium
CN112150464A
Method and system for monitoring game state of mobile phone
CN113806174A
Vehicle machine screen control method and device, medium and electronic equipment
CN114327185A
