Application program interface traversal method and device based on machine learning
Through the application interface traversal method based on machine learning, the traversal tree model is trained to generate click strategy, which solves the problems of low efficiency and insufficient coverage in the existing test methods, and realizes efficient and automated application interface traversal, improving detection efficiency .
Patent Information
- Application Number
- CN202011049357.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-09-29
AI Technical Summary
In the existing application testing methods, manual testing is inefficient and error-prone, the controllability and coverage of automated traversal tests cannot be guaranteed, and there are a large number of repetitive and invalid operations, and poor adaptability and scalability.
Using the application interface traversal method based on machine learning, by obtaining the application classification information and current page information, training the traversal tree model to generate click strategy, realizing depth and breadth traversal, recording traversal data for feature serialization, and training the machine learning model to Optimize the traversal strategy.
It improves the efficiency and coverage of application interface traversal, realizes automatic traversal of clicks, is suitable for various test scenarios, and improves detection efficiency.
Smart Images

Figure CN114356744B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computers, and in particular to a method and device for traversing an application program interface based on machine learning. Background Art
[0002] With the popularization of smart terminals, more and more applications are developed for smart terminals. Before each application is released, it is necessary to test the application.
[0003] Currently, commonly used testing methods include manual testing and automated traversal testing. Manual testing is to manually traverse each interface of the application under test, which consumes a lot of manpower, is inefficient, and is prone to omissions and errors. There are two main types of automated traversal testing. The first is the automatic traversal method, which is commonly used by the monkey tool provided by Android. This traversal method is random traversal and clicks, without manual intervention, but this method has poor controllability, and the traversal effectiveness and coverage cannot be guaranteed. The second method uses a preset click strategy. First, all components in the current window are obtained, and then an automated script is written to traverse and click. Common frameworks include appium, Robotium, and uiautomator. These frameworks have their own implementation methods for automated clicks, but they all face the problems of long detection time for single samples, a large number of repeated and invalid operations, incompatibility between the targetedness and coverage of the detection process, and poor adaptability and scalability. Summary of the invention
[0004] In view of the problems existing in the prior art, an embodiment of the present invention provides an application interface traversal method based on machine learning, which has universal applicability, high interface traversal efficiency, and can greatly improve traversal effectiveness and traversal coverage.
[0005] In a first aspect, an embodiment of the present invention provides an application program interface traversal method based on machine learning, comprising:
[0006] Obtaining classification information of a target application and selecting a target traversal tree model corresponding to the classification information; the classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on training of a machine learning model and is used to generate an interface traversal click strategy;
[0007] Acquire the current page information of the target application, input the current page information into the target traversal tree model, and obtain the traversal click strategy of the current page;
[0008] Based on the traversal click strategy, traversal clicks are performed on the current page.
[0009] Furthermore, the traversal tree model is generated by the following method, including:
[0010] Based on the classification information of application samples, configure the corresponding fuzzy click strategy;
[0011] According to the fuzzy click strategy, traverse and click each sample in the application sample, and record the traversal data of each sample;
[0012] The traversal data of all samples are combined into a feature sequence;
[0013] The feature sequence is input into a machine learning model, and the machine learning model is trained to optimize the target metric value, thereby obtaining a traversal tree model corresponding to the classification information.
[0014] Furthermore, the configuration of the corresponding fuzzy click strategy based on the classification information of the application sample specifically includes:
[0015] Based on the application attributes and / or business types in the classification information, configure depth traversal and breadth traversal parameters, including one or more of the following: traversal duration, maximum traversal depth, maximum number of page clicks, maximum number of clicks on components of the same type, component priority click sequence, component type black / white list, component name black / white list, extended traversal conditions, extended traversal depth, login account / password, and search keywords.
[0016] Furthermore, according to the fuzzy click strategy, traversing and clicking each sample in the application sample, and recording the traversal data of each sample, specifically includes:
[0017] For each sample, obtain the attribute information and component information of the current page of the sample;
[0018] According to the fuzzy click strategy and the attribute information and component information of the current page, component traversal click is performed to achieve depth traversal and breadth traversal of the current page, and the attribute information and component information of the current page are updated;
[0019] If the current page traversal is completed, or the depth traversal or breadth traversal condition of the fuzzy click strategy is met, the current page traversal is stopped and the parent page is returned until the depth traversal and breadth traversal of the sample are completed and the traversal data is obtained, which includes the updated attribute information and component information.
[0020] Further, the component traversal click is performed according to the fuzzy click strategy and the attribute information and component information of the current page to achieve the depth traversal and breadth traversal of the current page, and update the attribute information and component information of the current page, specifically including:
[0021] According to the component priority click sequence in the fuzzy click strategy, traverse and click on the components in the current page to achieve deep traversal and breadth traversal of the current page;
[0022] Record page traversal and component click information, including previous / next associated components and previous / next jump pages, to update the property information and component information of the current page.
[0023] Specifically, the depth traversal or breadth traversal conditions include one or more of the following:
[0024] Whether the traversal time has been reached; whether the maximum traversal depth has been reached; whether the maximum number of page clicks has been reached; whether the extended traversal conditions have been met; whether the extended traversal depth has been reached.
[0025] Furthermore, the traversal data of all samples are formed into a feature sequence, specifically including:
[0026] According to the attribute information and component information in the traversal data, mark valid clicks or invalid clicks, as well as key clicks or non-key clicks; the valid click refers to a change in page content after clicking a component, and the key click refers to a window jump after clicking a component;
[0027] Classify page components according to valid clicks and invalid clicks, and key clicks and non-key clicks, to obtain a first training set and a second training set, wherein the first training set includes component information marked as valid clicks or invalid clicks, and the second training set includes component information marked as key clicks or non-key clicks;
[0028] The first training set and the second training set are feature vectorized to obtain a feature sequence.
[0029] Furthermore, the attribute information also includes the number of jumps back from other pages;
[0030] The step of vectorizing the features of the first training set and the second training set to obtain a feature sequence specifically includes:
[0031] The first training set and the second training set are prioritized according to the number of times they are jumped back from other pages; feature vectorization is performed on the prioritized first training set and the second training set to obtain a feature sequence.
[0032] In a second aspect, an embodiment of the present invention provides an electronic device, including:
[0033] at least one processor; and
[0034] at least one memory in communication with the processor, wherein:
[0035] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method described in any optional embodiment of the application program interface traversal method based on machine learning in the first aspect of the embodiment of the present invention.
[0036] In a third aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions execute the machine learning-based application interface traversal method described in the first aspect of the embodiment of the present invention and the method of any optional embodiment thereof.
[0037] The machine learning-based application interface traversal method provided in the embodiment of the present invention can train different traversal tree models for different categories of applications; by inputting the page information of the application into the traversal tree model corresponding to its category, the optimal traversal click strategy of the application can be obtained, and accurate traversal clicks on the application can be achieved according to the optimal traversal click strategy, which can greatly improve the click efficiency, traversal effectiveness and traversal coverage. The method described in the embodiment of the present invention is universal, can realize automatic traversal clicks, and is suitable for various testing and detection scenarios. The embodiment of the present invention can improve the overall detection efficiency of the application by improving the traversal effectiveness and traversal coverage. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 This is a flow chart of a method for traversing an application program interface based on machine learning according to an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of a process flow of a traversal tree model generation method according to an embodiment of the present invention;
[0041] Figure 3 This is a schematic diagram of an application program interface traversal device based on machine learning according to an embodiment of the present invention;
[0042] Figure 4 Schematic diagram of the framework of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] Figure 1 This is a flow chart of the method for traversing an application program interface based on machine learning according to an embodiment of the present invention. Figure 1 The machine learning-based application program interface traversal method shown includes:
[0045] 100, obtaining classification information of a target application, and selecting a target traversal tree model corresponding to the classification information; the classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on training of a machine learning model and is used to generate an interface traversal click strategy;
[0046] 101, obtaining the current page information of the target application, inputting the current page information into the target traversal tree model, and obtaining the traversal click strategy of the current page;
[0047] 102. Perform traversal clicks on the current page based on the traversal click strategy.
[0048] The traversal tree model of the embodiment of the present invention is obtained through training based on a machine learning model. Different applications are classified according to application attributes and / or business types to obtain common features of each type of application. For applications of the same type, there are certain similarities in page layout. Therefore, after the classification is completed, model training can be performed for each type of application to obtain a traversal tree model for each type of application. The traversal tree model can generate an accurate traversal click strategy for the page based on the page information.
[0049] In step 100, the classification information of the application program in the embodiment of the present invention may be determined according to application attributes and / or business types, where the application attributes refer to the attributes of the application program itself, and the business type refers to the traversal requirement information.
[0050] For example, application attributes may include: application introduction, application classification in the application store, application developer information, application name, interface layout, etc. You can also choose to distinguish based on certain keywords, or use semantic analysis to make judgments, thereby classifying applications into financial management, news, tools, etc.
[0051] The business type can refer to the purpose, demand, goal, etc. of the traversal, such as the focus items, including whether there is a privacy policy, whether login is required, whether there is payment, etc.
[0052] The classification information of the embodiment of the present invention can determine the application classification according to the application attribute, or according to the service type, or according to the combination of the application attribute and the service type. The application attribute can include many options, and the service type can be determined according to actual needs, which is not limited in the embodiment of the present invention.
[0053] In step 101, the current page information of the target application is obtained, including the attribute information and component information of the page. The component information of the current page can be collected by registering an auxiliary service. The Android terminal can obtain the attribute information of the current window through the dumpsys window, thereby obtaining the complete page information including the component information.
[0054] For example, the attribute information of the current page may include page ID, page name, page layout, etc., and the component information may include component ID, component name, component position and size, component type, etc.
[0055] The current page information is input into the target traversal tree model corresponding to the classification information of the target application program, and the target traversal tree model is calculated to output the traversal click strategy of the current page.
[0056] Step 101 is a method for traversing a page of a target application program and obtaining a traversal click strategy. After obtaining the traversal click strategy of the page, step 102 performs effective traversal clicks according to key click components and / or effective click components in the traversal click strategy.
[0057] In an embodiment of the present invention, a traversal tree model corresponding to a classification is obtained based on a depth traversal and a breadth traversal of application samples under the classification. When the traversal tree model is used to realize automatic depth traversal and breadth traversal of the application, the application APP is first started, the APP home page information is obtained, the home page information is input into the traversal tree model corresponding to the classification information of the APP, and the traversal click strategy of the APP home page is obtained; click is performed based on the strategy, and if a jump to a sub-page occurs, step 101 is repeated to obtain the page information of the sub-page, the page information of the sub-page is input into the traversal tree model, and the traversal click strategy of the sub-page is obtained, and step 102 is repeated to click based on the sub-page traversal click strategy, and so on. If a jump to a lower-level sub-page occurs, steps 101 and 102 are repeated until the depth traversal and breadth traversal of the target application are completed according to the traversal click strategy.
[0058] The machine learning-based application interface traversal method provided in the embodiment of the present invention can train different traversal tree models for different categories of applications; by inputting the page information of the application into the traversal tree model corresponding to its category, the optimal traversal click strategy of the application can be obtained, and accurate traversal clicks on the application can be achieved according to the optimal traversal click strategy, which can greatly improve the click efficiency, traversal effectiveness and traversal coverage. The method described in the embodiment of the present invention is universal, can realize automatic traversal clicks, and is suitable for various testing and detection scenarios. The embodiment of the present invention can improve the overall detection efficiency of the application by improving the traversal effectiveness and traversal coverage.
[0059] Figure 2 FIG. 1 is a flow chart of a method for generating a traversal tree model according to an embodiment of the present invention. Figure 2 As shown, the traversal tree model in the embodiment of the present invention is generated by the following method, including:
[0060] 200, configuring a corresponding fuzzy click strategy based on the classification information of the application sample;
[0061] 201, according to the fuzzy click strategy, traverse and click each sample in the application sample, and record the traversal data of each sample;
[0062] 202, traversal data of all samples are combined into a feature sequence;
[0063] 203, input the feature sequence into a machine learning model, and train the machine learning model to optimize the target metric value, thereby obtaining a traversal tree model corresponding to the classification information.
[0064] The embodiment of the present invention can configure a fuzzy click strategy corresponding to each category of application programs, perform traversal clicks based on the simulated click strategy, and collect interface traversal data. According to the traversal data collected from different categories, the machine learning model is trained separately to obtain different traversal tree models. For example, category A corresponds to fuzzy click strategy A, and traversal tree model A is obtained through training; category B corresponds to fuzzy click strategy B, and traversal tree model B is obtained through training; and so on.
[0065] The fuzzy click strategy configured for each application category in the embodiment of the present invention may be different or the same. Therefore, the traversal trees obtained by training under different categories may be different or the same, and the embodiment of the present invention does not limit this.
[0066] Based on the above embodiment, step 200, the classification information based on the application sample is used to configure the corresponding fuzzy click strategy, specifically including: based on the application attributes and / or business type in the classification information, configuring the depth traversal and breadth traversal parameters, including one or more of the following: traversal duration, maximum traversal depth, maximum number of page clicks, maximum number of clicks on components of the same type, component priority click sequence, component type black / white list, component name black / white list, extended traversal conditions, extended traversal depth, login account / password, and search keywords.
[0067] For example, if for a certain application classification, the maximum traversal depth of the fuzzy click strategy is set to 5, the extended traversal condition is a special character, and the extended traversal depth is 10 or unlimited. Then when traversing to the 5th level sub-page, if a special character that meets the extended traversal condition is detected by searching for keywords or component names, then the depth traversal will continue to the 10th level sub-page or the traversal will be unlimited in depth. If the extended traversal condition is not met, no deep traversal will be performed when traversing to the 5th level sub-page. The setting of the extended traversal condition in the embodiment of the present invention is particularly suitable for deep traversal and retrieval for a specific keyword, sensitive information, virus information, etc. The specific application method and application field can be determined according to the needs, and the embodiment of the present invention is not limited.
[0068] When a username and password are required after clicking on certain pages or components, you can use the fuzzy click strategy to set the login account / password in advance to complete automated traversal clicks.
[0069] The traversal duration, maximum traversal depth, maximum number of page clicks, etc. can be comprehensively considered based on traversal requirements and efficiency, and are not limited in the embodiments of the present invention.
[0070] The fuzzy click strategy of the embodiment of the present invention is configured according to each application category, each application category is determined according to application attributes and / or business type, so the fuzzy click strategy is ultimately determined according to application attributes and / or business type. The fuzzy click strategies of different application categories may be the same or different.
[0071] The purpose of the fuzzy click strategy is to traverse and cover all pages and components as completely as possible to collect sample data more comprehensively; the parameters of the fuzzy click strategy can be set through the configuration file, as shown below:
[0072]
[0073] The fuzzy click strategy parameters of the embodiment of the present invention include but are not limited to the above parameters, and may also include other parameters, or may only include some of the above parameters. The specific parameter values are determined according to the classification of the application program, reflecting the traversal click strategy of the application program under the classification.
[0074] Based on any of the above optional embodiments, step 201, performing traversal clicks on each sample in the application sample according to the fuzzy click strategy, and recording traversal data of each sample, specifically includes:
[0075] 201.1, for each sample, obtain attribute information and component information of the current page of the sample;
[0076] 201.2, performing component traversal clicks according to the fuzzy click strategy and the attribute information and component information of the current page, so as to implement a depth traversal and a breadth traversal of the current page, and update the attribute information and component information of the current page;
[0077] 201.3, if the current page traversal is completed, or the depth traversal or breadth traversal condition of the fuzzy click strategy is met, the current page traversal is stopped and the parent page is returned until the depth traversal and breadth traversal of the sample are completed and the traversal data is obtained, the traversal data including the updated attribute information and component information.
[0078] For any page of any sample, the embodiment of the present invention performs interface traversal based on the fuzzy click strategy to obtain traversal data, which includes three parts:
[0079] First, obtain the attribute information and component information of the current page;
[0080] Secondly, perform traversal, record traversal information, and update attribute information and component information;
[0081] Finally, stop the current page traversal and organize the current page information and component traversal information.
[0082] Each page of a sample is traversed in this way, and the traversal data of each page is sorted to obtain the traversal data of the sample. The traversal data of each sample can be obtained by the method of the embodiment of the present invention.
[0083] Specifically, in an optional embodiment, the attribute information and component information can be recorded respectively by two data structures, for example, FrameInfo records the attribute information of the page, and WidgetInfo records the component information of the page; part of the information in the data structure can be obtained after entering the page, and the data structure can be initialized by the data obtained at this time; and part of the data is continuously updated during the traversal and clicking process, as follows:
[0084]
[0085]
[0086] It should be noted that the two data structures listed above are only examples and are not limiting. Different data structures can be used according to actual conditions. The parameters in the data structure are also optional and are not limiting. The required parameters can be determined by coordinating the fuzzy click strategy.
[0087] Step 201.1 After entering the current page, the attribute information and component information of the current page are obtained, and the data structure is initialized. For an andorid application sample, the sample can be started by the am command, startIntent or simulated click; the component information of the current page can be collected by registering the auxiliary service, and the attribute information of the current window can be obtained by dumpsyswindow.
[0088] After the application sample is started, for each page of the sample, first, hash the page Activity, layout, name string and other attributes to generate frameId; record the page depth in order to control the depth of the entire traversal process; record the number of jumps from other pages to return (to this page) during the traversal process, which to a certain extent indicates the importance of the page; obtain the information of all clickable components in the current page, and hash the Activity, location, name string and other information of each clickable component to generate the component widgetId, and add the component's own attributes and click-related attributes.
[0089] Some data in the data structure related to the click process may be continuously updated when traversing the clicks in step 201.2.
[0090] Step 201.2 performs traversal clicks on the application sample. After the application sample is started, the current page information is analyzed, and the component priority click sequence, component type black / white list, component name black / white list, and whether it has been clicked, etc. set in the confused click strategy, and traversal clicks are started. For example, if the number of clicks on components of the same type exceeds the maximum number of clicks on components of the same type in the confused click strategy, stop clicking on this type of component and traverse other types of components; if the interface jumps, record the jump relationship of the page, etc., and then repeat the above steps. The jump relationship diagram of the page can be continuously updated during the entire traversal process to achieve complete traversal clicks as much as possible.
[0091] During the traversal process, page traversal and component click information are recorded in real time, including: number of page traversals, click locations, click component information, number of component clicks, previous and subsequent dependent clicks, previous and subsequent page jumps, and other information. The entire click process can be fully expressed through information recording, which is the data basis for subsequent analysis.
[0092] Among them, the key information recorded or updated includes:
[0093] (1) The previous / next associated components and the previous / next jump pages of a component click, such as preWidget, nextWidget, curFrame, nextFrame, etc. in the data structure;
[0094] (2) The number of page clicks on the current page and the number of jumps back from other pages, such as frameClickCount, jumpCount, etc. in the data structure.
[0095] Step 201.3 stops traversal and sorts traversal data. There are two conditions for stopping traversal: first, the current page traversal is completed; second, the depth traversal or breadth traversal condition of the fuzzy click strategy is met. If either condition is met, the traversal of the current page is stopped.
[0096] The depth traversal or breadth traversal conditions include one or more of the following:
[0097] Whether the traversal time has been reached; whether the maximum traversal depth has been reached; whether the maximum number of page clicks has been reached; whether the extended traversal conditions have been met; whether the extended traversal depth has been reached. For example:
[0098] If the page traversal time reaches the traversal time, stop clicking on the page;
[0099] If the page has reached the maximum traversal depth and does not meet the extended traversal conditions, stop the deep traversal;
[0100] If the number of page clicks reaches the maximum number of page clicks, clicks on the page will be stopped;
[0101] If the page has reached the maximum extended traversal depth, stop the depth traversal;
[0102] If all components on the page have been clicked, that is, the page traversal is complete, then stop clicking on the page;
[0103] If you stop clicking on a page, you can return to the previous page by sending KEYCODE_BACK or simulating a click, or jump directly back to the previous page through StartIntent. At this point, the page traversal click is completed, and the traversal data is obtained, including initialization data and data related to the click process, and the data structure is updated.
[0104] The embodiment of the present invention obtains the traversal data of all samples based on sample traversal clicks, trains the machine model through the traversal data, and obtains the traversal tree model of each application classification. Specifically, the embodiment of the present invention normalizes the traversal data containing page information and component traversal information into a feature sequence to train the machine model.
[0105] Based on any of the above optional embodiments, step 202, forming a feature sequence from the traversal data of all samples, specifically includes:
[0106] 202.1. Mark valid clicks or invalid clicks, and key clicks or non-key clicks according to the attribute information and component information in the traversal data; a valid click refers to a change in page content after clicking a component, and a key click refers to a window jump after clicking a component;
[0107] 202.2, classify page components according to valid clicks and invalid clicks, and key clicks and non-key clicks, to obtain a first training set and a second training set, wherein the first training set includes component data marked as valid clicks or invalid clicks, and the second training set includes component data marked as key clicks or non-key clicks;
[0108] 202.3. Perform feature vectorization on the first training set and the second training set to obtain a feature sequence.
[0109] Step 202.1 of the embodiment of the present invention is mainly to mark the traversal data to determine whether the page information has changed. For example, by comparing the frameId value of the current page curFrame and the next page nextFrame structure in the data structure WidgetInfo, if the frameId value changes, it is marked as a valid click, otherwise it is marked as an invalid click, that is, isValidWidget=1 or isValidWidget=0. By comparing the ActivityName value of the current page curFrame and the next page nextFrame structure in WidgetInfo, if the ActivityName value changes, it is marked as a key click, otherwise it is marked as a non-key click, that is, isKeyWidget=1 or isKeyWidget=0. It should be noted that the change in page information refers to any change in the interface information displayed on the front end, including the window name, the size, position, type, etc. of each component. Window jump refers to the change in the top-level Activity of the application before and after the component is clicked.
[0110] Step 202.2 classifies all page components of all application samples into two categories according to valid clicks and invalid clicks and key clicks and non-key clicks. The first training set is the valid click and invalid click component training set D_valid, and the second training set is the key click and non-key click component training set D_key:
[0111] D_valid={(x1,y j ),(x2,y j ),…(x n ,y j ))} (1)
[0112] D_key={(a1,b j ),(a2,b j ),…(a n ,b j ))} (2)
[0113] where x i is the m-dimensional feature of the valid click and invalid click components, a i is the m-dimensional feature of key click and non-key click components, i = 1, ... n, representing n samples; y j and b j is the marking result, j=0 or j=1, y0 represents invalid click, y1 represents valid click, b0 represents non-critical click component, and b1 represents critical click component.
[0114] The component information of the embodiment of the present invention includes multi-dimensional parameters. For example, optional parameters include component size, component position, component name, component type, component description, component current page name, component current page depth, etc. When serializing the component information, the semantic parameters, component type parameters, etc. in the component information can be feature escaped first.
[0115] In an optional embodiment, for semantic parameters such as component name, component description, etc., Bert-as-Service can be used for feature escape and feature vectorization. Bert-as-service is an encoding service that can convert words of indefinite length into fixed-length vectors. It provides a default pre-trained model and can deploy feature escape services on the PC side. After using Bert-as-service to generate word vectors, the word vectors are clustered using the k-means method. The distance calculation method for clustering can be selected according to needs, such as Euclidean distance, Ming's distance, cosine distance, etc. After clustering is completed, the clustered word class is used as the optional value of the feature, such as (login / login, agree / confirm / ok, preferred / selected / fine / recommended, etc.).
[0116] In an optional embodiment, the component type is feature escaped, and the enumeration value of the original component can be used as the input feature, for example:
[0117]
[0118]
[0119] Furthermore, the page information described in the embodiment of the present invention includes the number of jumps back from other pages. This parameter can reflect the importance of the page to a certain extent. Therefore, when the first training set and the second training set are feature vectorized, the first training set and the second training set can be prioritized according to the number of jumps back from other pages. For example, according to the priority size and based on the n-dimensional features of the component information, the effective click component 1, effective click component 2...effective click component n of the first training set are sorted and labeled, and the key click component 1, key click component 2...key click component n of the second training set are sorted and labeled, and the sorted first training set and the second training set are feature vectorized to obtain a feature sequence.
[0120] The embodiment of the present invention performs feature priority sorting according to the importance of the page when performing feature vectorization on the training set, and obtains a traversal tree model after training with a machine learning model; the traversal click strategy of the relevant application classification obtained through the traversal tree model is also sorted according to the component click priority, which can improve the efficiency of traversal click and achieve accurate click.
[0121] At this point, the embodiment of the present invention configures a fuzzy click strategy to traverse clicks on application samples to obtain traversal data; marks the traversal data to obtain component information of valid clicks and invalid clicks, as well as key clicks and non-key clicks, and divides them into two training sets; and performs feature escape on the data in the training set, prioritizes the data in the training set according to the importance of the page, etc., and then performs feature vectorization on the training set to obtain a feature sequence, and trains the machine learning model through the obtained feature sequence.
[0122] The machine learning model in the embodiment of the present invention is a decision tree model, and the decision tree model is constructed using the obtained feature sequence. There are many methods for constructing a decision tree model, and the commonly used ones are: CLS, ID3, C4.5, CART, etc. The embodiment of the present invention takes the C4.5 algorithm to construct a decision tree model as an example to illustrate the implementation details.
[0123] The specific process of using the C4.5 algorithm to screen features and generate a multi-branch tree is as follows:
[0124] i. For a given training set D, the minimum sum variance metric is used to construct the decision tree model, which is defined as the sum of the squares of the differences between the sample value and the expected label value. Specifically, taking a binary tree as an example, whether feature A takes a certain value s will divide the training set D into two sample sets D1 and D2. c1 is the output mean of the D1 sample set, and c2 is the output mean of the D2 sample set. The metric is formula (3):
[0125]
[0126] Where A is a feature dimension, s is a value of feature A, and when feature A is s, the training set D is divided into two parts D1 and D2, where the training set D is D_valid in formula (1) or D_key in formula (2). i is the sample feature vector in the D1 / D2 set, that is, x in formula (1) i Or a in formula (2) i ;y j For the corresponding x i The labeling result of the sample feature, that is, y in formula (1) j Or b in formula (2) j .
[0127] ii. For all optional values of the features, calculate the sum and variance according to the above method, and then select the optional value of the feature with the minimum sum and variance as the optimal feature and the optimal split. Then, based on the optimal feature and the optimal split point, generate two child nodes, and distribute the data in the training set to the two child nodes according to the features and split points.
[0128] iii. Recursively perform steps i and ii on the child nodes until all data are segmented. Thus, the final tree model can be obtained.
[0129] The number of nodes in the decision tree can be controlled according to the distribution of actual features and the number of labeled results. Furthermore, in order to avoid overfitting of the model, the C4.5 model can be pruned. The pruning method of the C4.5 algorithm has room for optimization. There are mainly two ideas. One is pre-pruning, that is, deciding whether to prune when generating the decision tree. The other is post-pruning, that is, generating a decision tree first, and then pruning it through cross-validation, which will not be described here.
[0130] In summary, through the machine learning-based application program interface traversal method described in the embodiment of the present invention, a machine learning model can be trained for each application classification to obtain a traversal tree model corresponding to the classification.
[0131] Finally, the traversal behavior can be evaluated by calculating the click effectiveness and traversal coverage per unit time, such as click effectiveness, traversal coverage, etc.
[0132] Click effectiveness refers to the ratio of the number of clicks that result in screen information changes or jumps to the total number of clicks.
[0133] Traversal coverage refers to the ratio of the number of traversed Activities to the actual number of all Activities.
[0134] When applying the traversal tree model, for an application to be tested, first obtain the classification information of the application to be tested, and obtain the corresponding traversal tree model based on the classification information; input the page information of the application to be tested into the corresponding traversal tree model to obtain the optimal traversal click strategy for the application to be tested, and according to the optimal traversal click strategy, accurate traversal clicks on the application can be achieved. It can greatly improve the click efficiency, traversal effectiveness and traversal coverage. The method described in the embodiment of the present invention is universal, can realize automatic traversal clicks, and is suitable for various testing and detection scenarios. The embodiment of the present invention can improve the overall detection efficiency of the application by improving the traversal effectiveness and traversal coverage.
[0135] When applied in various scenarios, since each click is calculated by the model, it can greatly reduce invalid clicks in indiscriminate traversal. Within a certain number of clicks within a certain period of time, it can greatly improve the effectiveness of clicks and traversal coverage. Therefore, it has high effectiveness and can guarantee the click success rate.
[0136] The method described in the embodiment of the present invention is universal and can improve the effectiveness of clicks for samples of the same type. In the same period of time, the click effectiveness and traversal coverage of the method in the sample set have better average performance than traditional traversal strategies and manually customized strategies. It can be applied to application store application listing detection, application compliance detection by institutions, etc., and can be used to trigger and detect the scenarios concerned by the detection, reduce labor and time consumption, and have good beneficial effects.
[0137] Figure 3 FIG. 1 is a schematic diagram of an application program interface traversal device based on machine learning according to an embodiment of the present invention. Figure 3 As shown, the embodiment of the present invention also provides an application program interface traversal device based on machine learning, including a classification acquisition module 300, a strategy acquisition module 301 and a traversal click module 302;
[0138] The classification acquisition module 300 is used to obtain classification information of the target application and select a target traversal tree model corresponding to the classification information; the classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on machine learning model training and is used to generate an interface traversal click strategy;
[0139] The strategy acquisition module 301 is used to acquire the current page information of the target application, input the current page information into the target traversal tree model, and obtain the traversal click strategy of the current page;
[0140] The traversal click module 302 is used to perform traversal clicks on the current page based on the traversal click strategy.
[0141] The application program interface traversal device based on machine learning in the embodiment of the present invention is used to execute Figure 1 The technical solution of the embodiment of the application program interface traversal method based on machine learning shown in the figure has similar implementation principles and technical effects, which will not be repeated here.
[0142] Figure 4 This is a schematic diagram of the electronic device framework according to an embodiment of the present invention. Figure 4 , an embodiment of the present invention provides an electronic device, including: a processor (processor) 410, a communication interface (Communications Interface) 420, a memory (memory) 430 and a bus 440, wherein the processor 410, the communication interface 420, and the memory 430 complete mutual communication through the bus 440. The processor 410 can call the logic instructions in the memory 430 to execute the following method, including: obtaining the classification information of the target application, selecting the target traversal tree model corresponding to the classification information; the classification information is determined according to the application attribute and / or the business type; the traversal tree model is obtained based on the training of the machine learning model and is used to generate an interface traversal click strategy; obtaining the current page information of the target application, inputting the current page information into the target traversal tree model, and obtaining the traversal click strategy of the current page; based on the traversal click strategy, traversing and clicking the current page.
[0143] An embodiment of the present invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining classification information of a target application, and selecting a target traversal tree model corresponding to the classification information; the classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on machine learning model training and is used to generate an interface traversal click strategy; obtaining current page information of the target application, inputting the current page information into the target traversal tree model, and obtaining a traversal click strategy for the current page; and performing traversal clicks on the current page based on the traversal click strategy.
[0144] An embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable the computer to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining classification information of the target application, and selecting a target traversal tree model corresponding to the classification information; the classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on machine learning model training and is used to generate an interface traversal click strategy; obtaining the current page information of the target application, inputting the current page information into the target traversal tree model, and obtaining the traversal click strategy of the current page; and traversing and clicking the current page based on the traversal click strategy.
[0145] A person skilled in the art can understand that the implementation of the above-mentioned device embodiment or method embodiment is only illustrative, wherein the processor and the memory may be physically separated components or may not be physically separated, that is, they may be located in one place, or they may be distributed on 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. A person skilled in the art can understand and implement it without paying creative labor.
[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a USB flash drive, a mobile hard disk, ROM / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An application program interface traversal method based on machine learning, characterized in that: include: Obtaining classification information of a target application, and selecting a target traversal tree model corresponding to the classification information; The classification information is determined according to application attributes and / or business types; the traversal tree model is obtained based on machine learning model training and is used to generate an interface traversal click strategy; Acquire the current page information of the target application, input the current page information into the target traversal tree model, and obtain the traversal click strategy of the current page; Based on the traversal click strategy, traversal click is performed on the current page; The traversal tree model is generated by the following method, including: Based on the classification information of application samples, configure the corresponding fuzzy click strategy; According to the fuzzy click strategy, traverse and click each sample in the application sample, and record the traversal data of each sample; The traversal data of all samples are combined into a feature sequence; The feature sequence is input into a machine learning model, and the machine learning model is trained to optimize the target metric value, thereby obtaining a traversal tree model corresponding to the classification information.
2. The method according to claim 1, characterized in that The configuration of the corresponding fuzzy click strategy based on the classification information of the application sample specifically includes: Based on the application attributes and / or business types in the classification information, configure the depth traversal and breadth traversal parameters, including one or more of the following: Traversal duration, Maximum traversal depth, Maximum number of page clicks, Maximum number of clicks on components of the same type, Component priority click sequence, Component type black / white list, Component name black / white list, Extended traversal conditions, Extend the traversal depth, Login ID / password and Search keywords.
3. The method according to claim 2, characterized in that According to the fuzzy click strategy, traversing and clicking each sample in the application sample, and recording the traversal data of each sample, specifically includes: For each sample, obtain the attribute information and component information of the current page of the sample; According to the fuzzy click strategy and the attribute information and component information of the current page, component traversal click is performed to achieve depth traversal and breadth traversal of the current page, and the attribute information and component information of the current page are updated; If the current page traversal is completed, or the depth traversal or breadth traversal condition of the fuzzy click strategy is met, the current page traversal is stopped and the parent page is returned until the depth traversal and breadth traversal of the sample are completed and the traversal data is obtained, which includes the updated attribute information and component information.
4. The method according to claim 3, characterized in that The component traversal click is performed according to the fuzzy click strategy and the attribute information and component information of the current page to achieve the depth traversal and breadth traversal of the current page, and update the attribute information and component information of the current page, specifically including: According to the component priority click sequence in the fuzzy click strategy, traverse and click on the components in the current page to achieve deep traversal and breadth traversal of the current page; Record page traversal and component click information, including previous / next associated components and previous / next jump pages, to update the property information and component information of the current page.
5. The method according to claim 4, characterized in that The depth traversal or breadth traversal conditions include one or more of the following: Whether the traversal time is reached; Whether the maximum traversal depth has been reached; Whether the maximum number of page clicks has been reached; Whether the extended traversal conditions are met; Whether the extended traversal depth has been reached.
6. The method according to any one of claims 1 to 5, characterized in that: The traversal data of all samples are formed into a feature sequence, specifically including: According to the attribute information and component information in the traversal data, mark valid clicks or invalid clicks, as well as key clicks or non-key clicks; the valid click refers to a change in page content after clicking a component, and the key click refers to a window jump after clicking a component; Classify page components according to valid clicks and invalid clicks, and key clicks and non-key clicks, to obtain a first training set and a second training set, wherein the first training set includes component information marked as valid clicks or invalid clicks, and the second training set includes component information marked as key clicks or non-key clicks; The first training set and the second training set are feature vectorized to obtain a feature sequence.
7. The method according to claim 6, characterized in that The attribute information also includes the number of jumps back from other pages; The step of vectorizing the features of the first training set and the second training set to obtain a feature sequence specifically includes: Prioritizing the first training set and the second training set respectively according to the number of times of jumping back from other pages; The sorted first training set and the second training set are vectorized to obtain feature sequences.
8. An electronic device, characterized in that: include: at least one processor; as well as at least one memory in communication with the processor, wherein: The memory stores program instructions executable by the processor, and the processor can execute the method according to any one of claims 1 to 7 by calling the program instructions.
9. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method according to any one of claims 1 to 7.
