An automation testing and application fluency testing method based on control matching
By using an automated testing method based on control matching, the applicability and accuracy issues of Android interface loading smoothness testing are resolved. It achieves secure and rapid testing without requiring root access, is applicable to a variety of Android devices, and reduces development and maintenance costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-11
- Publication Date
- 2026-03-31
AI Technical Summary
Existing methods for testing the smoothness of Android interface loading have limitations in applicability, require root access, have poor compatibility, consume high computational resources, and lack accuracy and speed.
An automated testing method based on control matching is adopted. The UI control structure is obtained through AccessibilityService, regular expressions are used to determine the integrity of UI loading, a time threshold is set to determine smoothness, coordinate positioning is avoided, and the script file updates the UI control structure changes.
It achieves high security without requiring root access, has wide applicability, fast testing speed, high accuracy, reduces development and maintenance costs, and is compatible with different models and system versions of Android devices.
Smart Images

Figure CN115174725B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automated testing, and specifically to a technique for testing the smoothness of Android interface loading, and a method for automated testing and application smoothness testing based on control matching. Background Technology
[0002] With the widespread adoption of mobile phones, the user base for Android applications has gradually expanded. Users' needs are no longer limited to functional fulfillment; they are increasingly focused on the user experience and overall feel. Among the many factors affecting the Android application experience, smoothness is of paramount importance to users. When an application is very smooth, frequently experiencing lag or incomplete page loading, users' work or daily life can be severely impacted. Therefore, employing an effective testing method to analyze and optimize the smoothness of Android applications is crucial.
[0003] Fluency testing requires the use of automated testing technology. Automated testing technology refers to the use of preset scripts to simulate operations such as clicking, swiping, and editing, thereby saving manpower, time, or hardware resources and improving testing efficiency.
[0004] Currently, commonly used Android automated testing technologies include adb (Android Debug Bridge) and the Xposed framework. These technologies have the following characteristics:
[0005] (1) ADB technology can be used to directly operate and manage Android emulators or real Android devices, and can serve as a debugging bridge. However, it usually requires a PC host to be connected to the mobile phone and the PC host to perform script testing. This undoubtedly increases the inconvenience in actual application and is not suitable for application scenarios where it is difficult to carry a PC host.
[0006] (2) Using frameworks such as Xposed, which can run in Android's high-privilege mode, allows for the creation of powerful modules that can operate simultaneously without modifying the APK file (modifying the system). However, Xposed does not support Android 9 and above and cannot be adapted to updated Android systems. Furthermore, it requires root access, increasing the complexity and insecurity of the application.
[0007] In automated simulation operations, some methods perform automated testing based on coordinates. However, this requires accurate positioning based on the test interface. When the test device changes, the interface also changes, causing this automated testing method to fail, resulting in high maintenance costs. To address this, some testing methods use image recognition technology to locate the position of target controls and execute automated operations based on their coordinate information. This method is novel, but it places high demands on interface resolution and machine computing performance, making it unsuitable for resource-constrained mobile phones. In practical applications, this method requires large data samples and computational resources, leading to relatively high costs and long computation times.
[0008] When testing smoothness, it's necessary to determine the completeness of interface loading. One method is to use bandwidth usage to assess loading success. If bandwidth is abundant during loading, the interface loads quickly. This method is effective for large resource interfaces, but it's difficult to determine loading success using bandwidth alone for interfaces with limited bandwidth. Machine learning techniques can also be used to determine loading success by training a classifier, but this requires a large sample set and the model is complex. Another method compares the pixel ratios in a screenshot of the interface with those in a screenshot after loading. However, interfaces consist of more than just images, making this method problematic in practice, as pixel percentages are insufficient to determine the actual loading percentage. Furthermore, this method fails on interfaces with non-fixed images or other non-fixed display elements. Summary of the Invention
[0009] To address the problems existing in the above-mentioned Android interface loading smoothness testing techniques, this invention proposes an automated testing and application smoothness testing method based on control matching. This method uses automated testing to determine the Android interface loading smoothness, has good applicability to the target application, and can accurately determine the Android interface loading smoothness.
[0010] This invention provides an automated testing and application fluency testing method based on control matching, comprising the following steps:
[0011] Step 1: After receiving the test command remotely issued by the service control terminal, the Android client filters the test scripts. The test scripts include a behavior simulation script and a smoothness determination script. The behavior simulation script records the simulated operations on the controls. The smoothness determination script stores information about the structural framework of all controls contained in the interface when the application is fully loaded.
[0012] Step 2, call the accessibility service on the Android side for automated operations, including:
[0013] (2.1) Obtain the Android interface control structure and search for and locate the target control that needs to perform simulation operations;
[0014] (2.2) Perform simulation operations on the target control according to the behavior simulation script;
[0015] Step 3, judge the application fluency after each simulation operation, including:
[0016] (3.1) Set a timer and three time thresholds t1, t2, and t3, where t1 < t2 < t3. Start timing after each simulation operation, and execute (3.2) successively when the time thresholds are reached; [[ID=!4]]
[0017] (3.2) Obtain all the control elements of the current Android interface, generate a control element list, and judge whether this list contains all the controls recorded in the fluency judgment script. If so, the interface is fully loaded; otherwise, the interface is not fully loaded;
[0018] (3.3) Obtain the application fluency judgment result according to the interface loading situation, including: judge whether it is fluent at the t1 moment, judge whether the interface is fully loaded at the t3 moment, and judge whether the interface is complete in advance at the t2 moment to obtain the fluency result.
[0019] In the above-mentioned step 1, the fluency judgment script stores the fixed information of the structural framework of all the controls included in the interface.
[0020] In the above-mentioned step 3.3, set a regular expression to judge whether the control element list contains the fixed information of the structural framework of the interface controls recorded in the fluency judgment script.
[0021] In the above-mentioned step 3.3, it includes: (1) At the t1 moment, if it is judged that the interface is fully loaded, the application fluency judgment result is fluent; otherwise, continue to execute the judgment at the t2 moment; (2) At the t2 moment, if it is judged that the interface is fully loaded, the application fluency judgment result is not fluent; otherwise, record and execute the judgment at the t3 moment; (3) At the t3 moment, if it is judged that the interface is fully loaded, the application fluency judgment result is not fluent; if the interface is not fully loaded, the judgment result is incomplete; if an error occurs in the interface loading, the judgment result is an error; if there is no response in the interface loading, the judgment result is a timeout.
[0022] Compared with various existing automated testing methods, the beneficial effects of the present invention are as follows:
[0023] (1) The method of the present invention automates operations by calling the accessibility functions of the Android phone, without needing to obtain ROOT permission, thus avoiding unnecessary risks that may be caused by ROOT access. Compared with the prior art, the method of the present invention is more secure and easier to use.
[0024] (2) The method of the present invention is highly convenient to implement and can be tested anytime, anywhere without the need to connect to the PC via USB data cable. This avoids the risk of malicious software on the PC invading the target test machine by using USB. The method of the present invention prevents other software on the PC from launching malicious attacks on the test machine via USB.
[0025] (3) The automated simulation operation method used in this invention avoids the compatibility issues caused by the coordinate-based control positioning method. Due to different resolutions, the coordinates of the target control may change on different models or system versions of Android phones, but the properties of the control remain unchanged. Therefore, the method of this invention can be compatible with various models of Android phones after one development, reducing the adaptation cost.
[0026] (4) Compared with other methods, the method of this invention has higher testing accuracy and faster testing speed. The method of this invention uses regular expressions to match whether the control list contains fixed information in the interface structure to determine whether the interface is fully loaded. Compared with the method of using image comparison, the method of this invention has lower requirements for machine performance, shorter calculation time, lower technical cost for development and implementation, is easier for programmers to develop, and has better interpretability.
[0027] (5) The automated testing behavior simulation operation and smoothness judgment template of the method of the present invention are placed in the test script file of the server. When the interface control structure changes, the script file can be updated without repackaging the Apk, which greatly improves the efficiency of development and maintenance. Attached Figure Description
[0028] Figure 1 This is a schematic diagram of the overall process of the automated testing and application fluency testing method based on control matching of the present invention;
[0029] Figure 2 This is a schematic diagram of the automated testing and application fluency testing method based on control matching in an embodiment of the present invention. Detailed Implementation
[0030] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.
[0031] This invention is an automated testing and application fluency testing method based on control matching. An implementation process is as follows: Figure 1 and Figure 2 As shown, it mainly includes the following 6 steps.
[0032] Step 1: The service control terminal is deployed on a separate server. After receiving the test commands remotely issued by the service control terminal, the Android client selects the test scripts. The test scripts include behavior simulation scripts and smoothness judgment scripts.
[0033] The behavior simulation script stores simulated operations such as clicking and swiping on controls. The smoothness assessment script stores the application interface structure template, recording fixed information about the interface control structure framework. For example, if an interface has a control used for sending messages, then that control must have corresponding id, text, and description attributes. Combining all the controls contained in the entire interface constitutes the control structure framework of that interface. The smoothness assessment script records the structural framework information of all or key controls contained in the interface when the application is fully loaded.
[0034] Step 2: The Android client reads the automated operations from the test script and begins the automated operations. This invention calls the Android client, such as the accessibility features of an Android phone, to perform automated operations without requiring root access.
[0035] Step 3: Obtain the Android interface control structure and search for and locate the target control for which automation is required. If found, proceed to Step 4 to perform test operations on the target control; otherwise, re-obtain the current interface control structure and search for and locate it.
[0036] Step 4: Perform simulated operations such as clicking and swiping on the target control according to the behavior simulation script.
[0037] In this embodiment of the invention, the simulated user operation function employs AccessibilityService technology. AccessibilityService runs in the background and can receive events emitted by the system, such as focus changes, input content changes, and button clicks. The AccessibilityService can request the currently active window and retrieve its content. This embodiment of the invention calls the AccessibilityService's control query interface to locate controls recorded in the script, and performs simulated clicks, swipes, and other operations on the controls, thereby realizing automated testing functionality in Android.
[0038] Step 5: Perform a smoothness check after each simulation operation.
[0039] In the embodiment of the present invention, the ROOT node of the Android interface is obtained by calling the AccessibilityService interface, and all control elements of the interface are obtained by traversing the ROOT node in depth, and a list of control elements is generated. By determining whether the list of control elements contains the key controls required for a fully loaded interface recorded in the fluency determination script, it is judged whether the interface loading is completed and the application fluency. When judging the completion degree of interface loading, it is judged whether the interface controls are fully loaded by detecting whether the task control Json file contains all the control elements of the template file recorded in the fluency determination script.
[0040] The list of interface controls during the interface loading process is saved in the format of a Json string, and the control element string is composed of interface structure information. The web interface consists of two parts, namely fixed information and non-fixed information. Each time the web page is accessed, the fixed information on the interface does not change, while the non-fixed information of the interface may change. For example, the personal homepage button in the social website interface belongs to fixed information; the social dynamic content will be updated continuously over time and belongs to non-fixed information. By setting a regular expression to determine whether the list of control elements contains the fixed information of the interface structure in the fluency determination script, it is judged whether the interface loading is complete. If it contains, the interface loading is complete, otherwise the interface loading is incomplete.
[0041] Furthermore, in the embodiment of the present invention, a timer is set. After a certain time after each simulated operation, the system automatically loads the interface through automated testing technology and checks whether the target interface control structure is fully loaded. When the fluency judgment result is obtained, the subsequent tasks of the thread are stopped and the thread is closed. Otherwise, the subsequent tasks are continued. Specifically as follows: Three time thresholds t1, t2, and t3 are set, where t1 < t2 < t3. At time t1, it is judged whether it is fluent. At time t3, it is judged whether the loading is complete. The threshold t2 is used for early judgment before time t3. If the interface loading is completed at this time, there is no need to perform the next judgment, thereby improving the detection efficiency. The interface control structure is obtained at these three times after the interface is loaded, and it is judged whether the interface controls are fully loaded, and the fluency judgment result is obtained. According to the loading situation of the interface, there are the following judgment results:
[0042] Step 5.1, obtain the interface control structure after t1 seconds. If the interface loading is completed, mark the interface fluency as "fluent". Otherwise, continue to wait for the next time threshold.
[0043] Step 5.2, obtain the interface control structure after t2 seconds. If the interface loading is completed, mark the interface fluency as "not fluent". Otherwise, continue to wait for the next time threshold.
[0044] Step 5.3: After t3 seconds, obtain the interface control structure. If the interface is fully loaded, report "not smooth"; if the interface loads only part of the page, report "incomplete"; if the interface encounters a loading error, report "error"; if the interface does not respond, report "timeout".
[0045] Step 6: Generate a smoothness assessment report and return the assessment result to the service controller after the smoothness assessment is completed.
[0046] Except for the technical features described in the specification, all of the above are known technologies to those skilled in the art. Descriptions of well-known components and technologies are omitted in this invention to avoid redundancy and unnecessary limitation. The embodiments described above do not represent all embodiments consistent with this application. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this invention are still within the protection scope of this invention.
Claims
1. A method for automated testing and application smoothness testing based on control matching, the method comprising: receiving a plurality of test cases; receiving a plurality of applications; receiving a plurality of controls; and determining a control mapping between the plurality of controls and the plurality of applications. It comprises the following steps: Step 1, after receiving the test command remotely issued by the service control end, the Android end screens the test script; the behavior simulation operation and the fluency judgment template of the automatic test are placed in the test script of the server; wherein, the test script comprises a behavior simulation script and a fluency judgment script; the behavior simulation script records the simulation operation on the control; the fluency judgment script stores the fixed information of the structural framework of all controls contained in the interface when the application is completely loaded; Step 2, calling the auxiliary function of the Android end for automatic operation, comprising: (2.1) obtaining the Android end interface control structure, searching and positioning the target control which needs to be simulated; (2.2) simulating the target control according to the behavior simulation script; Step 3, judging the application fluency after each simulation operation, comprising: (3.1) setting a timer and three time thresholds t1, t2 and t3, t1 < t2 < t3, starting timing after each simulation operation, and executing (3.2) when reaching the time threshold in turn; (3.2) obtaining all control elements of the current Android end interface, generating a control element list, and judging whether the list contains all controls recorded in the fluency judgment script, if yes, the interface is completely loaded, otherwise the interface is not completely loaded; In step (3.2), the AccessibilityService interface is called to obtain the ROOT node of the Android end interface, the ROOT node is deeply traversed, all control elements of the interface are obtained, and a control element list is generated; (3.3) judging the application fluency according to the interface loading condition, comprising: judging whether it is fluent at t1, judging whether the interface is completely loaded at t3, and judging the fluency result in advance at t2 whether the interface is complete.
2. The method of claim 1, wherein, In step 3, a regular expression is set to judge whether the control element list contains the fixed information of the structural framework of the interface control recorded in the fluency judgment script.
3. The method of claim 1, wherein, In step (3.3), comprising: (1) at t1, if it is judged that the interface is completely loaded, the application fluency judgment result is fluent, otherwise, continue to execute the judgment at t2; (2) at t2, if it is judged that the interface is completely loaded, the application fluency judgment result is not fluent, otherwise, record the judgment at t3; (3) at t3, if it is judged that the interface is completely loaded, the application fluency judgment result is not fluent; if the interface is not completely loaded, the judgment result is not complete; if the interface loading appears error, the judgment result is error; if the interface loading has no response, the judgment result is timeout.
Citation Information
Patent Citations
Method and system for multi-interface switching test of smart television
CN103596000A
Software automation test method and device and computer readable storage medium
CN113553261A