Mobile application GUI popup window detection method only based on visual information

By combining target detection and color segmentation technology of HSV color space in mobile applications, the pop-up window boundaries in GUI screenshots are identified, which solves the problem of easy failure of mobile application GUI test scripts, realizes cross-platform automated detection and processing, and improves The degree of automation of GUI testing.

CN118550824APending Publication Date: 2024-08-27NANJING UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410646748.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Mobile application GUI test scripts are prone to failure due to changes in control locators and test event sequences. In particular, failures caused by pop-up windows are difficult to handle automatically, resulting in low GUI quality assurance and automated testing.

Method used

Using a detection method based only on visual information, combined with target detection and color segmentation technology of HSV color space, by training the YOLOv8 model and the OpenCV library, the pop-up window boundaries in GUI screenshots are identified to achieve automated detection and processing.

Benefits of technology

It realizes cross-platform GUI pop-up window detection, reduces maintenance costs, improves the automation of GUI testing, supports the processing of abnormal pop-up windows, and is suitable for all mobile platforms that can provide GUI screenshots.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550824A
    Figure CN118550824A
Patent Text Reader

Abstract

The invention discloses a mobile application GUI pop-up window detection method only based on visual information, which comprises the following steps: S1, control detection: based on a mobile application layout structure and a GUI screenshot in an open source Rico data set, training a YOLOv8 model, predicting controls existing in a to-be-detected GUI page, and screening out the controls of the pop-up window type from the controls; s2, brightness binarization: representing the GUI screenshot to be detected by using an HSV color space, and binarizing a V channel value to obtain a brightness mask of the GUI screenshot; and S3, contour detection: filling the periphery of the brightness mask of the GUI screenshot with black pixels, detecting contours in the brightness mask after filling, and taking the contour with the largest area in all the contours as a pop-up window boundary. According to the method, target detection and the color segmentation technology based on the HSV color space are combined, and the pop-up window boundary in the mobile application GUI screenshot is recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of GUI testing, and in particular to a mobile application GUI pop-up window detection method based only on visual information. Background Art

[0002] Graphical User Interface (GUI) is an important part of modern software. It intuitively displays information to users through graphic elements such as menus, icons and buttons, and guides users to interact with the software. Good GUI design helps improve user experience, thereby enhancing user stickiness and improving the competitiveness of software. Given the importance of GUI, GUI quality assurance has become a key issue for software developers.

[0003] For mobile applications, the mainstream way to ensure the quality of the GUI is to use test frameworks such as Appium to develop automated test scripts to test the display, layout, and interaction of the application GUI. These GUI test scripts are usually a set of test event sequences, where the test events are composed of GUI control locators and interactive actions. Common GUI control locating methods include ID, XPath, and Accessibility ID. However, the maintenance cost of GUI test scripts is very high, because in scenarios such as application version iteration, cross-platform (Android, iOS, and Web, etc.), and Android fragmentation issues, test scripts are very likely to become invalid due to changes in control locators and test event sequences, requiring a lot of manual work to troubleshoot and repair invalid scripts.

[0004] Pop-up windows are a common reason for test script failure. For example, advertisements in an application or the first login of a user in an application may cause pop-up windows in the application that are not expected by the test script developer, thereby causing the test script to fail. How to automatically detect pop-up windows and close them is an important issue to ensure GUI quality and improve the degree of automation of GUI testing. Therefore, the present invention aims to detect pop-up windows existing on the mobile application GUI based only on visual information, obtain the boundary information of the pop-up windows, and then support the processing of abnormal pop-up windows and the improvement of the degree of automation of GUI testing. Summary of the invention

[0005] At present, the present invention proposes a mobile application GUI pop-up window detection method based only on visual information, combining target detection and color segmentation technology based on HSV color space to realize the recognition of pop-up window boundaries in mobile application GUI screenshots. The present invention is implemented through the following technical solutions.

[0006] A method for detecting pop-up windows of mobile application GUI based only on visual information, characterized in that the method comprises the following steps:

[0007] S1, control detection: Based on the mobile application layout structure and GUI screenshots in the open source Rico dataset, the YOLOv8 model is trained to predict the controls existing in the GUI page to be detected, and the pop-up type controls are selected;

[0008] S2, brightness binarization: use HSV color space to represent the GUI screenshot to be detected, binarize the V channel value, and obtain the brightness mask of the GUI screenshot;

[0009] S3, contour detection: fill black pixels around the brightness mask of the GUI screenshot, detect the contours in the filled brightness mask, and take the contour with the largest area among all contours as the pop-up window boundary.

[0010] Furthermore, the control detection in step S1 specifically includes the following steps:

[0011] S11, for each GUI page provided by the open source Rico dataset, obtain the width and height of the GUI screenshot, record w s is the width of the GUI page, h s The height of the GUI page;

[0012] S12, filtering out leaf nodes without child nodes from all nodes of the layout tree of the GUI page provided in step S1, extracting bounds and componentLabel attribute values ​​of the leaf nodes, and assigning a unique ID to the leaf nodes, wherein the leaf node ID in each GUI page starts from 0 and increases in sequence;

[0013] S13, combining the ID, bounds attribute value and componentLabel attribute value of the leaf node extracted in step S12 into the following form: <ID,<x0,y0,x1,y1> ,componentLabel>, where

[0014] <x0,y0,x1,y1> The bounds attribute value from the node, (x0, y0) represents the coordinates of the upper left corner of the control,

[0015] (x1, y1) represents the coordinates of the lower right corner of the control;

[0016] S14, for each obtained in step S13, <ID,<x0,y0,x1,y1> ,componentLabel> tuple, calculate the relative center coordinates of the control Relative width of controls Relative height to the control The control ID, control relative center coordinates, control relative width, and control relative height are calculated according to " <id><x c ><y c > <w> <h>" is written into a text file in the format of ", the componentLabel value of the control is written into the configuration file data.yml, and the YOLOv8 model is trained with the default parameters, which are epochs=100 and imgsz=640;

[0017] S15, for the YOLOv8 model trained in step S14, using the application GUI screenshot to be detected as input, predicting the boundaries and types of controls on the GUI page, retaining only Modal type controls, and recording the set of all Modal type controls as S;

[0018] S16, if the set S of Modal type controls in step S15 is not empty, directly output the boundary information of all controls in S, otherwise continue to execute steps S2 and S3.

[0019] Furthermore, the brightness binarization step S2 specifically includes the following steps:

[0020] S21, taking the path of the GUI screenshot of the application to be detected as a parameter, calling the cv2.imread() method to obtain the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected, where bgr_image is h s × s The matrix h s × s Each element in the matrix is ​​a tuple consisting of 3 integers, which are the values ​​of the B, G, and R channels of the pixel respectively;

[0021] S22, taking the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected and cv2.COLOR_BGR2HSV as parameters, calling the cv2.cvtColor() method to obtain the HSV pixel representation hsv_image of the GUI screenshot of the application to be detected, where hsv_image is h s × s The matrix h s × s Each element in the matrix is ​​a tuple consisting of 3 integers, which are the values ​​of the H, S, and V channels of the pixel point respectively;

[0022] S23, use hsv_image[:,:,2] to slice hsv_image to obtain the V channel matrix of the GUI screenshot of the application to be detected, recorded as v_image, let the parameters be src=v_image, thresh=0, maxval=255, type=cv2.THRESH_BINARY|cv2.THRESH_OTSU, call cv2.threshold() method, and obtain the brightness mask v_mask after binarization of the V channel.

[0023] Furthermore, the contour detection in step S3 specifically includes the following steps:

[0024] S31, Settings Let the parameters be src = v_mask, top = p, bottom = p, left = p, right = p, borderType = cv2.BORDER_CONSTANT, value = (0,0,0), call cv2.copyMakeBorder() method, fill black pixels with a width of p around the brightness mask v_mask, and record the brightness mask after filling black pixels around as v_mask_ext;

[0025] S32, set parameters image = v_mask_ext, threshold1 = 5, threshold2 = 500, apertureSize = 3, call cv2.Canny() method to perform Canny edge detection, and record the edge detection result as canny_image;

[0026] S33, let the parameters be src = canny_image, kernel = np.ones((3,3), np.uint8), iterations = 2, call the cv2.dilate() method to dilate the edges detected in canny_image, the number of iterations is 2, and obtain the dilated edge detection result dlt_canny_image;

[0027] Step 34: Let the parameters be image = dlt_canny_image, mode = cv2.RETR_EXTERNAL, method = cv2.CHAIN_APPROX_SIMPLE, call cv2.findContours() to find the contours in the edge detection result dlt_canny_image after expansion, and only retain the outermost contour for the nested contours to obtain a set of contours;

[0028] Step 35: Sort all detected contours in descending order according to their area size, using Python's built-in sorted() method with parameters iterable = contours, key = cv2.contourArea, reverse = True, and take the first contour cnt in the sorted result, which is the contour with the largest area;

[0029] Step 36: Call cv2.boundingRect() method to obtain the coordinates of the upper left corner (x0, y0), width w and height h of the contour cnt with the largest area, and output a tuple<x0,y0,x0+w,y0+h> As the boundary information of the detected pop-up window.

[0030] The present invention adopts the above technical solution and has the following beneficial effects:

[0031] The present invention realizes mobile application GUI pop-up window detection based only on visual information. The entire detection process is independent of the platform, so that the pop-up window detection method can be applied to all mobile platforms (or devices) that can provide GUI screenshots, thereby supporting the processing of abnormal pop-up windows in GUI testing and improving the degree of automation. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 This is a flowchart of a method for detecting mobile application GUI pop-up windows based only on visual information according to an embodiment of the present invention.

[0033] Figure 2 This is a schematic diagram of a screenshot of a mobile application GUI according to an embodiment of the present invention.

[0034] Figure 3 This is a schematic diagram of the binarization result of the V channel of a GUI screenshot in HSV color format according to an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0036] The present invention proposes a mobile application GUI pop-up window detection method based only on visual information, combining target detection and color segmentation technology based on HSV color space to realize the recognition of pop-up window boundaries in mobile application GUI screenshots; wherein, target detection identifies and screens the controls existing on the mobile application GUI, and HSV-based color segmentation obtains the pop-up window boundaries through binary image brightness and contour detection. Combining these two technologies, the present invention can provide the boundary information of mobile application GUI pop-up windows. Figure 1 As shown, Figure 1 This is a flow chart of a method for detecting a mobile application GUI pop-up window based only on visual information according to an embodiment of the present invention. The method of the present invention specifically includes:

[0037] S1, control detection: Based on the mobile application layout structure and GUI screenshots in the open source Rico dataset, the YOLOv8 model is trained to predict the controls existing in the GUI page to be detected, and the pop-up type controls are screened out; the specific implementation process of the control detection in step S1 includes the following steps:

[0038] S11, for each GUI page provided by the open source Rico dataset, obtain the width and height of the GUI screenshot, record w s is the width of the GUI page, h s The height of the GUI page;

[0039] S12, filter out leaf nodes without child nodes from all nodes of the GUI page layout tree obtained in step 11, extract bounds and componentLabel attribute values ​​of the leaf nodes, and assign a unique ID to the leaf nodes, where the leaf node ID starts from 0 and increases in sequence in each GUI page;

[0040] S13, combining the ID, bounds attribute value and componentLabel attribute value of the leaf node screened out in step S12 into the following <ID,<x0,y0,x1,y1> ,componentLabel>, where

[0041] <x0,y0,x1,y1> The bounds attribute value from the node, (x0, y0) represents the coordinates of the upper left corner of the control,

[0042] (x1, y1) represents the coordinates of the lower right corner of the control;

[0043] S14, for each obtained in step S13, <ID,<x0,y0,x1,y1> ,componentLabel> tuple, calculate the relative center coordinates of the control Relative width of controls Relative height to the control The control ID, control relative center coordinates, control relative width and control relative height are calculated according to " <id><x c ><y c > <w> <h>" is written into a text file in the format of ", the componentLabel value of the control is written into the configuration file data.yml, and the YOLOv8 model is trained with the default parameters, which are epochs=100 and imgsz=640;

[0044] S15, as attached Figure 2 As shown, Figure 2 Schematic diagram of a mobile application GUI screenshot according to an embodiment of the present invention. For the YOLOv8 model trained in step S14, the application GUI screenshot to be detected is used as input to predict the boundaries and types of controls on the GUI page, and only Modal type controls are retained. The set of all Modal type controls is recorded as S;

[0045] S16, if the set S of Modal type controls in step S15 is not empty, directly output the boundary information of all controls in S, otherwise continue to execute steps S2 and S3.

[0046] S2, brightness binarization: using HSV color space to represent the GUI screenshot to be detected, binarizing the V channel value, and obtaining the brightness mask of the GUI screenshot; the specific implementation process of step S2 brightness binarization includes the following steps:

[0047] S21, cv2 library is the Python implementation of OpenCV, takes the path of the GUI screenshot of the application to be detected as a parameter, calls cv2.imread() method, obtains the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected, and the bgr_image is h s × s Matrix, each element in the matrix is ​​a tuple consisting of 3 integers, and the 3 integers are the values ​​of the B, G, and R channels of the pixel respectively;

[0048] S22, taking the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected and cv2.COLOR_BGR2HSV as parameters, calling the cv2.cvtColor() method to obtain the HSV pixel representation hsv_image of the GUI screenshot of the application to be detected, wherein hsv_image is h s × s The matrix h s × s Each element in the matrix is ​​a tuple consisting of 3 integers, which are the values ​​of the H, S, and V channels of the pixel point respectively;

[0049] S23, use hsv_image[:,:,2] to slice hsv_image to obtain the V channel matrix of the GUI screenshot of the application to be detected, recorded as v_image, set the parameters to src = v_image, thresh = 0, maxval = 255, type = cv2.THRESH_BINARY | cv2.THRESH_OTSU, call cv2.threshold() method, and obtain the brightness mask v_mask after binarization of the V channel, such as Figure 3 As shown, Figure 3 This is a schematic diagram of the binarization result of the V channel of a GUI screenshot in HSV color format according to an embodiment of the present invention.

[0050] S3, contour detection: fill black pixels around the brightness mask of the GUI screenshot, detect the contours in the filled brightness mask, and take the contour with the largest area among all contours as the pop-up window boundary. The specific implementation process of step S3 contour detection includes the following steps:

[0051] S31, let the parameters be src=v_mask, top=p, bottom=p, left=p, right=p, borderType=cv2.BORDER_CONSTANT, value=(0,0,0), call cv2.copyMakeBorder() method, fill black pixels with a width of p around the brightness mask v_mask, and record the brightness mask after the black pixels are filled around as v_mask_ext. As a preference, the value of p is set to 55;

[0052] S32, set parameters image = v_mask_ext, threshold1 = 5, threshold2 = 500, apertureSize = 3, call cv2.Canny() method to perform Canny edge detection, and record the edge detection result as canny_image;

[0053] S33, let the parameters be src = canny_image, kernel = np.ones((3,3), np.uint8), iterations = 2, call the cv2.dilate() method to dilate the edges detected in canny_image, the number of iterations is 2, and obtain the dilated edge detection result dlt_canny_image;

[0054] S34, let the parameters be image = dlt_canny_image, mode = cv2.RETR_EXTERNAL, method = cv2.CHAIN_APPROX_SIMPLE, call cv2.findContours() to find the contours in the edge detection result dlt_canny_image after expansion, and only retain the outermost contour for the nested contours to obtain a set of contours;

[0055] S35, sort all detected contours in descending order according to their area size, using the built-in sorted() method in Python, with parameters iterable = contours, key = cv2.contourArea, reverse = True, and taking the first contour cnt in the sorted result, i.e. the contour with the largest area;

[0056] S36, call cv2.boundingRect() method to obtain the coordinates of the upper left corner (x0, y0), width w and height h of the contour cnt with the largest area, and output a tuple<x0,y0,x0+w,y0+h> As the boundary information of the detected pop-up window.

[0057] The above is only a preferred embodiment of the present invention, but the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Any simple modification, equivalent changes and modifications made to the above embodiments by any technician familiar with the profession according to the technical essence of the present invention without departing from the principle and spirit of the present invention shall be included in the protection scope of the present invention.< / h> < / w> < / id> < / h> < / w> < / id>

Claims

1. A mobile application GUI pop-up window detection method based only on visual information, characterized in that: The method comprises the following steps: S1, control detection: Based on the mobile application layout structure and GUI screenshots in the open source Rico dataset, the YOLOv8 model is trained to predict the controls existing in the GUI page to be detected, and the pop-up type controls are selected; S2, brightness binarization: use HSV color space to represent the GUI screenshot to be detected, binarize the V channel value, and obtain the brightness mask of the GUI screenshot; S3, contour detection: fill black pixels around the brightness mask of the GUI screenshot, detect the contours in the filled brightness mask, and take the contour with the largest area among all contours as the pop-up window boundary.

2. The mobile application GUI pop-up window detection method based only on visual information according to claim 1, characterized in that: The control detection step S1 specifically includes the following steps: S11, for each GUI page provided by the open source Rico dataset, obtain the width and height of the GUI screenshot, record w s is the width of the GUI page, h s The height of the GUI page; S12, filtering out leaf nodes without child nodes from all nodes of the layout tree of the GUI page provided in step S1, extracting bounds and componentLabel attribute values ​​of the leaf nodes, and assigning a unique ID to the leaf nodes, wherein the leaf node ID in each GUI page starts from 0 and increases in sequence; S13, combining the ID, bounds attribute value and componentLabel attribute value of the leaf node extracted in step S12 into the following form: <ID,<x0,y0,x1,y1> ,componentLabel>, where<x0,y0,x1,y1> The bounds attribute value from the node, (x0, y0) represents the coordinates of the upper left corner of the control, (x1, y1) represents the coordinates of the lower right corner of the control; S14, for each obtained in step S13, <ID,<x0,y0,x1,y1> ,componentLabel> tuple, calculate the relative center coordinates of the control Relative width of controls Relative height to the control The control ID, control relative center coordinates, control relative width and control relative height are calculated according to " <id><x c ><y c > <w> <h> " is written into a text file in the format of ", the componentLabel value of the control is written into the configuration file data.yml, and the YOLOv8 model is trained with the default parameters, which are epochs=100 and imgsz=640;< / h> < / w> < / id> S15, for the YOLOv8 model trained in step S14, using the application GUI screenshot to be detected as input, predicting the boundaries and types of controls on the GUI page, retaining only Modal type controls, and recording the set of all Modal type controls as S; S16, if the set S of Modal type controls in step S15 is not empty, directly output the boundary information of all controls in S, otherwise continue to execute steps S2 and S3.

3. The mobile application GUI pop-up window detection method based only on visual information according to claim 1, characterized in that: The step S2 of brightness binarization specifically includes the following steps: S21, taking the path of the GUI screenshot of the application to be detected as a parameter, calling the cv2.imread() method to obtain the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected, where bgr_image is h s × s The matrix h s × s Each element in the matrix is ​​a tuple consisting of 3 integers, which are the values ​​of the B, G, and R channels of the pixel respectively; S22, taking the BGR pixel representation bgr_image of the GUI screenshot of the application to be detected and cv2.COLOR_BGR2HSV as parameters, calling the cv2.cvtColor() method to obtain the HSV pixel representation hsv_image of the GUI screenshot of the application to be detected, where hsv_image is h s × s The matrix h s × s Each element in the matrix is ​​a tuple consisting of 3 integers, which are the values ​​of the H, S, and V channels of the pixel point respectively; S23, use hsv_image[:,:,2] to slice hsv_image to obtain the V channel matrix of the GUI screenshot of the application to be detected, recorded as v_image, let the parameters be src=v_image, thresh=0, maxval=255, type=cv2.THRESH_BINARY|cv2.THRESH_OTSU, call cv2.threshold() method, and obtain the brightness mask v_mask after binarization of the V channel.

4. The mobile application GUI pop-up window detection method based only on visual information according to claim 1, characterized in that: The step S3 of contour detection specifically includes the following steps: S31, Settings Let the parameters be src = v_mask, top = p, bottom = p, left = p, right = p, borderType = cv2.BORDER_CONSTANT, value = (0,0,0), call cv2.copyMakeBorder() method, fill black pixels with a width of p around the brightness mask v_mask, and record the brightness mask after filling black pixels around as v_mask_ext; S32, set parameters image = v_mask_ext, threshold1 = 5, threshold2 = 500, apertureSize = 3, call cv2.Canny() method to perform Canny edge detection, and record the edge detection result as canny_image; S33, let the parameters be src = canny_image, kernel = np.ones((3,3), np.uint8), iterations = 2, call the cv2.dilate() method to dilate the edges detected in canny_image, the number of iterations is 2, and obtain the dilated edge detection result dlt_canny_image; Step 34: Let the parameters be image = dlt_canny_image, mode = cv2.RETR_EXTERNAL, method = cv2.CHAIN_APPROX_SIMPLE, call cv2.findContours() to find the contours in the edge detection result dlt_canny_image after expansion, and only retain the outermost contour for the nested contours to obtain a set of contours; Step 35: Sort all detected contours in descending order according to their area size, using Python's built-in sorted() method with parameters iterable = contours, key = cv2.contourArea, reverse = True, and take the first contour cnt in the sorted result, which is the contour with the largest area; Step 36: Call cv2.boundingRect() method to obtain the coordinates of the upper left corner (x0, y0), width w and height h of the contour cnt with the largest area, and output a tuple<x0,y0,x0+w,y0+h> As the boundary information of the detected pop-up window.

Citation Information

Cited By

  • Method, system and equipment for judging and processing non-standard state of GUI (Graphical User Interface) page and medium

    CN119336434A

  • Graphical user interface agent training and prediction method and device, program and medium

    CN121598986A