A testing method, Appium client and computer storage medium
Through the Appium client, the application pages are parsed and clicked step by step, which solves the problems of low testing efficiency and large scripts in the existing technology, and realizes efficient and automated testing of hybrid development applications.
Patent Information
- Application Number
- CN202110082134.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-21
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2041-01-21
AI Technical Summary
Existing application testing methods are inefficient in testing, unable to detect the risks brought by new features in a timely manner, and applications for hybrid development require writing and maintaining a large number of scripts, resulting in high costs.
Through the Appium client, get the i-level page of the application and parse the page according to the type of the page handle, obtain clickable elements, perform click tests, and traverse the page step by step until the maximum page depth is reached and the test results are determined.
It improves the testing efficiency of applications, reduces the need for coding and maintenance scripts for different applications, reduces manpower consumption, and can promptly detect application problems.
Smart Images

Figure CN113742211B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to application testing technology, and more particularly to a testing method, an Appium client, and a computer storage medium. Background Art
[0002] At present, mobile application development technologies are quite broad, usually involving Native, H5, mini programs, RN, Flutter and other technologies.
[0003] As a cross-platform automated testing tool, Appium meets the needs of automated testing to a certain extent, reducing the manpower of testers in the main process testing during regression testing. However, for hybrid development applications, it is necessary to write / maintain scripts in a targeted manner, which makes the script volume large, resulting in high application testing costs and failure to discover risks brought by new functions in a timely manner; it can be seen that the existing application testing methods have technical problems such as low testing efficiency. Summary of the invention
[0004] The embodiments of the present application provide a testing method, an Appium client, and a computer storage medium, which can improve the testing efficiency of an application program.
[0005] The technical solution of this application is implemented as follows:
[0006] The present application embodiment provides a testing method, which is applied to an Appium client, wherein the Appium client is connected to a terminal through an Appium server, and an application is installed on the terminal, including:
[0007] Obtaining the i-level page of the application; wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page;
[0008] When i is less than the maximum page depth of the application, the i-level page is parsed according to the type of the handle of the i-level page to obtain the clickable elements of the i-level page; wherein the maximum page depth of the application is the total number of pages of the application;
[0009] Perform a click test on the clickable elements of the i-level page to obtain the test result of the i-level page, update i to i+1, and return to execute the step of obtaining the i-level page of the application;
[0010] When i is greater than or equal to the maximum page depth of the application, the test result of the i-level page is determined as the test result of the application.
[0011] The embodiment of the present application provides an Appium client, which is connected to a terminal through an Appium server, and an application is installed on the terminal, including:
[0012] An acquisition module, used to acquire the i-level page of the application; wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page;
[0013] A parsing module, configured to parse the i-level page according to the type of the handle of the i-level page to obtain clickable elements of the i-level page when i is less than the maximum page depth of the application; wherein the maximum page depth of the application is the total number of pages of the application;
[0014] A testing module, used for performing a click test on the clickable elements of the i-level page, obtaining the test result of the i-level page, updating i to i+1, and returning to execute the acquisition module to acquire the i-level page of the application;
[0015] The determination module is used to determine the test result of the i-level page as the test result of the application when i is greater than or equal to the maximum page depth of the application.
[0016] An embodiment of the present application also provides an Appium client, which is connected to a terminal through an Appium server, and an application is installed on the terminal. The Appium client includes: a processor and a storage medium storing instructions executable by the processor, and the storage medium relies on the processor to perform operations through a communication bus. When the instructions are executed by the processor, the test method described in one or more of the above embodiments is executed.
[0017] An embodiment of the present application provides a computer storage medium storing executable instructions. When the executable instructions are executed by one or more processors, the processors execute the test method described in one or more of the above embodiments.
[0018] The embodiment of the present application provides a test method, an Appium client, and a computer storage medium. The Appium client is connected to a terminal through an Appium server, and an application is installed on the terminal, including: obtaining an i-level page of the application, when i is less than the maximum page depth of the application, parsing the i-level page according to the type of the handle of the i-level page, obtaining clickable elements of the i-level page, performing a click test on the clickable elements of the i-level page, obtaining a test result of the i-level page, updating i to i+1, returning to execute to obtain the i-level page of the application, when i is greater than or equal to the maximum page depth of the application, determining the test result of the i-level page as the test result of the application, wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page, and the maximum page depth of the application is the total number of pages of the application; that is, in the embodiment of the present application , by traversing the pages of the application according to the preset levels, and parsing each level of the pages according to the type of the handle of each level of the pages, the clickable elements of each level of the pages are obtained, and then the clickable elements of each level of the pages are tested. In this way, by traversing the pages of the application level by level and parsing the pages according to the handles, the pages can be parsed using the corresponding parsing methods for different page handles. Then, each page can be fully parsed. For applications that use multiple technologies, more functions of the application can be covered, which is conducive to the testing of applications that mix multiple technologies. Moreover, for different applications, it is only necessary to pre-set the maximum page depth of the application to achieve automated testing of any application, avoiding the manpower consumption brought by developers coding / maintaining scripts for different applications, thereby improving the testing efficiency of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic diagram of a flow chart of an optional testing method provided in an embodiment of the present application;
[0020] Figure 2 A flowchart of Example 1 of an optional testing method provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a flow chart of Example 2 of an optional testing method provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of an example structure of an optional page depth provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of the structure of an Appium client provided in an embodiment of the present application Figure 1 ;
[0024] Figure 6 A schematic diagram of the structure of an Appium client provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0025] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0026] Embodiment 1
[0027] The present application embodiment provides a testing method, which is applied to an Appium client, wherein the Appium client is connected to a terminal through an Appium server, and an application is installed on the terminal. Figure 1 A flow chart of an optional testing method provided in the embodiment of the present application is provided, see Figure 1 As shown, the above test method may include:
[0028] S101: Obtaining the i-level page of the application;
[0029] At present, hybrid development applications generally use technologies such as Native, H5, mini-programs, RN and Flutter. When testing hybrid development applications, the cost of coding / maintaining scripts is high, and the risks brought by new functions cannot be discovered in time, such as native application CRASH, ANR and H5 page resource loading failure.
[0030] In order to reduce the testing cost and avoid the risk of new functions not being covered by existing testing methods, the present application provides a testing method. First, the Appium client obtains the i-level page of the application; wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page. For example, the startup page of WeChat is a level 0 page. After the startup is completed, it jumps to the login page, which is a level 1 page. After the login is completed, it jumps to the next level page, and so on. The level of each page of the application can be determined.
[0031] It should be noted that in actual testing, the initial value of i is 0, and the Appium client traverses all pages of the application to complete the application more comprehensively.
[0032] S102: when i is less than the maximum page depth of the application, parse the i-level page according to the type of the handle of the i-level page to obtain the clickable elements of the i-level page;
[0033] Specifically, after the Appium client obtains the i-level page, the Appium client first compares the relationship between i and the maximum page depth of the application, where the maximum page depth of the application is the total number of pages of the application, and the maximum page depth of the application is pre-set. Taking the level 0 page with a maximum page depth of 3 as an example, the Appium client determines that 0 is less than 3, parses the level 0 page according to the type of the level 0 page handle, and obtains the clickable elements of the level 0 page.
[0034] That is, in S102, the Appium client first determines the type of the handle of the i-level page, and uses different parsing methods for different types of handles to parse the i-level page. Such targeted parsing of the page makes the clickable elements of the parsed i-level page more comprehensive.
[0035] Furthermore, in order to parse and obtain clickable elements of the level i page, in an optional embodiment, parsing the level i page according to the type of the handle of the level i page to obtain the clickable elements of the level i page may include:
[0036] Parse the i-level page according to the type of the handle of the i-level page, and obtain the nodes of the i-level page and the attributes of the nodes of the i-level page;
[0037] Get the kth node from the nodes of the i-level page;
[0038] When k is less than the number of nodes in the i-level page, and the sum of the number of attributes of the k-th node is less than or equal to 0, k is updated to k+1, and the execution returns to obtain the k-th node from the nodes in the i-level page;
[0039] When k is less than the number of nodes of the i-level page, and the sum of the number of attributes of the k-th node is greater than 0, determine whether the k-th node is a clickable element of the i-level page based on the attributes of the k-th node, update k to k+1, and return to execute to obtain the k-th node from the nodes of the i-level page;
[0040] When k is greater than or equal to the number of nodes of the i-level page, the clickable elements of the i-level page are obtained.
[0041] Specifically, the Appium client first determines the type of the handle of the level i page, and then parses the level i page according to the determined type of the handle, and can obtain the nodes of the level i page and the attributes of the nodes of the level i page. After determining the nodes of the level i page and the attributes of the nodes of the level i page, it is necessary to filter the nodes of the level i page and select the nodes that meet the requirements from the nodes of the level i page as clickable elements.
[0042] Among them, the node of the i-level page can be one or more, and this embodiment of the present application does not make any specific limitation on this.
[0043] The Appium client first obtains the kth node from the nodes of the i-level page, where the initial value of k is 0, and traverses from the 0th node. Taking the number of nodes of the i-level page as 3 as an example, 0 is less than 3, and it is determined that the sum of the number of attributes of the 0th node is less than or equal to 0, indicating that the 0th node has no attributes, that is, the 0th node is an invalid node and not a clickable element. Therefore, the 0th node is filtered out, and the next node is traversed again, that is, k is updated to k+1, and the first node is obtained from the nodes of the i-level page. 1 is less than 3, and it is determined that the sum of the number of attributes of the first node is greater than 0. That is, the first node is a valid node. At this time, it is determined whether the first node is a clickable element of the i-level page according to the attributes of the first node, and then k is updated to k+1, and it is returned to obtain the second node from the nodes of the i-level page. By analogy, after traversing all the nodes of the i-level page, the clickable element of the i-level page can be obtained.
[0044] In order to parse and obtain the nodes of the level i page and the clickable elements of the nodes of the level i page, in an optional embodiment, parsing the level i page according to the type of the handle of the level i page to obtain the nodes of the level i page and the properties of the nodes of the level i page may include:
[0045] When the type of the handle of the level i page is Native, the level i page is format converted to obtain the node of the level i page;
[0046] The nodes of the i-level page are processed by DocumentBuilder to obtain M attributes of the nodes of the i-level page.
[0047] Here, when the Appium client finds that the handle of the i-level page is Native, it first obtains the page xml and converts UTF-8 to GBK, so that the node of the i-level page can be obtained, and then converted into DocumentBuilder to obtain Document, thereby obtaining the attributes of the node of the i-level page, where the number of attributes is M, and the attributes include: display size and boundary coordinates.
[0048] In addition, in order to parse and obtain the nodes of the level i page and the clickable elements of the nodes of the level i page, in an optional embodiment, parsing the level i page according to the type of the handle of the level i page to obtain the nodes of the level i page and the properties of the nodes of the level i page may include:
[0049] When the type of the handle of the level i page is WebView, the level i page is parsed according to the preset H5 page parsing rules to obtain the nodes of the level i page and the attributes of the nodes of the level i page;
[0050] Here, when the Appium client finds that the handle of the i-level page is WebView, it first switches (SwitchTo) to the WebView handle, and then parses the i-level page according to the preset H5 page parsing rules to obtain the nodes of the i-level page, where the nodes of the i-level page include: elements of the button tag, elements of the a tag, elements containing onclick event attributes, elements of the mouse listening attribute, and elements containing value change js.
[0051] Here, it should be noted that each element in the node of the level i page obtained by parsing the page parsing rule of H5 includes the attributes of the node, wherein the number of attributes is M, and the attributes include: display size and boundary coordinates.
[0052] After obtaining the nodes of the i-level page and the attributes of the nodes of the i-level page, in an optional embodiment, determining whether the k-th node is a clickable element of the i-level page according to the attributes of the k-th node, updating k to k+1, and returning to execute obtaining the k-th node from the nodes of the i-level page may include:
[0053] Get the nth attribute of the kth node;
[0054] When n is less than M, and the display size of the nth attribute is within the screen size range of the terminal, and the boundary size of the nth attribute is within the boundary range of the terminal screen, the kth node is determined to be a clickable element of the i-level page, k is updated to k+1, and the execution returns to obtain the kth node from the nodes of the i-level page;
[0055] When n is less than M, the display size of the nth attribute exceeds the screen size of the terminal, and / or the boundary size of the nth attribute exceeds the range of the terminal screen, it is determined that the kth node is not a clickable element of the i-level page, n is updated to n+1, and the process returns to execute obtaining the nth attribute of the kth node;
[0056] When n is greater than or equal to M, k is updated to k+1, and the process returns to execute to obtain the kth node from the nodes of the i-level page.
[0057] Specifically, the Appium client first obtains the nth attribute of the kth node. In actual applications, the initial value of n is 0. Taking M as 3 as an example, the 0th attribute of the kth node is obtained first. Since 0 is less than 3, if the display size of the 0th attribute is within the screen size range of the terminal, and the border size of the 0th attribute is within the border range of the terminal screen, it is determined that the kth node is a clickable element of the i-level page, k is updated to k+1, and the execution returns to obtain the first node from the nodes of the i-level page. For example, the display size can be width W and height H, and the border size can be the border coordinates of the node. The width, height and border size are used to filter out nodes that have attributes but exceed the screen or are not displayed on the screen.
[0058] If the display size of the 0th attribute exceeds the screen size of the terminal, and the boundary size of the 0th attribute exceeds the boundary range of the terminal screen, it is determined that the kth node is not a clickable element of the i-level page, n is updated to n+1, and the next attribute is traversed until the second attribute is traversed and it is determined that the second attribute is not a clickable element of the i-level page, n is updated to n+1, at this time n is greater than or equal to M, k is updated to k+1, and the next node is traversed.
[0059] In this way, by analogy, all nodes are traversed and clickable elements of the i-level page are obtained through traversal for click testing.
[0060] S103: Perform a click test on the clickable elements of the i-level page to obtain the test result of the i-level page, update i to i+1, and return to execute and obtain the i-level page of the application;
[0061] Specifically, after obtaining the clickable elements of the i-level page through one or more of the above embodiments, a click test is performed on the clickable elements of the i-level page to obtain the test results of the i-level page, and then the page is traversed again, i is updated to i+1, and the next page is traversed.
[0062] In order to implement a click test on a clickable element of an i-level page to obtain a test result of the i-level page, in an optional embodiment, performing a click test on a clickable element of an i-level page to obtain a test result of the i-level page may include:
[0063] Get the jth clickable element from the clickable elements of the i-level page;
[0064] When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page. If it is determined that the current page of the application is not the i-level page, i is updated to i+1, and the execution returns to obtain the i-level page of the application.
[0065] When j is greater than or equal to the number of clickable elements on the i-level page, control the current page to jump to the i-1-level page;
[0066] When the i-1 level page is not the startup page of the application, i is updated to i-1, and the execution returns to obtain the i-level page of the application;
[0067] When the i-1 level page is a startup page, the test result of the i-level page is determined as the test result of the application program.
[0068] Specifically, the Appium client obtains the jth clickable element from the clickable elements of the i-level page, where the initial value of j is 0. Then, the Appium client obtains the 0th clickable element from the clickable elements of the i-level page. Taking the number of clickable elements of the i-level page as 3 as an example, 0 is less than 3. The Appium client clicks the 0th clickable element, and then checks whether the current page of the application is still the i-level page. If not, it means that the current page jumps, then i is updated to i+1, and then the next page is traversed.
[0069] When j=3, since j is greater than or equal to 3, that is to say, the clickable elements of the i-level page have been traversed, then the Appium client first controls the current page to jump to the previous level page, that is, jumps to the i-1 level page, and then determines whether the i-1 level page is the startup page of the application, that is, determines whether the i-1 level page is a level 0 page. If not, then update i to i-1 and continue to traverse the i-level page. If so, it means that all pages of the application have been completed. At this time, the test result of the i-level page is the test result of all pages, which determines the test result I give to the application.
[0070] In addition, for clickable elements, some clickable elements will cause page jumps when performing click tests, while some clickable elements will not cause page jumps when performing click tests. In an optional embodiment, the above method may further include:
[0071] When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page. When it is determined that the current page is an i-level page, j is updated to j+1, and the execution returns to obtain the j-th clickable element from the clickable elements of the current page.
[0072] Here, when traversing the clickable elements, when j is less than the clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page. Here, considering that no jump will occur when the clickable element is clicked, j is updated to j+1, and then the next clickable element is traversed.
[0073] S104: When i is greater than or equal to the maximum page depth of the application, the test result of the i-level page is determined as the test result of the application.
[0074] Specifically, when i is greater than or equal to the maximum page depth of the application, that is, when the Appium client has traversed all pages, the test result of the i-level page is determined as the test result of the application.
[0075] The following examples are used to illustrate the testing method described in one or more of the above embodiments.
[0076] Figure 2 A flow chart of an example 1 of an optional testing method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the above test method may include:
[0077] S201: Appium client initializes the environment, i.e. starts the application (App, Application);
[0078] Specifically, since the mainstream platforms for mobile applications are divided into Android and iOS (Internetworking Operating System-Cisco), although Appium is a cross-platform automated testing tool, the configuration and environment of the two ends are quite different. The initialization configuration is unified here according to the different ends, and the unified example object is the AppiumDriver object.
[0079] S202: Appium client starts the monitoring process to monitor fixed operations and blacklists;
[0080] The fixed operation mentioned above may be a login operation, such as inputting a user name and password, etc. The blacklist is a prohibited operation, such as the comment function of the App.
[0081] Specifically, the Appium client starts the listening program to listen to and block the fixed operation steps and blacklists: the fixed steps (fixStepAction) are stored in json, defining the operations that must be performed when performing traversal stability, for example, the login page performs the user name and password input operation: Example json such as:
[0082]
[0083]
[0084] For example, the above listening configuration activity means that only when the page is detected, if the following positioning elements (xpath) are found, the event operation (input, click, etc.) is performed. Throttle is the delay after the event is executed, in milliseconds. Blacklist similar operations are skipped directly. The listening will continue until the entire task is completed.
[0085] S203: Appium client searches for the current page handle (ContextHandles);
[0086] Here, it should be noted that after the App is started, the current page is a page with a depth level (Depth) of level 0 (equivalent to the above-mentioned level i page, i=0).
[0087] S204: The Appium client determines whether Depth is greater than or equal to the maximum depth level (maxDepth) (equivalent to the maximum page depth). If yes, execute S205; if no, execute S206;
[0088] S205: Return, end the test.
[0089] S206: The Appium client checks the handle type of the current page to determine whether the handle is Native or WebView. If it is Native, execute S207; if it is WebView, execute S212; if it is other, execute S216;
[0090] S207: Execute S208 for the Native handle;
[0091] S208: Appium client obtains the current page xml;
[0092] S209: The Appium client parses the XML into each node of the page;
[0093] S210: The Appium client parses the XML to obtain a node set (NodeList) of the page;
[0094] S211: The Appium client determines a clickable element from the node set;
[0095] The index value of each clickable element is represented by index. In order to determine the clickable element from the node set, in actual applications, for the Native handle, Figure 3 A flow chart of Example 2 of an optional testing method provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the method for determining a clickable element may include:
[0096] S301: For the Native handle, the Appium client obtains the page xml;
[0097] S302: Appium client converts UTF-8 to GBK;
[0098] S303: Appium client is converted to Document through DocumentBuilder;
[0099] S304: The Appium client converts to obtain the NodeList and the properties of each Node;
[0100] S305: The Appium client obtains the current node and determines whether the index of the current node is less than or equal to the total number m of nodes in the NodeList; if yes, execute S306; if no, end;
[0101] The index value of the node is represented by index, and the initial value of index is 0.
[0102] S306: The Appium client obtains the total number L of attributes of the current node;
[0103] S307: The Appium client determines whether the total number L of attributes of the current node is greater than 0; if yes, execute S308; if no, determine that the node is an invalid node, and obtain the next node;
[0104] S308: The Appium client obtains the nth attribute of the current node; wherein the initial value of n is 0;
[0105] S309: The Appium client determines whether L is greater than n. If so, execute S310, otherwise, end;
[0106] S310: Appium client obtains the attribute name Name, n++;
[0107] S311: The Appium client determines whether Name is equal to the location coordinate x or y of the current node; if yes, execute S312; if no, execute S314;
[0108] S312: The Appium client obtains the width W and height H of the terminal screen;
[0109] S313: The Appium client determines whether x is less than W and whether y is less than H. If both are yes, execute S314; otherwise, execute S308.
[0110] S314: The Appium client obtains the attribute as bounds value (startX, startY, endX, endY);
[0111] S315: The Appium client determines whether startX is greater than 0, and determines whether startY is greater than 0, and determines whether endX is greater than 0, and determines whether endY is greater than 0, and determines whether startX is less than W, and determines whether endX is less than W, and determines whether startY is less than H, and determines whether endY is less than H. If all are yes, execute S316, otherwise, execute S308;
[0112] S316: The Appium client adds the current node to the clickable element (equivalent to the final node set).
[0113] S212: Execute S213 for the WebView handle;
[0114] S213: Appium client SwitchTo to WebView handle;
[0115] S214: Appium client parses the page according to H5 page parsing rules;
[0116] Specifically, the Appium client parses the page according to the H5 page parsing rules, parses the elements of the page button tag, parses the elements of the page a tag, parses the elements of the page containing onclick event attributes, parses the elements of the page with mouse listening attributes, parses the elements of the page containing value change js, and obtains the attributes of each element;
[0117] S215: The Appium client determines a set of clickable elements from the parsed nodes according to S305-S316, and executes S211;
[0118] S216: For other handles, execute S217;
[0119] S217: Appium client SwitchTo to the corresponding handle;
[0120] S218: The Appium client parses the page according to the corresponding rules and executes S215;
[0121] S219: The Appium client obtains the index value index of the current clickable element and determines whether index is less than or equal to the number of clickable elements; if it is less than, execute S220; if it is greater than or equal to, execute S222;
[0122] S220: The Appium client clicks the current clickable element and executes S221;
[0123] S221: Appium client adds Depth++ and executes S203;
[0124] S222: The Appium client jumps to the previous page and executes S223;
[0125] S223: The Appium client determines whether the previous level page is a level 0 page; if yes, the process ends; if no, the process proceeds to S224;
[0126] S224: Appium client sets Depth-- and executes S203.
[0127] Figure 4 A schematic diagram of an example structure of an optional page depth provided in an embodiment of the present application, such as Figure 4 As shown, the page depth of the application can be represented by levels, for example, a total of 4 levels, including: pages at level 0 depth, pages at level 1 depth, pages at level 2 depth, and pages at level 3 depth, wherein, Figure 4 Pages with depth level 0 are not marked.
[0128] It should be noted that the page at the 0-level depth is usually the startup page of the application. When the above test method is used, the traversal order of the application's pages is generally:
[0129] A->a->1->2->3;
[0130] A->b->1->2->3;
[0131] A->c->1->2->3;
[0132] B->a->1->2->3;
[0133] B->b->1->2->3;
[0134] B->c->1->2->3;
[0135] C->a->1->2->3;
[0136] C->b->1->2->3;
[0137] C->c->1->2->3.
[0138] If the current depth is equal to the custom maximum page depth (maxDepth), return to the previous level page until the traversal is completed.
[0139] In addition, in actual applications, when traversing clickable elements, the click test is recorded and screenshots are stored in the jvm memory. If the page is found to have crash, anr, page loading failure, etc. during execution, the information recorded in the jvm memory is saved in the test report. If there is no exception, the information saved in the memory is cleared.
[0140] This example is suitable for products that are developed with a mix of common technologies such as Native, H5, and mini-programs on both Android and iOS. It does not require R&D or testers to write automated test scripts. Instead, they can simply configure the corresponding traversal rules. The solution's analysis and targeted traversal strategies can be more efficiently and quickly implemented in product applications, improving test efficiency and further ensuring product quality.
[0141] In this way, the above examples can be used to promptly discover application problems and trace them back, thereby improving the efficiency of automated testing.
[0142] The embodiment of the present application provides a testing method, in which the Appium client is connected to a terminal through an Appium server, and an application is installed on the terminal, including: obtaining an i-level page of the application, when i is less than the maximum page depth of the application, parsing the i-level page according to the type of the handle of the i-level page, obtaining clickable elements of the i-level page, performing a click test on the clickable elements of the i-level page, obtaining a test result of the i-level page, updating i to i+1, returning to execute to obtain the i-level page of the application, when i is greater than or equal to the maximum page depth of the application, determining the test result of the i-level page as the test result of the application, wherein i is the number of consecutive jumps required for the application's startup page to jump to the i-level page, and the maximum page depth of the application is the total number of pages of the application; that is, in the embodiment of the present application, by The pages are traversed at preset levels, and each level of the pages is parsed according to the type of the handle of each level of the pages to obtain the clickable elements of each level of the pages. In this way, the clickable elements of each level of the pages are tested for clicks. In this way, by traversing the pages of the application level by level and parsing the pages according to the handles, the pages can be parsed using corresponding parsing methods for different page handles. In this way, each page can be fully parsed. For applications that use multiple technologies, more functions of the application can be covered, which is conducive to the testing of applications that mix multiple technologies. Moreover, for different applications, it is only necessary to pre-set the maximum page depth of the application to achieve automated testing of any application, avoiding the manpower consumption brought by developers coding / maintaining scripts for different applications, thereby improving the testing efficiency of the application.
[0143] Embodiment 2
[0144] Figure 5 A schematic diagram of the structure of an Appium client provided in an embodiment of the present application Figure 1 ,like Figure 5 As shown, the Appium client is connected to the terminal through the Appium server, and an application is installed on the terminal, including: an acquisition module 51, a parsing module 52, a testing module 53 and a u determination module 54; wherein,
[0145] The acquisition module 51 is used to acquire the i-level page of the application; wherein i is the number of consecutive jumps required for the application startup page to jump to the i-level page;
[0146] The parsing module 52 is used to parse the i-level page according to the type of the handle of the i-level page to obtain the clickable elements of the i-level page when i is less than the maximum page depth of the application; wherein the maximum page depth of the application is the total number of pages of the application;
[0147] The testing module 53 is used to perform a click test on the clickable elements of the level i page, obtain the test result of the level i page, update i to i+1, and return to execute the acquisition module 51 to obtain the level i page of the application;
[0148] The determination module 54 is used to determine the test result of the i-level page as the test result of the application program when i is greater than or equal to the maximum page depth of the application program.
[0149] Optionally, the parsing module 52 parses the level i page according to the type of the handle of the level i page, and obtains the clickable elements of the level i page, including:
[0150] Parse the i-level page according to the type of the handle of the i-level page, and obtain the nodes of the i-level page and the attributes of the nodes of the i-level page;
[0151] Get the kth node from the nodes of the i-level page;
[0152] When k is less than the number of nodes in the i-level page, and the sum of the number of attributes of the k-th node is less than or equal to 0, k is updated to k+1, and the execution returns to obtain the k-th node from the nodes in the i-level page;
[0153] When k is less than the number of nodes of the i-level page, and the sum of the number of attributes of the k-th node is greater than 0, determine whether the k-th node is a clickable element of the i-level page based on the attributes of the k-th node, update k to k+1, and return to execute to obtain the k-th node from the nodes of the i-level page;
[0154] When k is greater than or equal to the number of nodes of the i-level page, the clickable elements of the i-level page are obtained.
[0155] Optionally, the parsing module 52 parses the level i page according to the type of the level i page handle, and obtains the level i page node and the level i page node attributes, including:
[0156] When the type of the handle of the level i page is Native, the level i page is format converted to obtain the node of the level i page;
[0157] The nodes of the i-level page are processed by DocumentBuilder to obtain M attributes of the nodes of the i-level page;
[0158] Among them, the properties include: display size and boundary coordinates.
[0159] Optionally, the parsing module 52 parses the level i page according to the type of the level i page handle, and obtains the level i page node and the level i page node attributes, including:
[0160] When the type of the handle of the level i page is WebView, the level i page is parsed according to the preset H5 page parsing rules to obtain the nodes of the level i page and the attributes of the nodes of the level i page;
[0161] The nodes of the i-level page include: elements of the button tag, elements of the a tag, elements containing onclick event attributes, elements of the mouse monitoring attribute, and elements containing value change js;
[0162] Among them, the properties include: display size and boundary coordinates.
[0163] Optionally, the parsing module 52 determines whether the kth node is a clickable element of the i-level page according to the attribute of the kth node, updates k to k+1, and returns to execute the acquisition module 51 to acquire the kth node from the nodes of the i-level page, including:
[0164] Get the nth attribute of the kth node;
[0165] When n is less than M, and the display size of the nth attribute is within the screen size range of the terminal, and the border size of the nth attribute is within the screen range of the terminal, the kth node is determined to be a clickable element of the i-level page, k is updated to k+1, and the execution returns to obtain the kth node from the nodes of the i-level page;
[0166] When n is less than M, the display size of the nth attribute exceeds the screen size of the terminal, and / or the boundary size of the nth attribute exceeds the range of the terminal screen, it is determined that the kth node is not a clickable element of the i-level page, n is updated to n+1, and the process returns to execute the acquisition of the nth group of attributes of the kth node;
[0167] When n is greater than or equal to M, k is updated to k+1, and the process returns to execute to obtain the kth node from the nodes of the i-level page.
[0168] Optionally, the testing module 53 is specifically used for:
[0169] Get the jth clickable element from the clickable elements of the i-level page;
[0170] When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page, and when it is determined that the current page of the application is not the i-level page, i is updated to i+1, and the process returns to the execution acquisition module 51 to acquire the i-level page of the application;
[0171] When j is greater than or equal to the number of clickable elements on the i-level page, control the current page to jump to the i-1-level page;
[0172] When the i-1 level page is not the startup page of the application, i is updated to i-1, and the process returns to the execution acquisition module 51 to acquire the i-level page of the application;
[0173] When the i-1 level page is a startup page, the test result of the i-level page is determined as the test result of the application program.
[0174] Optionally, the Appium client is used to:
[0175] When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page. When it is determined that the current page is an i-level page, j is updated to j+1, and the execution returns to obtain the j-th clickable element from the clickable elements of the current page.
[0176] In practical applications, the acquisition module 51, the parsing module 52, the testing module 53 and the determination module 54 can be implemented by a processor located on the Appium client, specifically a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA).
[0177] Figure 6 A schematic diagram of the structure of an Appium client provided in an embodiment of the present application Figure 2 ,like Figure 6As shown, an embodiment of the present application provides an Appium client 600, which is connected to a terminal through an Appium server, and an application is installed on the terminal, including:
[0178] A processor 61 and a storage medium 62 storing executable instructions of the processor 61, wherein the storage medium 62 relies on the processor 61 to perform operations through a communication bus 63, and when the instructions are executed by the processor 61, the test method described in the above embodiment 1 is executed.
[0179] It should be noted that in actual application, the various components in the terminal are coupled together through the communication bus 63. It is understandable that the communication bus 63 is used to realize the connection and communication between these components. In addition to the data bus, the communication bus 63 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as communication buses 63.
[0180] An embodiment of the present application provides a computer storage medium storing executable instructions. When the executable instructions are executed by one or more processors, the processors execute the test method described in the first embodiment.
[0181] Among them, the computer-readable storage medium can be a ferromagnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and other memories.
[0182] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0183] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0184] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0185] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0186] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A testing method, It is characterized in that The method is applied to an Appium client, wherein the Appium client is connected to a terminal through an Appium server, and an application is installed on the terminal, including: Obtaining the i-level page of the application; wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page; When i is less than the maximum page depth of the application, the i-level page is parsed according to the type of the handle of the i-level page to obtain the clickable elements of the i-level page; wherein the maximum page depth of the application is the total number of pages of the application; Perform a click test on the clickable elements of the i-level page to obtain the test result of the i-level page, update i to i+1, and return to execute the step of obtaining the i-level page of the application; When i is greater than or equal to the maximum page depth of the application, determining the test result of the i-level page as the test result of the application; Wherein, the parsing of the i-level page according to the type of the handle of the i-level page includes: parsing the i-level page according to the type of the handle of the i-level page to obtain the nodes of the i-level page and the attributes of the nodes of the i-level page; obtaining the k-th node from the nodes of the i-level page; when k is less than the number of nodes of the i-level page, and the sum of the number of attributes of the k-th node is less than or equal to 0, k is updated to k+1, and the acquisition of the k-th node from the nodes of the i-level page is returned to execute; when k is less than the number of nodes of the i-level page, and the sum of the number of attributes of the k-th node is greater than 0, determining whether the k-th node is a clickable element of the i-level page according to the attributes of the k-th node, k is updated to k+1, and the acquisition of the k-th node from the nodes of the i-level page is returned to execute; when k is greater than or equal to the number of nodes of the i-level page, the clickable element of the i-level page is obtained; The attributes include: display size and boundary coordinates; the parsing of the i-level page according to the type of the handle of the i-level page to obtain the nodes of the i-level page and the attributes of the nodes of the i-level page include: When the type of the handle of the level i page is Native, the level i page is format converted to obtain the node of the level i page; the node of the level i page is processed by DocumentBuilder to obtain M attributes of the node of the level i page; When the type of the handle of the i-level page is WebView, the i-level page is parsed according to the preset H5 page parsing rules to obtain the nodes of the i-level page and the attributes of the nodes of the i-level page; wherein the nodes of the i-level page include: elements of the button tag, elements of the a tag, elements containing onclick event attributes, elements of the mouse listening attribute and elements containing value change js.
2. The method according to claim 1, It is characterized in that Determining whether the kth node is a clickable element of the i-level page according to the attribute of the kth node, updating k to k+1, and returning to execute obtaining the kth node from the nodes of the i-level page, including: obtaining the nth attribute of the kth node; When n is less than M, and the display size of the nth attribute is within the screen size range of the terminal, and the boundary size of the nth attribute is within the screen range of the terminal, it is determined that the kth node is a clickable element of the i-level page, k is updated to k+1, and the process returns to obtain the kth node from the nodes of the i-level page; When n is less than M, the display size of the nth attribute exceeds the screen size of the terminal, and / or the boundary size of the nth attribute exceeds the range of the screen of the terminal, it is determined that the kth node is not a clickable element of the i-level page, n is updated to n+1, and the process of obtaining the nth group of attributes of the kth node is returned; When n is greater than or equal to M, k is updated to k+1, and the process returns to execute obtaining the kth node from the nodes of the i-level page.
3. The method according to claim 1, It is characterized in that The step of performing a click test on the clickable elements of the level i page to obtain a test result of the level i page includes: Get the jth clickable element from the clickable elements of the i-level page; When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page, and when it is determined that the current page of the application is not the i-level page, i is updated to i+1, and the process returns to execute the step of obtaining the i-level page of the application; When j is greater than or equal to the number of clickable elements of the i-level page, control the current page to jump to the i-1-level page; When the i-1 level page is not the startup page of the application, i is updated to i-1, and the process returns to execute the step of obtaining the i-level page of the application; When the i-1 level page is the startup page, the test result of the i-level page is determined as the test result of the application.
4. The method according to claim 3, It is characterized in that The method further comprises: When j is less than the number of clickable elements of the i-level page, a click test is performed on the j-th clickable element of the i-level page, and when it is determined that the current page is the i-level page, j is updated to j+1, and the process returns to execute the process of obtaining the j-th clickable element from the clickable elements of the current page.
5. An Appium client, It is characterized in that The Appium client is connected to the terminal through the Appium server, and the terminal is installed with an application program, including: An acquisition module, used to acquire the i-level page of the application; wherein i is the number of consecutive jumps required for the startup page of the application to jump to the i-level page; A parsing module, for parsing the i-level page according to the type of the handle of the i-level page to obtain clickable elements of the i-level page when i is less than the maximum page depth of the application; wherein the maximum page depth of the application is the total number of pages of the application; wherein the parsing module parses the i-level page according to the type of the handle of the i-level page, including: parsing the i-level page according to the type of the handle of the i-level page to obtain the nodes of the i-level page and the attributes of the nodes of the i-level page; obtaining the kth node from the nodes of the i-level page; when k is less than the i-level page When the number of nodes on the i-level page is less than or equal to 0, and the sum of the number of attributes of the k-th node is less than or equal to 0, k is updated to k+1, and the process of obtaining the k-th node from the nodes of the i-level page is returned; when k is less than the number of nodes on the i-level page, and the sum of the number of attributes of the k-th node is greater than 0, whether the k-th node is a clickable element of the i-level page is determined according to the attribute of the k-th node, k is updated to k+1, and the process of obtaining the k-th node from the nodes of the i-level page is returned; when k is greater than or equal to the number of nodes on the i-level page, the clickable element of the i-level page is obtained; The attributes include: display size and boundary coordinates; the parsing module parses the i-level page according to the type of the handle of the i-level page, and obtains the nodes of the i-level page and the attributes of the nodes of the i-level page, including: When the type of the handle of the level i page is Native, the level i page is format converted to obtain the node of the level i page; the node of the level i page is processed by DocumentBuilder to obtain M attributes of the node of the level i page; When the type of the handle of the i-level page is WebView, the i-level page is parsed according to the preset H5 page parsing rules to obtain the nodes of the i-level page and the attributes of the nodes of the i-level page; wherein the nodes of the i-level page include: elements of the button tag, elements of the a tag, elements containing onclick event attributes, elements of the mouse monitoring attributes and elements containing value change js; A testing module, used for performing a click test on the clickable elements of the i-level page, obtaining the test result of the i-level page, updating i to i+1, and returning to execute the acquisition module to acquire the i-level page of the application; The determination module is used to determine the test result of the i-level page as the test result of the application when i is greater than or equal to the maximum page depth of the application.
6. An Appium client, It is characterized in that The Appium client is connected to the terminal through the Appium server, and an application is installed on the terminal. The Appium client includes: a processor and a storage medium storing instructions executable by the processor, and the storage medium relies on the processor to perform operations through a communication bus. When the instructions are executed by the processor, the test method described in any one of claims 1 to 4 is executed.
7. A computer storage medium, It is characterized in that Executable instructions are stored, and when the executable instructions are executed by one or more processors, the processors execute the test method described in any one of claims 1 to 4.
Citation Information
Patent Citations
A tree traversal-based terminal APP coverage test method and device
CN109710506A