A method and system for detecting page grayscale of a mobile client
By performing grayscale detection of screenshots of mobile clients and automatically obtaining and detecting control screenshot lists, the problems of low efficiency and high cost of grayscale display detection of mobile clients in the prior art are solved, and efficient and automated grayscale detection is achieved.
Patent Information
- Application Number
- CN202210276405.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2042-03-21
AI Technical Summary
The grayscale display detection method of existing mobile clients is inefficient and costly, and testers need to spend a lot of manpower and time verifying the grayscale display of all pages and controls.
By obtaining screenshots of the mobile client, the detection is performed using the preset grayscale detection method. If the detection result is a non-grayscale display, obtain the control screenshot list and perform grayscale detection on it, automatically identify the ungrayscaled controls and perform the next detection.
It improves the efficiency and test quality of grayscale test on mobile client pictures, reduces labor testing costs, and realizes an automated grayscale test process.
Smart Images

Figure CN114816992B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of mobile software testing, and more specifically, to a method and system for detecting page grayscale of a mobile client. Background Art
[0002] When the mobile client encounters special holidays, it is necessary to display the application-related pages and controls in grayscale. The grayscale display method of the mobile client can support grayscale display of all pages, partial pages, or a single control on a certain page.
[0003] In order to ensure the grayscale display of the mobile client, it is necessary to detect the grayscale display of the mobile client. In the existing detection methods for the grayscale display of the mobile client, since it involves all pages and controls of the application (Application, APP) of the mobile client, testers need to spend a large amount of manpower and a long time to complete the detection of the grayscale display of each page during verification.
[0004] Therefore, the existing detection method for the grayscale display of the mobile client has low efficiency and high detection cost. Summary of the Invention
[0005] In view of this, this application discloses a method and system for detecting page grayscale of a mobile client, aiming to improve the efficiency and quality of image grayscale testing of the mobile client and reduce the human testing cost.
[0006] To achieve the above object, the disclosed technical solutions are as follows:
[0007] The first aspect of this application discloses a method for detecting page grayscale of a mobile client, and the method includes:
[0008] Obtain a screenshot of the mobile client;
[0009] Perform grayscale detection on the screenshot through a preset grayscale detection method to obtain a detection result in a preset data format; the detection result is used to determine whether the screenshot is a screenshot with grayscale display;
[0010] If the detection result is a screenshot without grayscale display, obtain a list of control screenshots; the list of control screenshots is used to store screenshots of each page control of the mobile client;
[0011] Perform grayscale detection on the screenshots of each page control in the list of control screenshots.
[0012] Preferably, the obtaining of the screenshot of the mobile client includes:
[0013] Obtain a screenshot of the mobile client through a preset screenshot method.
[0014] Preferably, through a preset grayscale detection method, perform grayscale detection on the screenshot to obtain a detection result in a preset data format, including:
[0015] Encode the screenshot through a preset encoding format to obtain encoded data;
[0016] Encrypt the encoded data through a preset encryption method to obtain the picture string of the screenshot;
[0017] Decode the picture string through a preset decoding method to obtain the decoded data corresponding to the picture string;
[0018] Perform encoding on the decoded data corresponding to the picture string to obtain the encoded picture corresponding to the screenshot;
[0019] Call a preset recognition method to perform grayscale recognition on the encoded picture to obtain a detection result in a preset data format;
[0020] Preferably, if the detection result is a screenshot that is not grayscale displayed, obtain a list of control screenshots, including:
[0021] If the length of the preset list in the detection result is not 0, determine that the detection result is a screenshot that is not grayscale displayed;
[0022] When the detection result is a screenshot that is not grayscale displayed, obtain the page control information of each control of the mobile client and the picture resolution of the screenshot;
[0023] Based on the page control information, determine the resolution coordinates and sizes of each control of the mobile client;
[0024] Based on the picture resolution, determine the initial coordinate values of the controls;
[0025] Divide the screenshot through the initial coordinate values and the sizes of each control to obtain pictures corresponding to each control, and name the pictures corresponding to each control as control IDs;
[0026] Obtain the paths of the pictures corresponding to each control, and generate a list of control screenshots through the paths of the pictures corresponding to each control and the control IDs.
[0027] Preferably, it further includes:
[0028] Determine the business to which each control belongs.
[0029] Preferably, it further includes:
[0030] Store the screenshot in a preset form to a preset specified path.
[0031] Preferably, it further includes:
[0032] If the length of the preset list in the detection result is 0, determine that the detection result is a screenshot presented in grayscale.
[0033] Preferably, it further includes:
[0034] If the detection result is a screenshot presented in grayscale, generate a grayscale result report.
[0035] The second aspect of the present application discloses a page grayscale detection system for a mobile client. The system includes:
[0036] A first acquisition unit, configured to acquire a screenshot of the mobile client;
[0037] A first detection unit, configured to perform screenshot grayscale detection on the screenshot by a preset grayscale detection method to obtain a detection result in a preset data format; the detection result is used to determine whether the screenshot is a screenshot presented in grayscale;
[0038] A second acquisition unit, configured to, if the detection result is a screenshot not presented in grayscale, acquire a list of control screenshots; the list of control screenshots is used to store screenshots of each page control of the mobile client;
[0039] A second detection unit, configured to perform grayscale detection on screenshots of each page control in the list of control screenshots.
[0040] Preferably, the first acquisition unit is specifically configured to:
[0041] Acquire a screenshot of the mobile client through a preset screenshot method.
[0042] As can be seen from the above technical solutions, the present application discloses a method and system for detecting page grayscale of a mobile client. A screenshot of the mobile client is obtained. The screenshot stores the screen elements of the mobile client in the form of a picture. Through a preset grayscale detection method, the screenshot is subjected to screenshot grayscale detection to obtain a detection result in a preset data format. The detection result is used to determine whether the screenshot is a screenshot with grayscale display. If the detection result indicates that the screenshot is not a screenshot with grayscale display, a control screenshot list is obtained. The control screenshot list is used to store screenshots of each page control of the mobile client, and the screenshots of each page control in the control screenshot list are subjected to grayscale detection. Through the above solution, it is not necessary to manually detect all pages and controls of the APP of the mobile client. By simulating user operations to access all pages and taking screenshots, if there are ungrayscaled parts in the screenshots, the screenshots of each page control in the obtained control screenshot list are subjected to grayscale detection to determine which control's picture is not grayscaled, and the grayscale recognition of the next page is automatically performed, improving the test efficiency and test quality of the picture grayscale of the mobile client and reducing the human test cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.
[0044] Figure 1 It is a schematic flowchart of a method for detecting page grayscale of a mobile client disclosed in an embodiment of the present application;
[0045] Figure 2 It is a schematic structural diagram of a system for detecting page grayscale of a mobile client disclosed in an embodiment of the present application;
[0046] Figure 3 It is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0047] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0048] In this application, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising the element.
[0049] As can be seen from the background art, in order to ensure the grayscale display of the mobile client, it is necessary to detect the grayscale display of the mobile client. In the existing detection methods for the grayscale display of the mobile client, since it involves all pages and controls of the APP of the mobile client, testers need to spend a large amount of manpower and a long time to complete the detection of the grayscale display of each page. Therefore, the existing detection methods for the grayscale display of the mobile client are inefficient and have a high detection cost.
[0050] To solve the above problems, the embodiments of this application disclose a method and system for detecting the page grayscale of a mobile client, which improve the efficiency and quality of the picture grayscale test of the mobile client and reduce the human testing cost. The specific implementation manner will be specifically described in the following embodiments.
[0051] Reference Figure 1 As shown, it is a schematic flowchart of a method for detecting the page grayscale of a mobile client disclosed in the embodiments of this application. The method for detecting the page grayscale of the mobile client mainly includes the following steps:
[0052] S101: Obtain a screenshot of the mobile client.
[0053] In S101, the screenshot is to store the screen elements of the mobile client in the form of a picture.
[0054] Obtain a screenshot of the mobile client through a preset screenshot method.
[0055] Among them, the preset screenshot method can be the save_screenshot() method in the screen capture Appium, or the get_screenshot_os_file(self, filename) method. The preset screenshot method is set by technicians according to the actual situation, and this application does not make specific limitations. The preset screenshot method of this application preferably uses the save_screenshot() method in Appium.
[0056] Store the screenshot in a preset form to a preset specified path.
[0057] The preset format may be a portable network graphic (PNG) or other formats. The preset format is determined by the technician according to the actual situation and is not specifically limited in this application. The preset format of this application is preferably a PNG format.
[0058] The save_screenshot() method in Appium is used to store the screenshot of the mobile client in PNG format to the preset specified path, that is, the file location where the current script is located.
[0059] For example, to help you understand the process of using the save_screenshot() method in Appium to store a screenshot of a mobile client to the file location where the current script is located, here is an example:
[0060] For example, the current script:
[0061] #!_*_ coding:UTF-8 _*_from find_element.capability import driver.
[0062] driver.find_element_by_xpath(' / / *[@text="Safety check speed"]').click().
[0063] driver.save_screenshot('anjian.png') #Screenshot, save the screenshot to the folder where the current script is located, and name it anjian.png.
[0064] S102: Performing a grayscale detection on the screenshot using a preset grayscale detection method to obtain a detection result in a preset data format; the detection result is used to determine whether the screenshot is a grayscale displayed screenshot.
[0065] Specifically, the process of performing screenshot grayscale detection on the screenshot by using a preset grayscale detection method and obtaining the detection result in a preset data format is shown in A1-A5.
[0066] A1: Encode the screenshot using a preset encoding format to obtain encoded data.
[0067] The preset encoding format may be a JPG format or other types of encoding formats. The preset encoding format is set by a technician according to actual conditions, and this application does not specifically limit it. The preset encoding format of this application is preferably a JPG format.
[0068] Encode the screenshot in JPG format to obtain the encoded data of the screenshot after JPG format encoding.
[0069] A2: Encrypt the encoded data through a preset encryption method to obtain the picture string of the screenshot.
[0070] Among them, the preset encryption method can be base64 encryption, RSA encryption, etc. The specific preset encryption method is set by the technical personnel according to the actual situation, and this application does not make specific limitations. The preset encryption method of this application is preferably base64 encryption.
[0071] Use base64 encryption for the encoded data to obtain the encoded picture string corresponding to the screenshot.
[0072] A3: Decode the picture string through a preset decoding method to obtain the decoded data corresponding to the picture string.
[0073] Among them, the preset decoding method can be (Numerical Python, Numpy) decoding method, or other decoding methods. The determination of the preset decoding method is set by the technical personnel according to the actual situation, and this application does not make specific limitations. The preset decoding method of this application is preferably the Numpy decoding method.
[0074] Numpy is an open-source numerical computing extension of Python. This tool can be used to store and process large matrices.
[0075] Decode the picture string through the Numpy decoding method to obtain the decoded data corresponding to the picture string.
[0076] A4: Encrypt the decoded data corresponding to the picture string to obtain the encrypted picture corresponding to the screenshot.
[0077] Among them, call the grayscale image detection http interface to upload the encrypted picture to the picture grayscale recognition server in the form of post parameters for picture grayscale recognition.
[0078] A5: Call the preset recognition method to perform grayscale recognition on the encrypted picture to obtain the detection result in the preset data format.
[0079] Among them, the preset recognition method is through the cross-platform computer vision and machine learning software library OpenCV2.
[0080] OpenCV is a cross-platform computer vision and machine learning software library distributed under the Apache 2.0 license (open source). It can run on Linux, Windows, Android, and Mac OS operating systems. It consists of a series of C functions and a small number of C++ classes, and at the same time provides interfaces in languages such as Python, Ruby, and MATLAB, implementing many general algorithms in image processing and computer vision.
[0081] In this solution, only the cv2 module of OpenCV is used to perform grayscale recognition of images.
[0082] The determination of the preset recognition method is not specifically limited in this application.
[0083] The preset data format is the detection result returned in the form of JSON (JavaScript Object Notation).
[0084] The image grayscale detection server calls cv2 and Numpy to perform grayscale recognition of images and returns the detection result in JSON format.
[0085] The specific content of the returned detection result is as follows:
[0086] {
[0087] "msg": "done",
[0088] "success": true,
[0089] "code":200,
[0090] "bboxs":[[0, 0, 10, 10], [50, 50, 70, 80],...]
[0091] }
[0092] Among them, in the detection result, bbox is a list composed of result boxes, [bbox0, bbox1,...]. Each bbox has 4 integers, which respectively represent: left side left, top side top, width weight, and height height. The size of the color area is represented by these 4 integers.
[0093] S103: Determine whether the detection result is a screenshot of non-grayscale display. If the detection result is a screenshot of non-grayscale display, then execute S104. If the detection result is a screenshot of grayscale display, then execute S106.
[0094] In S103, by determining whether the length of the preset list in the detection result is 0, it is determined whether the detection result is a screen shot shown in grayscale or a screen shot not shown in grayscale.
[0095] Among them, the preset list is the list bbox composed of result boxes.
[0096] If the length of the preset list in the detection result (the length of the list bbox composed of result boxes) is 0, it is determined that the detection result is a screen shot shown in grayscale.
[0097] If the length of the preset list in the detection result (the length of the list bbox composed of result boxes) is not 0, it is determined that the detection result is a screen shot not shown in grayscale.
[0098] Among them, if the length of the list bbox composed of result boxes in the detection result is not 0, it is determined that the detection result is a screen shot not shown in grayscale, that is, a screen shot of a color area is detected.
[0099] S104: Obtain a list of control screenshots; the list of control screenshots is used to store screenshots of each page control of the mobile client.
[0100] In S104, screenshots are obtained through save_screenshot() in Appium, the screen resolution is obtained through driver.get_window_size(), the control size is obtained through driver.find_element_by_XX().size, and the control coordinates, the upper left coordinate point of the area where the control is located, are obtained through driver.find_element_by_XX().location. OpenCV is used to split the picture according to the screenshot, screen resolution, control coordinates and size to obtain screenshots of each page control of the mobile client.
[0101] The specific process of obtaining the list of control screenshots is as shown in B1 - B5.
[0102] B1: Obtain the page control information of each control of the mobile client and the picture resolution of the screenshot.
[0103] In B1, the screenshot is obtained through save_screenshot() in Appium.
[0104] Determine the business to which each control belongs.
[0105] Among them, developers add business identifiers to the resource-id of page control attributes, record the corresponding relationships between business line names and business identifiers in the configuration file, and distinguish the business to which the control belongs according to the business identifier in the resource-id and the corresponding relationship in the configuration file during the automated testing process.
[0106] The businesses include channels, membership, on-demand, live broadcast, search, advertising, personal center, etc. The same page may also contain different businesses. For example, the channel home page may contain flash pictures, small horizontal pictures, large horizontal pictures, etc.
[0107] B2: Based on the page control information, determine the resolution coordinates and sizes of each control of the mobile client.
[0108] Among them, page control information is obtained through Appium, and each page control information includes an attribute key and a corresponding attribute value value.
[0109] The size of each control is obtained through driver.find_element_by_XX().size.
[0110] The codes of the specific attribute key and the corresponding attribute value value are as follows:
[0111] [{
[0112] "key": "elementId",
[0113] "value": "1287aa81-8e16-4954-aec1-ed02c520ea0a",
[0114] "name": "elementId"
[0115] }, {
[0116] "key": "index",
[0117] "value": "0",
[0118] "name": "index"
[0119] }, {
[0120] "key": "package",
[0121] "value": "com.hunantv.imgo.activity",
[0122] "name": "package"
[0123] }, {
[0124] "key": "class",
[0125] "value": "android.widget.ImageView",
[0126] "name": "class"
[0127] }, {
[0128] "key": "text",
[0129] "value": "",
[0130] "name": "text"
[0131] }, {
[0132] "key": "checkable",
[0133] "value": "false",
[0134] "name": "checkable"
[0135] }, {
[0136] "key": "checked",
[0137] "value": "false",
[0138] "name": "checked"
[0139] }, {
[0140] "key": "clickable",
[0141] "value": "false",
[0142] "name": "clickable"
[0143] }, {
[0144] "key": "enabled",
[0145] "value": "true",
[0146] "name": "enabled"
[0147] }, {
[0148] "key": "focusable",
[0149] "value": "false",
[0150] "name": "focusable"
[0151] }, {
[0152] "key": "focused",
[0153] "value": "false",
[0154] "name": "focused"
[0155] }, {
[0156] "key": "long-clickable",
[0157] "value": "false",
[0158] "name": "long-clickable"
[0159] }, {
[0160] "key": "password",
[0161] "value": "false",
[0162] "name": "password"
[0163] }, {
[0164] "key": "scrollable",
[0165] "value": "false",
[0166] "name": "scrollable"
[0167] }, {
[0168] "key": "selected",
[0169] "value": "false",
[0170] "name": "selected"
[0171] }, {
[0172] "key": "bounds",
[0173] "value": "[41,474][1039,1035]",
[0174] "name": "bounds"
[0175] }, {
[0176] "key": "displayed",
[0177] "value": "true",
[0178] "name": "displayed"
[0179] }]。
[0180] B3: Determine the initial coordinate values of the controls based on the image resolution.
[0181] B4: Split the screenshot according to the initial coordinate values and the sizes of the respective controls to obtain the images corresponding to the respective controls, and name the images corresponding to the respective controls with the control IDs.
[0182] B5: Obtain the paths of the images corresponding to the respective controls, and generate a list of control screenshots based on the paths of the images corresponding to the respective controls and the control IDs.
[0183] S105: Perform grayscale detection on the screenshots of each page control in the list of control screenshots.
[0184] In S105, use Appium to simulate user operations to access each page and take screenshots, and use cv2 and Numpy to identify the grayscale images of the screenshots of each page control. If there are ungrayscaled parts in the screenshots of each page control, split the screenshots according to the screen resolution, control size, etc., and perform grayscale recognition to determine which control's image is not grayscaled and generate a test result, and then continue with the grayscale detection of the next page.
[0185] The mobile client simulates user operations and uses the open-source UI automation tool Appium to perform operations such as application startup, page navigation, screenshot taking, control property acquisition, and application shutdown.
[0186] Among them, the open-source UI automation tools include Appium (for ios and android), Calabash (for ios and android), Robotium (for android), Frank (for ios), UIAutomator (for android), etc.
[0187] If the grayscale conversion success flag is returned, the current page use case passes. If the grayscale conversion failure flag is returned, the control screenshot acquisition process is executed. Cut the image to obtain each control screenshot dictionary, and then loop through the grayscale check of each control image, returning the control IDs that fail the grayscale check.
[0188] The developer adds a business identifier to the resource-id attribute of the control, associates the business identifier with the specific business name in the business relationship mapping configuration file. After obtaining the list of control IDs that fail grayscale conversion, it is possible to analyze which business images on the current page are not grayscale-converted based on the mapping configuration.
[0189] The specific grayscale conversion example code is as follows:
[0190] #! / usr / bin / env python
[0191] # -*- encoding: utf-8 -*-
[0192] import numpy as np
[0193] import base64
[0194] import cv2
[0195] from fastapi import FastAPI
[0196] from typing import List
[0197] from pydantic import BaseModel
[0198] import uvicorn
[0199] app = FastAPI()。
[0200] class ColorDetRequest(BaseModel): # threshold1=50, threshold2=10,kernel_size=9
[0201] img: str
[0202] # threshold1: int
[0203] # threshold2: int
[0204] # kernel_size: int
[0205] class basebox(BaseModel):
[0206] x: int
[0207] y: int
[0208] w: int
[0209] h: int
[0210] class ColorDetResponse(BaseModel):
[0211] message: str
[0212] success: bool
[0213] code: int
[0214] bboxs: List[List[int]]
[0215] def base64_to_image(roi_buffer_b64):
[0216] img_data = base64.b64decode(roi_buffer_b64)
[0217] img_array = np.fromstring(img_data, np.uint8) #fromstring function is very convenient to decode data from a string.
[0218] img = cv2.imdecode(img_array, cv2.IMREAD_COLOR) #Reads data from the specified memory cache and converts (decodes) the data into an image format; mainly used to recover images from network transmitted data.
[0219] return img
[0220] def color_det_by_hsv(hsv, threshold1=50, threshold2=10, kernel_size=9):
[0221] h, s, v = cv2.split(hsv) #Split the three channels of an RGB image, s is a grayscale image.
[0222] th, threshed = cv2.threshold(s, threshold1, 255, cv2.THRESH_BINARY) # Apply binary thresholding to the image. cv2.threshold(source image, threshold, fill color, threshold type).
[0223] threshed = cv2.GaussianBlur(threshed, (kernel_size, kernel_size),0) # Blur the image using a Gaussian filter.
[0224] th, threshed = cv2.threshold(threshed, threshold2, 255,cv2.THRESH_BINARY) # Detect contours.
[0225] contours, hierarchy = cv2.findContours(threshed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Draw contours.
[0226] bboxs = []
[0227] for ind, cnt in enumerate(contours):
[0228] if len(cnt)<50: continue
[0229] bboxs.append(cv2.boundingRect(cnt)) # Get the contour points and return four values: x, y, w, h.
[0230] bboxs = sorted(bboxs, key=lambda r: r[2] * r[3], reverse=True)
[0231] return bboxs.
[0232] @app.get(" / det_health")
[0233] async def det_health():
[0234] return "health"
[0235] @app.post(" / color_det", response_model=ColorDetResponse)
[0236] async def name_voice(item: ColorDetRequest):
[0237] img_str = item.img
[0238] try:
[0239] img = base64_to_image(img_str)
[0240] hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # Convert the image from one color space to another color space.
[0241] except Exception as e:
[0242] print(e)
[0243] return ColorDetResponse(message="error img", success=False,code=300, bboxs=[])
[0244] bboxs = color_det_by_hsv(hsv) # Image grayscale query processing.
[0245] return ColorDetResponse(message="done", success=True, code=200,bboxs=bboxs)
[0246] if __name__ == "__main__":
[0247] uvicorn.run(app, host="0.0.0.0", port=8080).
[0248] S106: Generate a grayscale result report.
[0249] In the embodiments of the present application, there is no need to manually detect all pages and controls of the APP on the mobile client. By simulating user operations to access all pages and take screenshots, if there are un-grayed parts in the screenshots, the screenshots of each page control in the obtained control screenshot list are subjected to grayscale detection to determine which control's picture is not grayed, and the grayscale recognition of the next page is automatically performed, improving the test efficiency and test quality of the picture grayscale of the mobile client and reducing the human test cost.
[0250] Based on the above embodiments Figure 1 A method for detecting the grayscale of pages of a mobile client disclosed, the embodiments of the present application also correspondingly disclose a system for detecting the grayscale of pages of a mobile client, as Figure 2 shown. The system for detecting the grayscale of pages of the mobile client includes a first acquisition unit 201, a first detection unit 202, a second acquisition unit 203, and a second detection unit 204.
[0251] The first acquisition unit 201 is used to acquire a screenshot of the screen of the mobile client; the screenshot of the screen is in the form of storing the screen elements of the mobile client as a picture.
[0252] The first detection unit 202 is used to perform grayscale detection on the screenshot of the screen through a preset grayscale detection method to obtain a detection result in a preset data format; the detection result is used to determine whether the screenshot of the screen is a screenshot of the screen presented in grayscale.
[0253] The second acquisition unit 203 is used to obtain a control screenshot list if the detection result is a screenshot of the screen that is not presented in grayscale; the control screenshot list is used to store screenshots of each page control of the mobile client.
[0254] The second detection unit 204 is used to perform grayscale detection on the screenshots of each page control in the control screenshot list.
[0255] Further, the first acquisition unit is specifically used to acquire a screenshot of the screen of the mobile client through a preset screenshot method.
[0256] Further, the first detection unit includes an encoding module, an encryption module, a decoding module, an encoding module, and an identification module.
[0257] The encoding module is used to encode the screenshot of the screen through a preset encoding format to obtain encoded data.
[0258] The encryption module is used to encrypt the encoded data through a preset encryption method to obtain a picture string of the screenshot of the screen.
[0259] The decoding module is used to decode the picture string through a preset decoding method to obtain decoded data corresponding to the picture string.
[0260] An encoding module, configured to encode the decoded data corresponding to the picture string to obtain an encoded picture corresponding to the screenshot.
[0261] An identification module, configured to call a preset identification method to perform grayscale identification on the encoded picture to obtain a detection result in a preset data format.
[0262] Further, the second obtaining unit 203 includes a first determination module, a first obtaining module, a second determination module, a third determination module, a splitting module, and a second obtaining module.
[0263] The first determination module is configured to determine that the detection result is a screenshot that is not grayscale displayed if the length of the preset list in the detection result is not 0.
[0264] The first obtaining module is configured to obtain the page control information of each control of the mobile client and the picture resolution of the screenshot when the detection result is a screenshot that is not grayscale displayed.
[0265] The second determination module is configured to determine the resolution coordinates and the size of each control of the mobile client based on the page control information.
[0266] The third determination module is configured to determine the initial coordinate value of the control based on the picture resolution.
[0267] The splitting module is configured to split the screenshot through the initial coordinate value and the size of each control to obtain pictures corresponding to each control, and name the pictures corresponding to each control as control IDs.
[0268] The second obtaining module is configured to obtain the paths of the pictures corresponding to each control, and generate a control screenshot list through the paths of the pictures corresponding to each control and the control IDs.
[0269] Further, the page grayscale detection system of the mobile client further includes a first determination unit.
[0270] The first determination unit is configured to determine the business to which each control belongs.
[0271] Further, the page grayscale detection system of the mobile client further includes a storage unit.
[0272] The storage unit is configured to store the screenshot in a preset form to a preset specified path.
[0273] Further, the page grayscale detection system of the mobile client further includes a second determination unit.
[0274] The second determination unit is configured to determine that the detection result is a screenshot that is grayscale displayed if the length of the preset list in the detection result is 0.
[0275] Further, the page grayscale detection system of the mobile client further includes a generating unit.
[0276] The generating unit is used to generate a grayscale result report if the detection result is a screenshot of a grayscale display.
[0277] In the embodiment of the present application, it is not necessary to manually detect all pages and controls of the APP of the mobile client. By simulating user operations to access all pages and take screenshots, if there are ungrayscaled parts in the screenshots, grayscale detection is performed on the screenshots of each page control in the obtained control screenshot list to determine which control's picture is not grayscaled, and automatic grayscale recognition of the next page is performed, improving the test efficiency and test quality of the picture grayscaling of the mobile client and reducing the human test cost.
[0278] The embodiment of the present application further provides a storage medium, which includes stored instructions. When the instructions run, the device where the storage medium is located is controlled to execute the above-mentioned page grayscale detection method of the mobile client.
[0279] The embodiment of the present application further provides an electronic device, and its structural schematic diagram is as Figure 3 shown, specifically including a memory 301 and one or more instructions 302. One or more instructions 302 are stored in the memory 301 and are configured to be executed by one or more processors 303 to execute the above-mentioned page grayscale detection method of the mobile client.
[0280] The specific implementation processes and their derivative methods of the above-mentioned various embodiments are all within the protection scope of the present application.
[0281] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the key points of each embodiment are the differences from other embodiments. In particular, for a system or a system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The systems and system embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement without creative efforts.
[0282] Those skilled in the art may further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered as exceeding the scope of this application.
[0283] The above description of the disclosed embodiments enables those skilled in the art to implement or use this application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the scope of this application. Therefore, this application will not be limited to these embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0284] The above are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of this application.
Claims
1. A method for detecting grayscale display of pages on a mobile client, characterized in that, the method includes: Obtain a screenshot of the mobile client; Perform grayscale detection on the screenshot through a preset grayscale detection method to obtain a detection result in a preset data format, including: encode the screenshot through a preset encoding format to obtain encoded data; encrypt the encoded data through a preset encryption method to obtain a picture string of the screenshot; decode the picture string through a preset decoding method to obtain decoded data corresponding to the picture string; convert the decoded data into a picture, and perform grayscale recognition processing on the picture to obtain a detection result; the detection result is used to determine whether the screenshot is a screenshot with grayscale display; If the detection result is a screenshot without grayscale display, obtain a list of control screenshots; the list of control screenshots is used to store screenshots of each page control of the mobile client; Perform grayscale detection on the screenshots of each page control in the list of control screenshots, including: identify the grayscale pictures of the screenshots of each page control. If there are ungrayed parts in the screenshots of each page control, at least split the screenshots according to the screen resolution and control size, perform grayscale recognition, determine the pictures of the controls that are not grayed, generate a test result, and continue the grayscale detection of the next page.
2. The method according to claim 1, characterized in that, the obtaining of the screenshot of the mobile client includes: Obtain a screenshot of the mobile client through a preset screenshot method.
3. The method according to claim 1, characterized in that, if the detection result is a screenshot without grayscale display, the obtaining of the list of control screenshots includes: If the length of the preset list in the detection result is not 0, determine that the detection result is a screenshot without grayscale display; When the detection result is a screenshot without grayscale display, obtain the page control information of each control of the mobile client and the picture resolution of the screenshot; Based on the page control information, determine the resolution coordinates and sizes of each control of the mobile client; Based on the picture resolution, determine the initial coordinate values of the controls; Divide the screenshot through the initial coordinate values and the sizes of each control to obtain pictures corresponding to each control, and name the pictures corresponding to each control as control IDs; Obtain the paths of the pictures corresponding to each control, and generate a list of control screenshots through the paths of the pictures corresponding to each control and the control IDs.
4. The method according to claim 3, characterized in that, further includes: Determine the business to which each control belongs.
5. The method according to claim 3, characterized in that, further includes: Store the screenshot in a preset specified path in a preset form.
6. The method according to claim 1, characterized in that, further includes: If the length of the preset list in the detection result is 0, determine that the detection result is a screenshot with grayscale display.
7. The method according to claim 6, wherein, it further comprises: if the detection result is a screen capture presented in grayscale, generating a grayscale result report.
8. A page grayscale detection system for a mobile client, wherein, the system comprises: a first acquisition unit configured to acquire a screen capture of the mobile client; a first detection unit configured to perform screen capture grayscale detection on the screen capture by a preset grayscale detection method to obtain a detection result in a preset data format; the detection result is used to determine whether the screen capture is a screen capture presented in grayscale; the first detection unit includes an encoding module, an encryption module, and a decoding module; the encoding module is configured to encode the screen capture by a preset encoding format to obtain encoded data; the encryption module is configured to encrypt the encoded data by a preset encryption method to obtain a picture string of the screen capture; the decoding module is configured to decode the picture string by a preset decoding method to obtain decoded data corresponding to the picture string; convert the decoded data into a picture, perform grayscale recognition processing on the picture to obtain a detection result; a second acquisition unit configured to, if the detection result is a screen capture not presented in grayscale, acquire a list of control screenshots; the list of control screenshots is used to store screenshots of each page control of the mobile client; a second detection unit configured to perform grayscale detection on screenshots of each page control in the list of control screenshots, including: recognizing grayscale pictures of screenshots of each page control, if there are un-grayscaled parts in the screenshots of each page control, at least splitting the screenshots according to the screen resolution and control size, performing grayscale recognition, determining pictures of controls that are not grayscaled, generating a test result, and continuing with grayscale detection of the next page.
9. The system according to claim 8, wherein, the first acquisition unit is specifically configured to: acquire a screen capture of the mobile client by a preset screenshot method.
Citation Information
Patent Citations
Method and device for testing user interface
CN108229485A