Automatic testing method and system, readable medium and electronic equipment
By detecting and converting controls for non-native applications, the problem that automated testing methods cannot identify non-native controls is solved, the test speed and coverage are improved, and automated testing of non-native application interfaces is realized.
Patent Information
- Application Number
- CN202310724952.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2024-12-17
AI Technical Summary
The existing automated testing methods cannot recognize controls that are not native to the application, resulting in the inability to perform automated testing, which reduces the test speed and page coverage.
By detecting the text information and location information of the non-native type control of the application to be tested, converting it into a native type control, and testing it according to the test rules of the native type.
It improves test speed and page coverage, avoids switching of test rules, and realizes automated testing of non-native application interfaces.
Smart Images

Figure CN119149380A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an automated testing method, system, readable medium and electronic device. Background Art
[0002] Each time an application is optimized and released online, the controls in the application interface must be tested to determine whether the function of each control is available, such as whether clicking a control can jump to a new application interface. Taking mobile phones as an example, the testing of mobile applications includes: manual testing methods and automated testing methods using automated testing technologies (such as uiautomator, appium, etc.).
[0003] However, when existing automated testing methods identify controls on the application interface to be tested, they can usually only identify controls of native applications (native APPs), and cannot identify controls of non-native applications, such as hybrid applications (hybrid APPs). As a result, it is impossible to continue automated testing of the application interface to be tested, which reduces the test speed and results in low page coverage within the test time. Summary of the invention
[0004] The purpose of the present application is to provide an automated testing method, system, readable medium and electronic device.
[0005] The first aspect of the present application provides an automated testing method, including: detecting a first control in a first interface of an application to be tested, and obtaining text information and position information of the first control; wherein the attribute of the first control is of a first type; based on the text information and position information of the first control, converting the first control into a second control; wherein the attribute of the second control is of a second type; and testing the second control according to a test rule of the second type.
[0006] That is, in an embodiment of the present application, the first interface here refers to the current interface to be tested of the application to be tested, the first control refers to a non-native type control, the first type refers to a non-native type, the second control refers to a native type control, and the second type refers to a native type. A control of a non-native type (such as an H5 type, a flutter type, etc.) is detected in the current interface to be tested of the application to be tested, and the text information and position information of the non-native type control are obtained. Then, based on the text information and position information of the non-native type control, the non-native type control is converted to a native type (such as a native type) control. Finally, the native type control in the current interface to be tested is tested according to the test rules of the native type.
[0007] The automated testing method provided in the embodiment of the present application can improve the testing speed and further improve the page coverage within the testing time by obtaining the text information and position information of non-native type controls, converting the non-native type controls into native types, and testing the converted controls according to the testing rules of the native types; and further, only the native type detection rules need to be used to test the controls in the application to be tested, without the need to switch the testing rules.
[0008] In a possible implementation of the first aspect above, obtaining text information and location information of the first control includes: taking a screenshot of the first interface to obtain a first image; and performing text recognition on the first image to obtain text information and location information of the first control.
[0009] That is, in the embodiment of the present application, the first picture here refers to the captured picture. Corresponding to the current interface being of a non-native type, or the type of a control in the current interface being of a non-native type, a screenshot of the current interface is saved, and a text recognition result (text information and position information) of the current interface is obtained through text recognition technology, such as optical character recognition (OCR).
[0010] In a possible implementation of the first aspect above, a screenshot operation is performed on the first interface to obtain a first image, including at least one of the following: capturing a display area of the first interface as the first image; capturing a display area of the first control as the first image.
[0011] That is, in the embodiment of the present application, the screenshot operation on the current interface may be to capture the display area of the current interface, and the screenshot operation on the current interface may also be to capture the display area of the non-native type of controls in the current interface.
[0012] In a possible implementation of the first aspect above, based on the text information and position information of the first control, the first control is converted into a second control, including: encapsulating the text information and position information of the first control into an encapsulation object; setting the properties of the encapsulation object to the second type; and adding the encapsulation object to the first type of control of the first interface.
[0013] That is, in the embodiment of the present application, the encapsulated object here refers to the object corresponding to the native type. The text information and position information of each non-native type control in the current interface are encapsulated into an object corresponding to the native type, and then the encapsulated object is added to the access object of the current interface, and the property of the encapsulated object is set to the native type, such as the clickable type (CLICK_EDIT_CHECK).
[0014] In a possible implementation of the first aspect above, the method also includes: detecting that the attribute of the first interface of the application to be tested is of the first type, obtaining the text information and position information of each third control in the first interface; converting the third control into a second control based on the text information and position information of the third control; and testing the third control according to the test rules of the second type.
[0015] That is, in the embodiment of the present application, the third control here refers to a non-native type control. If the current interface to be tested is a non-native type, the text information and position information of the non-native type control in the current interface to be tested are obtained, and the non-native type control in the current interface to be tested is converted into a native type control. Then, the control of the current interface to be tested is tested according to the preset test rules.
[0016] In a possible implementation of the first aspect above, detecting that the attribute of the first interface of the application to be tested is of the first type includes: obtaining position information of each third control in the first interface; and determining that the attribute of the first interface is of the first type when the position information of each third control does not exceed the area threshold.
[0017] That is, in the embodiment of the present application, the uiaotomator tool is used to obtain all clickable nodes and their position information in the current interface. If the position information of all clickable nodes in the current interface does not exceed the area threshold, it is determined that the interface attribute of the current interface is a non-native type.
[0018] In a possible implementation of the first aspect above, the second type of test rules include at least one of the following: after completing the test of the second control and the associated interface of the second control, testing the fourth control in the first interface; after completing the test of the controls in the first interface, testing the controls in the second interface; wherein the test of the controls in the first interface includes: testing all controls in the first interface, or selecting controls in the first interface for testing according to preset rules.
[0019] That is, in the embodiment of the present application, the fourth control here refers to another control in the first interface, the second interface refers to the associated application interface of the control in the first interface, and the preset rule refers to the selection method of the control to be tested. The test rule of the native type can be a depth-first rule, that is, after completing the test of a certain control in the application interface of the application to be tested and all controls in its associated application interface, another control and all controls in its associated application interface are tested. The test rule of the native type can also be a breadth-first rule, that is, after completing the test of all controls in the application interface of the application to be tested, all controls in the associated application interface of the control in the application interface are tested. All controls in the interface to be tested can be tested (clicked or accessed). In other embodiments, some controls in the interface to be tested can be tested, for example, according to a 60% probability, a given step size is taken to select the control to be tested, and a 40% probability randomly selects the control to be tested.
[0020] In a possible implementation of the first aspect above, the automated testing method is performed using at least one of the following testing tools: uiautomator, appium, selenium, katalon studio, soapui.
[0021] The second aspect of the present application provides an automated testing system, characterized in that it includes: a control determination module, used to detect a first control in a first interface of an application to be tested, and obtain text information and position information of the first control; based on the text information and position information of the first control, convert the first control into a second control; wherein the attribute of the first control is of the first type, and the attribute of the second control is of the second type; and a testing module, used to test the second control according to the test rules of the second type.
[0022] A third aspect of the present application provides a readable medium on which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes any one of the methods in the first aspect.
[0023] The fourth aspect of the present application provides an electronic device, comprising a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the processors of the electronic device, for executing any one of the methods in the above-mentioned first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 A schematic diagram of a user interface of a shopping application is shown according to an embodiment of the present application;
[0026] Figures 2a to 2i According to an embodiment of the present application, a schematic diagram of application interface changes during automated testing of a mobile shopping application is shown;
[0027] Figures 3a to 3j According to an embodiment of the present application, another schematic diagram of application interface changes during automated testing of a mobile shopping application is shown;
[0028] Figure 4 According to an embodiment of the present application, a schematic flow chart of an automated testing method is shown;
[0029] Figure 5 A schematic diagram of a regional threshold is shown according to an embodiment of the present application;
[0030] Figure 6a According to an embodiment of the present application, a schematic diagram of a result of image capture is shown;
[0031] Figure 6b According to an embodiment of the present application, a schematic diagram of another result of image capture is shown;
[0032] Figure 7 According to an embodiment of the present application, a structural schematic diagram of an automated testing system is shown;
[0033] Figure 8 According to an embodiment of the present application, a structural schematic diagram of an electronic device is shown. DETAILED DESCRIPTION
[0034] Illustrative embodiments of the present application include, but are not limited to, an automated testing method, system, readable medium, and electronic device.
[0035] The following is a detailed description of the embodiments of the present application using an application in a mobile phone as an example.
[0036] As mentioned above, when the automated testing method identifies controls on the application interface to be tested, it can usually only identify native controls and cannot identify non-native controls, which in turn makes it impossible to continue automated testing of the application interface to be tested, reduces the testing speed, and results in low page coverage within the testing time.
[0037] Figure 1 A schematic diagram showing a user interface of a shopping application.
[0038] like Figure 1 As shown, the user interface 10 of the shopping application of the mobile phone 100 displays a navigation bar area 101, which includes navigation controls such as "Home" and "My"; and a display area 102 corresponding to the "Home" navigation control in the navigation bar area 101, and the display area 102 includes multiple controls, such as product category controls "Recommendations", "Food", "Wine and Beverages", etc.
[0039] Figures 2a to 2i A schematic diagram showing a group of application interface changes during automated testing of a mobile shopping application.
[0040] For example, in step N of the automated test, in response to a triggering event of a red envelope pop-up window, such as opening a shopping application or clicking a “get coupon” control, the mobile phone 100 displays the following: Figure 2a The application interface 20a shown in FIG. 20a includes a shopping application interface 201 at the lower layer and a red envelope pop-up window interface 202 at the upper layer. The red envelope pop-up window interface 202 includes controls such as an "open" control 2021 and an "×" control 2022. It can be understood that the shopping application interface 201 and the red envelope pop-up window interface 202 are similar. Figure 1 The user interface 10 of the shopping application is shown to be consistent.
[0041] Figure 2b The interface 20b of the mobile phone 100 corresponding to the N+1 step of the automated test is shown. Figure 2c The interface 20c of the mobile phone 100 corresponding to the N+2 step of the automated test is shown. Figure 2d The interface 20d of the mobile phone 100 corresponding to the N+3 step of the automated test is shown. It can be understood that the interfaces 20b, 20c and 20d are exactly the same as the interface 20a. That is, the automated test cannot recognize the controls in the upper layer red envelope pop-up interface 202, such as the "open" control 2021, the "×" control 2022 and other controls, resulting in the interface of the mobile phone 100 corresponding to the Nth step to the N+3th step of the automated test always staying at the interface 20a.
[0042] In step N+4 of the automated test, in response to a triggering event of the welfare pop-up window, such as opening a shopping application or displaying a red envelope pop-up window k seconds later, the mobile phone 100 displays the following Figure 2eThe application interface 20e shown in FIG. 20e includes a shopping application interface 201 at the lower layer, a red envelope pop-up window interface 202 at the middle layer, and a welfare pop-up window interface 203 at the upper layer. Among them, the welfare pop-up window interface 203 includes a "give up discount" control 2031, a "get it now" control 2032, etc. It can be understood that the shopping application interface 201 and the red envelope pop-up window interface 202 are similar. Figure 2a The shopping application interface 201 shown is consistent with the red envelope pop-up interface 202. Figure 2a The red envelope pop-up interface 202 shown is consistent.
[0043] Since the controls in the welfare pop-up window interface 203, such as the "Abandon Discount" control 2031 and the "Get Immediately" control 2032, cannot be identified during the automated testing process, the welfare pop-up window interface 203 cannot be closed or jumped to the next interface. Until the automated testing is completed, the interface of the mobile phone 100 always stays at the interface 20e.
[0044] For example, Figure 2f to Figure 2i A schematic diagram showing the interface changes for the last 4 steps of automated testing.
[0045] Figure 2f The interface 20f of the mobile phone 100 corresponding to the M-3 step of the automated test is shown. Figure 2g The interface 20g of the mobile phone 100 corresponding to the M-2 step of the automated test is shown. Figure 2h The interface 20h of the mobile phone 100 corresponding to the M-1 step of the automated test is shown. Figure 2i The interface 20i of the mobile phone 100 corresponding to the Mth step (the last step) of the automated test is shown. It can be understood that the interfaces 20f, 20g, 20h and 20i are exactly the same as the interface 20e. That is, the automated test cannot recognize the controls of the upper welfare pop-up interface 203, such as the "abandon discount" control 2031, the "get it now" control 2032, etc., resulting in the interface of the mobile phone 100 corresponding to the N+4th step to the Mth step of the automated test always staying at the interface 20e.
[0046] It is understandable that since the controls in the non-native red envelope pop-up interface 202 and the welfare pop-up interface 203 cannot be identified during the automated testing process, the interface of the mobile phone 100 remains on the non-native application interface red envelope pop-up interface 202 or the welfare pop-up interface 203 during the automated testing process, and the controls in the native application interface shopping application interface 201 cannot be tested, which reduces the testing speed and results in a low page coverage rate within the testing time.
[0047] In view of this, an embodiment of the present application provides an automated testing method, which includes: detecting a non-native type (such as H5 type, flutter type, etc.) control in the current interface to be tested of the application to be tested, and obtaining the text information and location information of the non-native type control. Then, based on the text information and location information of the non-native type control, the non-native type control is converted into a native type (such as native type) control. Finally, the native type control in the current interface to be tested is tested according to the test rules of the native type.
[0048] For example, in some embodiments, the method specifically includes: first, determining the properties of the current interface to be tested of the application to be tested. Secondly, if the current interface to be tested is of a non-native type, taking a screenshot of the current interface to be tested, and performing text recognition, obtaining the text information and position information of the non-native type controls in the current interface to be tested, and converting the non-native type controls in the current interface to be tested into native type controls. Then, testing the controls of the current interface to be tested according to preset test rules. If the current interface to be tested is of a native type, obtaining all controls of the interface to be tested, and testing the controls of the current interface to be tested according to the test rules of the native type.
[0049] Or for example, in some other embodiments, the method specifically includes: first, determining the properties of the controls in the current interface to be tested. Second, after detecting the non-native type controls in the current interface to be tested, taking a screenshot of the area where the non-native type controls are located, and performing text recognition, obtaining the text information and position information of the non-native type controls, and converting the non-native type controls into native type controls. Then, the controls of the current interface to be tested are tested according to the native type test rules.
[0050] For example, Figure 2a Taking the interface 20a shown as an example, it is detected that the interface attribute of the red envelope pop-up window interface 202 is a non-native type; the red envelope pop-up window interface 202 is screenshotted and text recognition is performed to obtain the text information and position information of the controls in the red envelope pop-up window interface 202, such as text information such as "open" and "×" and their corresponding position information; the controls in the red envelope pop-up window interface 202 are converted to native types. Finally, the controls in the red envelope pop-up window interface 202 are tested according to the test rules of the native type.
[0051] It can be understood that in some embodiments, the native type of test rules can be depth-first rules, that is, after completing the testing of a certain control in the application interface of the application to be tested and all controls in its associated application interface, another control and all controls in its associated application interface are tested.
[0052] In other embodiments, the native type test rule may also be a breadth-first rule, that is, after completing the test of all controls in the application interface of the application to be tested, all controls in the application interface associated with the controls in the application interface are tested. This application does not specifically limit the test rules.
[0053] It can be understood that the automated testing method provided in the embodiment of the present application can improve the testing speed and thereby improve the page coverage within the testing time by obtaining the text information and position information of non-native type controls, converting the non-native type controls into native types, and testing the converted controls according to the native type testing rules; and, it is only necessary to test the controls in the application to be tested using the native type detection rules, without the need to switch the testing rules.
[0054] It can be understood that in other embodiments, the above-mentioned automated testing method can also be: after converting the native type controls in the test interface of the application to be tested into non-native types, the non-native type controls in the test interface are tested according to the testing rules of the non-native types.
[0055] For example, Figures 3a to 3j A set of schematic diagrams showing changes in the application interface during the process of testing a mobile shopping application using the automated testing method provided in an embodiment of the present application are shown.
[0056] In the nth step of the automated test, in response to a triggering event of the red envelope pop-up window, such as opening a shopping application or clicking a “get coupon” control, the mobile phone 100 displays the following Figure 3a The application interface 30a shown in FIG. 30a includes a shopping application interface 301 at the lower layer and a red envelope pop-up window interface 302 at the upper layer. The red envelope pop-up window interface 302 includes controls such as an “×” control 3021. It can be understood that the interface 30a and Figure 2a The interface 20a shown is consistent.
[0057] like Figure 3a As shown, click the "×" control 3021. In response to the click operation, the mobile phone 100 displays the following Figure 3bInterface 30b of step n+1 of the automated test shown. It can be understood that although the attribute of the "×" control 3021 in the red envelope pop-up interface 302 is a non-native type, after the attribute of the "×" control 3021 is converted to a native type through the automated testing method provided in the embodiment of the present application, the "×" control 3021 can be recognized by the testing tool. In response to the operation of clicking the "×" control 3021, the mobile phone 100 exits the red envelope pop-up interface 302 and displays interface 30b. The interface 30b includes a shopping application interface 301 and a location selection prompt area 303. Among them, the location selection prompt area 303 includes text information such as "I don't know where you are yet" and controls such as the "×" control 3031. The shopping application interface 301 and Figure 1 The shopping application user interface 10 is shown to be consistent. It can be understood that the properties of the controls in the interface 30b are of native type and can be recognized by the testing tool.
[0058] like Figure 3b As shown, click the "×" control 3031. In response to the click operation, the mobile phone 100 displays the following Figure 3c The interface 30c of the step n+2 of the automated test shown in the figure. The interface 30c includes a navigation bar area 304, which includes main navigation controls such as "Home" and "My", and a display area 3041 corresponding to the "Home" main navigation control in the navigation bar area 304, and the display area 3041 includes a "Home" paging navigation control 3042, a "Search" control 3043, and controls such as "Recommendations", "Food", "Wine and Beverages" and other product category controls. It can be understood that the properties of the controls in the interface 30c are native types and can be recognized by the test tool.
[0059] like Figure 3c As shown, click the "Home" page navigation control 3042. In response to the click operation, the mobile phone 100 displays the following Figure 3d The interface 30d of the step n+3 of the automated test shown in FIG. Figure 3b The properties of the controls in the interface 30d are of native type and can be recognized by the test tool.
[0060] like Figure 3d As shown, click the "Search" control 3043. In response to the click operation, the mobile phone 100 displays the following Figure 3eThe interface 30e of step n+4 of the automated test shown in the figure. The interface 30e includes a "search" control 3051, a search recommendation area 305, and an input method interface 3052. It can be understood that although the properties of the controls in the input method interface 3052 (such as buttons for various numbers or symbols) are non-native types, after the properties of the controls in the input method interface 3052 are converted to native types through the automated testing method provided in the embodiment of the present application, the controls in the input method interface 3052 can be recognized by the testing tool.
[0061] In the mth step of the automated test, in response to a triggering event of the welfare pop-up window, such as opening a shopping application or displaying a red envelope pop-up window k seconds later, the mobile phone 100 displays the following Figure 3f The application interface 30f shown in FIG. 30f includes a shopping application interface 301 at the lower layer and a welfare pop-up window interface 306 at the upper layer. The welfare pop-up window interface 306 includes text information such as "0 yuan to recharge phone bills" and controls such as an "×" control 3061. It can be understood that the shopping application interface 301 and the welfare pop-up window interface 306 are similar. Figure 3a The shopping application interface 301 shown is consistent.
[0062] Figure 3g The interface 30g of the mobile phone 100 corresponding to the step (m+1) of the automated test is shown, and the interface 30g is consistent with the interface 30f. Figure 3g As shown, click the "×" control 3061. In response to the click operation, the mobile phone 100 displays the following Figure 3h The interface 30h of the m+2th step of the automated test is shown.
[0063] It can be understood that although the attribute of the "×" control 3061 in the welfare pop-up interface 306 is a non-native type, after the attribute of the "×" control 3061 is converted to a native type through the automated testing method provided in the embodiment of the present application, the "×" control 3061 can be recognized by the testing tool. In response to the operation of clicking the "×" control 3061, the mobile phone 100 exits the welfare pop-up interface 306 and displays the interface 30h. Figure 3h As shown, the interface 30h includes controls such as a "recommendation" control 3015. It can be understood that the properties of the controls in the interface 30h are of native type and can be recognized by the test tool.
[0064] like Figure 3h As shown, click the "Recommendation" control 3015. In response to the click operation, the mobile phone 100 displays Figure 3i The interface 30i of the step m+3 of the automated test shown in FIG. Figure 3i As shown, the interface 30i includes controls such as a "supermarket" control 3016. It can be understood that the properties of the controls in the interface 30i are of native type and can be recognized by the test tool.
[0065] like Figure 3i As shown, click the "Supermarket" control 3016. In response to the click operation, the mobile phone 100 displays the following Figure 3j The interface 30j of the step m+4 of the automated test is shown. It can be understood that the interface 30j is the associated application interface of the "supermarket" control 3016. The properties of the controls in the interface 30j are native types and can be recognized by the test tool. In the subsequent automated test process, the controls in the interface 30j can be tested to continue the automated test of the shopping application.
[0066] It can be understood that during the above-mentioned automated testing process, the controls in the non-native red envelope pop-up interface 302 and the welfare pop-up interface 306 are identified through the method provided in the embodiment of the present application, the controls in the red envelope pop-up interface 302 and the welfare pop-up interface 306 are tested, and the controls in the native application interface shopping application interface 301 are continued to be tested, thereby improving the page coverage within the testing time.
[0067] It is understood that the automated testing method provided in the embodiments of the present application can be applied to applications of electronic devices such as smart large screens, tablet computers, laptops, netbooks, personal digital assistants (PDAs), etc. The operating environment of the application includes but is not limited to Or other operating systems.
[0068] To facilitate understanding of the technical solution of the embodiment of the present application, the automated testing method provided in the embodiment of the present application is introduced below in conjunction with the accompanying drawings.
[0069] Figure 4 According to an embodiment of the present application, a schematic diagram of a process of an automated testing method is shown. It can be understood that Figure 4 The execution subject of each step of the process shown is the electronic device 1000. Figure 4 The execution entities of each step will not be described repeatedly in the steps of the process shown.
[0070] like Figure 4 As shown, the process includes but is not limited to the following steps:
[0071] S401: Entering a test interface of a test application.
[0072] In some embodiments, in response to an instruction to start an automated test, the default interface of the application to be tested is entered. Figure 1 A user interface 10 of a shopping application of a mobile phone 100 is shown.
[0073] In other embodiments, in response to a jump instruction in the automated test process, the interface of the application program to be tested corresponding to the jump instruction is entered. Figures 3a to 3j The application interface of the shopping application of the mobile phone 100 during the automated testing process is shown.
[0074] It is understood that the interface to be tested can be any interface displayed by the application to be tested during the test process. Figure 3a The red envelope pop-up interface 302 shown is an example of the interface to be tested to introduce the automated testing method provided in the embodiment of the present application.
[0075] S402: Determine the interface attributes of the current interface.
[0076] In some embodiments, after entering the interface to be tested of the application to be tested, the interface attributes of the current interface are determined.
[0077] In some embodiments, the determination method may be: using the uiaotomator tool to obtain all clickable nodes and their position information in the current interface. If the position information of all clickable nodes in the current interface does not exceed the area threshold, it is determined that the interface attribute of the current interface is a non-native type.
[0078] For example, refer to Figure 5 The schematic diagram of the area threshold is shown, with the horizontal axis being x and the vertical axis being y. If the area threshold of the location information of all clickable nodes in the application interface 50 of the mobile phone 100 is area A, that is, the area with a vertical axis range of 0 to 300.
[0079] In other embodiments, after entering the interface to be tested of the application to be tested, all controls in the current interface are obtained, and the properties of each control in the current interface are determined.
[0080] In some embodiments, if the judgment result is that the interface attribute of the current interface is a non-native type, step S403 is executed to take a screenshot of the current interface and perform text recognition to obtain text information and position information of the non-native type control.
[0081] In other embodiments, if the judgment result is that the interface attribute of the current interface is of a native type, step S405 is executed to obtain and analyze all controls of the current interface.
[0082] S403: Taking a screenshot of the current interface and performing text recognition to obtain text information and position information of non-native type controls.
[0083] In some embodiments, if the attribute corresponding to the current interface is of a non-native type, or the attribute of a control in the current interface is of a non-native type, a screenshot of the current interface is taken and saved, and the text recognition result (text information and location information) of the captured image is obtained through text recognition technology, such as optical character recognition (OCR).
[0084] For example, taking OCR technology as an example, firstly, the captured image is preprocessed, such as image enhancement. Then, the preprocessed image is subjected to text detection, for example, each text box in the image and the location of the text box are detected by using layout analysis technology, text line detection technology, etc. Then, the text recognition is performed on each text box in the image to obtain the corresponding text information.
[0085] It is understood that in some embodiments, the screenshot operation of the current interface may be to capture the display area of the current interface. Figure 3a The display area of the red envelope pop-up window interface 302 shown in FIG. Figure 6a As shown in the picture, area 60a is the entire interface of the red envelope pop-up interface 302.
[0086] In other embodiments, the screenshot operation of the current interface may also be to capture the display area of the non-native type of controls in the current interface. Figure 3a The display area of the "×" control 3021 in the red envelope pop-up interface 302 shown in FIG. Figure 6b In the picture shown, area 60b is a part of the red envelope pop-up interface 302, that is, the display area of the non-native type of control. This application does not limit this.
[0087] S404: Convert the non-native type control into a native type control.
[0088] In some embodiments, non-native type controls in the current interface are converted to native type controls to achieve compatibility between native type and non-native type frameworks.
[0089] In some embodiments, the conversion method may be: encapsulating the acquired text information and position information of each non-native type control in the current interface into an object corresponding to the native type, and then adding the encapsulated object to the access object of the current interface, and setting the properties of the encapsulated object to the native type, such as a clickable type (CLICK_EDIT_CHECK).
[0090] S405: Acquire and analyze all controls on the current interface.
[0091] In some embodiments, if the attribute corresponding to the current interface is of a native type, all controls of the current interface are acquired and analyzed.
[0092] In some embodiments, the uiaotomator tool is used to obtain all clickable nodes (native type controls) in the current interface.
[0093] It can be understood that all clickable nodes in the current interface are input data of the traversal algorithm. During the automated testing process, these clickable nodes will be visited, and the clickable nodes that have been clicked or visited will be marked to avoid repeated visits to the same clickable node.
[0094] S406: Testing the controls of the interface to be tested according to preset testing rules.
[0095] In some embodiments, the controls of the test interface are automatically tested according to native type test rules.
[0096] In some embodiments, the native type of test rules may be depth-first rules, that is, after completing the testing of a certain control in the application interface of the application to be tested and all controls in its associated application interface, another control and all controls in its associated application interface are tested.
[0097] In other embodiments, the native type test rule may also be a breadth-first rule, that is, after completing the test of all controls in the application interface of the application to be tested, all controls in the application interface associated with the controls in the application interface are tested. This application does not specifically limit the test rules.
[0098] It is understood that in some embodiments, all controls in the interface to be tested may be tested (clicked or accessed). In other embodiments, some controls in the interface to be tested may be tested, for example, the control to be tested may be selected with a given step length with a probability of 60%, and the control to be tested may be randomly selected with a probability of 40%. The present application does not specifically limit the test method of the control and the selection method of the control to be tested.
[0099] It can be understood that the above embodiments only take the interface to be tested as a non-native type interface as an example to introduce the automated testing method provided by the embodiments of the present application. In other embodiments, if the interface to be tested is a native type interface, the native type controls in the interface to be tested can also be converted to non-native types, and then the non-native type controls in the interface to be tested can be tested according to the testing rules of the non-native type.
[0100] It can be understood that in other embodiments, according to actual needs, the above Figure 4The steps shown can be combined, deleted or replaced with other steps that are conducive to achieving the purpose of this application. For example, the above steps S403 and S404 can be combined into one step, and this application does not limit this.
[0101] It can be understood that the above embodiment only takes the method using the uiautomator tool as an example to introduce the automated testing method provided by the embodiment of the present application. In other embodiments, tools such as appium, selenium, katalon studio, soapui, etc. can also be used.
[0102] It is understood that the above embodiment only takes the application to be tested on the mobile phone 100 as an example to introduce the automated testing method provided by the embodiment of the present application. In other embodiments, the application to be tested may also be an application applied to electronic devices such as smart large screens, tablet computers, laptops, netbooks, PDAs, etc. The operating environment of the application includes but is not limited to Or other operating systems.
[0103] To summarize, the automated testing method provided in the embodiment of the present application can improve the testing speed and thereby improve the page coverage within the testing time by acquiring the text information and location information of non-native type controls, converting the non-native type controls into native types, and testing the converted controls according to the native type testing rules; and, it is only necessary to test the controls in the application to be tested using the native type detection rules, without the need to switch the testing rules.
[0104] The present application also provides an automated testing system. Figure 7 According to an embodiment of the present application, a schematic diagram of the structure of an automated testing system is shown. Figure 7 As shown, the automated testing system 700 includes: a control determination module 710 and a testing module 720 .
[0105] The control determination module 710 is used to obtain the controls of the application to be tested; it is also used to obtain the text information and position information of each control, and perform attribute conversion on the control based on the text information and position information of the control.
[0106] The testing module 720 is used to test the controls of the application to be tested.
[0107] Figure 8 According to an embodiment of the present application, a schematic diagram of the structure of an electronic device is shown. Figure 8 As shown, the electronic device 1000 includes: a processor 110 , a memory 120 , and an interactive interface 130 .
[0108] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0109] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0110] The controller may be the nerve center and command center of the electronic device 1000. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0111] The processor 110 may also be provided with a memory 120 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0112] In some embodiments, the processor 110 may include one or more interactive interfaces 130. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0113] The memory 120 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 1000 by running the instructions stored in the memory 120. The memory 120 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function, etc. The data storage area may store data created during the use of the electronic device 1000, etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0114] Optionally, the memory 120 may be independent or integrated with the processor 110 .
[0115] Optionally, when the memory 120 is a device independent of the processor 110, the electronic device 1000 may further include: a bus 140 for connecting the above devices.
[0116] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.
[0117] Program code may be applied to input instructions to perform the functions described herein and to generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0118] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0119] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).
[0120] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.
[0121] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.
[0122] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0123] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.
Claims
1. An automated testing method, characterized in that: include: Detecting a first control in a first interface of the application to be tested, and acquiring text information and position information of the first control; wherein the attribute of the first control is a first type; Based on the text information and position information of the first control, convert the first control into a second control; wherein the attribute of the second control is a second type; The second control is tested according to the test rule of the second type.
2. The method according to claim 1, characterized in that The obtaining of the text information and position information of the first control includes: Performing a screenshot operation on the first interface to obtain a first picture; Perform text recognition on the first image to obtain text information and position information of the first control.
3. The method according to claim 2, characterized in that The taking a screenshot of the first interface to obtain a first picture includes at least one of the following: capturing a display area of the first interface as a first picture; A display area of the first control is captured as a first picture.
4. The method according to claim 1, characterized in that The converting the first control into a second control based on the text information and the position information of the first control includes: Encapsulating the text information and position information of the first control into an encapsulation object; Setting the property of the encapsulated object to a second type; The encapsulated object is added to a first type of control of the first interface.
5. The method according to claim 1, characterized in that The method further comprises: Detecting that the attribute of the first interface of the application to be tested is of the first type, obtaining text information and position information of each third control in the first interface; Based on the text information and position information of the third control, converting the third control into a second control; The third control is tested according to the test rule of the second type.
6. The method according to claim 5, characterized in that The detecting that the attribute of the first interface of the application to be tested is of the first type includes: Obtaining position information of each third control in the first interface; The position information corresponding to each of the third controls does not exceed the area threshold, and the attribute of the first interface is determined to be the first type.
7. The method according to claim 1 or 5, characterized in that: The second type of test rules includes at least one of the following: After completing the testing of the second control and the interface associated with the second control, testing the fourth control in the first interface; After completing the test of the controls in the first interface, testing the controls in the second interface; The testing of the controls in the first interface includes: testing all controls in the first interface, or selecting controls in the first interface for testing according to preset rules.
8. The method according to any one of claims 1 to 7, characterized in that The automated testing method is performed using at least one of the following testing tools: uiautomator, appium, selenium, katalon studio, soapui.
9. An automated testing system, characterized in that: include: A control determination module, used to detect a first control in a first interface of the application to be tested, and obtain text information and position information of the first control; Based on the text information and position information of the first control, convert the first control into a second control; wherein the attribute of the first control is of the first type, and the attribute of the second control is of the second type; A testing module is used to test the second control according to the second type of testing rules.
10. A readable medium, characterized in that: The readable medium stores instructions, which, when executed on an electronic device, enable the electronic device to execute the method according to any one of claims 1 to 8.
11. An electronic device, characterized in that: include: Processor, memory, and interactive interface; Wherein, the memory is used to store instructions executed by one or more processors of the electronic device; The processor is one of the processors of the electronic device, and is used to execute the method according to any one of claims 1 to 8.
