A method of asynchronous traversal of page controls based on image analysis
Through an asynchronous traversal method based on image analysis, using computer vision and OCR algorithms, combined with thread pool asynchronous processing, the problem of slow and intrusive control traversal speed in mobile application testing is solved, and efficient and automated page control traversal is achieved, which is suitable for wireless applications. Barrier compliance detection.
Patent Information
- Application Number
- CN202210369175.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-04-08
AI Technical Summary
There is a lack of fast, efficient, and accurate page control traversal methods in mobile application testing. Traditional tools are intrusive and slow, prone to blocking and interruption, and difficult to traverse all controls.
The asynchronous traversal method of page controls based on image analysis is adopted. The control coordinates are calculated through screenshots and computer vision algorithms. The alternative text content of the controls is obtained by combining the OCR algorithm. The thread pool is used for asynchronous processing to simulate the keyboard operation barrier-free auxiliary program to achieve non-intrusive traversal.
It realizes full automation and non-intrusive traversal without manual intervention, with fast speed and high traversal degree. It is suitable for barrier-free compliance detection and provides mobile application page information for subsequent detection.
Smart Images

Figure CN114840416B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of computer technology software and mobile application testing, and in particular relates to an asynchronous traversal method of page controls based on image analysis. Background Art
[0002] Testing and analysis of mobile applications often requires obtaining the structure and page information of mobile applications first. However, mobile applications cannot crawl web page information through crawler technology like web pages. Due to the sensitivity of page structure and information, mobile applications are difficult to parse directly through traditional tools, and obtaining mobile application source code often brings further security risks. Therefore, there is a need for a fast, efficient and accurate page control traversal method to facilitate the testing and analysis of mobile applications. At present, there are some automatic traversal methods for application pages in the field of mobile application testing, which usually use invasive automated testing tools for traversal. The main disadvantages are invasiveness, slow speed, easy blocking and interruption, and missed detection. Summary of the invention
[0003] The purpose of the present invention is to provide a page control asynchronous traversal method based on image analysis in view of the deficiencies of the prior art.
[0004] The object of the present invention is achieved through the following technical solution: a page control asynchronous traversal method based on image analysis, comprising the following steps:
[0005] S1: Enter the page and move to the first control;
[0006] S2: Get a screenshot of the current page;
[0007] S3: Generates asynchronous tasks and submits them to the thread pool for execution;
[0008] S4: If the number of moves does not reach the set number of rounds and the set total number of moves, move to the next control and jump to step S2 to continue execution;
[0009] S5: If the number of moves reaches the set number of rounds, determine whether the page traversal is complete;
[0010] S6: If step S5 determines that the page traversal is not completed, move to the next control and jump to step S2 to continue execution;
[0011] S7: If step S5 determines that the page traversal is completed or the number of moves reaches the set total number of moves, the page control traversal is completed.
[0012] Furthermore, step S2 includes: connecting the mobile phone and the host computer via USB, using the screen projection software to project the mobile phone screen onto the host computer desktop, and then obtaining the window of the screen projection software and capturing the mobile phone screen in the window.
[0013] Further, step S3 includes:
[0014] S31: One task is to calculate the coordinates of the current page control based on the screenshot using a computer vision algorithm;
[0015] S32: Another task is to calculate the alternative text content of the current control through the OCR algorithm based on the subtitle of the current page;
[0016] S33: Submit these two tasks to the thread pool for asynchronous execution.
[0017] Further, step S5 includes:
[0018] S51: Wait for all asynchronous tasks in the thread pool to be completed;
[0019] S52: after all the tasks in step S51 are completed, page controls are sequentially generated according to the control information included in all the tasks;
[0020] S53: Based on the alternative text content of the control generated in step S32, if the number of consecutive identical alternative text contents of the control at the end of the page reaches the set maximum number, or the loop is the same, the page traversal is considered to be completed, otherwise the traversal is not completed.
[0021] Furthermore, the maximum number set in step S53 is 6.
[0022] Furthermore, the number of rounds set in step S4 is 20 times.
[0023] Furthermore, the total number of moves set in step S4 is 80 times.
[0024] Furthermore, in step S4, the method for moving to the next control is: connecting the mobile phone and the host computer via Bluetooth, simulating keyboard operation, and sending a "move to the next item" instruction of the accessibility assistance program.
[0025] The beneficial effects of the present invention are as follows:
[0026] (1) No human intervention is required, and the whole process is automated;
[0027] (2) The crawling degree of traversal is high. After opening the accessibility program of the mobile phone, every control on the page can be traversed in an ideal situation;
[0028] (3) Non-intrusive, no need to obtain the source code of the software;
[0029] (4) Fast speed, using asynchronous processing, the time interval for control traversal is very short;
[0030] (5) It can be used as an upstream service for accessibility compliance testing to crawl the page information of mobile applications for subsequent testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 It is an overall flow chart of the page control asynchronous traversal method based on image analysis of the present invention;
[0033] Figure 2 This is a flow chart for determining whether page traversal is complete in the present invention. Specific implementation methods
[0034] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0035] like Figure 1 As shown, the present invention provides a page control asynchronous traversal method based on image analysis, comprising the following steps:
[0036] S1: Enter the APP page and move to the first control.
[0037] S2: Get a screenshot of the current page.
[0038] Specifically, the mobile phone and the host computer are connected via USB, the screen projection software is used to project the mobile phone screen onto the host computer desktop, and then the window of the screen projection software is obtained to capture the mobile phone screen in the window.
[0039] S3: Generates asynchronous tasks and submits them to the thread pool for execution; including:
[0040] S31: One task is to calculate the coordinates of the current page controls based on the screenshot using a computer vision algorithm.
[0041] S32: Another task is to calculate the alternative text content of the current control through the OCR algorithm based on the subtitle of the current page.
[0042] S33: Submit these two tasks to the thread pool for asynchronous execution.
[0043] S4: If the number of moves does not reach the set number of rounds and the set total number of moves, move to the next control and jump to step S2 to continue. In this embodiment, the set number of rounds is 20 times and the set total number of moves is 80 times.
[0044] Specifically, the method of moving to the next control is: connecting the mobile phone and the host computer via Bluetooth, simulating keyboard operation, and sending a "move to the next item" instruction of the accessibility assistance program.
[0045] S5: Figure 2 As shown, if the number of moves reaches the set number of rounds, it is determined whether the page traversal is completed, including:
[0046] S51: Wait for all asynchronous tasks in the thread pool to be completed.
[0047] S52: After all the tasks in step S51 are completed, page controls are generated sequentially according to the control information included in all the tasks.
[0048] S53: According to the alternative text content of the control generated in step S32, if the number of consecutive identical alternative text contents of the control at the end of the page reaches the set maximum number, or the same cycle, the page traversal is considered to be completed, otherwise the traversal is not completed. In this embodiment, the set maximum number is 6.
[0049] S6: If step S5 determines that the page traversal is not completed, move to the next control and jump to step S2 to continue execution;
[0050] S7: If step S5 determines that the page traversal is completed or the number of moves reaches the set total number of moves, the page control traversal is completed.
[0051] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A page control asynchronous traversal method based on image analysis, characterized in that: The following steps are involved: S1: Enter the page and move to the first control; S2: Get a screenshot of the current page; Connect the mobile phone and the host computer via USB, use the screen projection software to project the mobile phone screen onto the host computer desktop, then obtain the window of the screen projection software and capture the mobile phone screen in the window; S3: Generates asynchronous tasks and submits them to the thread pool for execution; S31: One task is to calculate the coordinates of the current page control based on the screenshot using a computer vision algorithm; S32: Another task is to calculate the alternative text content of the current control through the OCR algorithm based on the subtitle of the current page; S33: Submit these two tasks to the thread pool for asynchronous execution; S4: If the number of moves does not reach the set number of rounds and the set total number of moves, move to the next control and jump to step S2 to continue execution; The method to move to the next control is: connect the mobile phone and the host computer via Bluetooth, simulate keyboard operation, and send the "move to the next item" command of the accessibility auxiliary program; S5: If the number of moves reaches the set number of rounds, determine whether the page traversal is complete; S51: Wait for all asynchronous tasks in the thread pool to be completed; S52: after all the tasks in step S51 are completed, page controls are sequentially generated according to the control information included in all the tasks; S53: according to the alternative text content of the control generated in step S32, if the number of consecutive identical alternative text contents of the control at the end of the page reaches the set maximum number, or the same cycle occurs, the page traversal is considered to be completed, otherwise the traversal is not completed; S6: If step S5 determines that the page traversal is not completed, move to the next control and jump to step S2 to continue execution; S7: If step S5 determines that the page traversal is completed or the number of moves reaches the set total number of moves, the page control traversal is completed.
2. The page control asynchronous traversal method based on image analysis according to claim 1 is characterized in that: The maximum number set in step S53 is 6.
3. The page control asynchronous traversal method based on image analysis according to claim 1 is characterized in that: The number of rounds set in step S4 is 20 times.
4. The page control asynchronous traversal method based on image analysis according to claim 1 is characterized in that: The total number of moves set in step S4 is 80 times.
