APP response time testing method and device based on image comparison and related medium

Through an image comparison method, using an automated test framework and screenshot API, the screenshots of the APP are compared in reverse order to accurately calculate the response time, which solves the problems of low accuracy and high cost of the existing test methods, and achieves more efficient APP response time test.

CN119226162APending Publication Date: 2024-12-31SHENZHEN FIFTH SPACE NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411293758.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The existing APP response time testing methods have problems with low accuracy and high testing costs, especially manual image comparison and program image comparison are prone to errors, and the camera and screenshot methods require resource consumption, resulting in increased testing costs.

Method used

采用基于图像对比的APP响应时间测试方法,通过与测试设备和摄像设备建立数据连接,利用自动化测试框架启动APP,获取屏幕信息并进行截屏操作,倒序图像对比以确定APP的最后一次界面变化时间,计算响应时间。

Benefits of technology

It improves the accuracy of APP response time testing, reduces testing costs, and reduces manual errors and equipment resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226162A_ABST
    Figure CN119226162A_ABST
Patent Text Reader

Abstract

The invention discloses an APP response time testing method and device based on image comparison and a related medium, which are applied to a PC (Personal Computer) end, and the method comprises the following steps: respectively establishing data connection with testing equipment and camera equipment; the camera equipment is used for capturing screen information of the test equipment; starting the APP on the test equipment and recording the starting time; obtaining screen information and performing screen capture operation to obtain a plurality of screen capture pictures; performing image comparison with a preset image forwards in sequence according to the reverse order of the screen capture time to obtain a final screen capture image; obtaining the end time of the APP based on the final screenshot picture; and calculating the time difference between the starting time and the ending time to obtain the response time of the APP. According to the method and the device, the screen information of the test equipment is captured through the camera equipment, the screen information is subjected to screen capture comparison to obtain the final screen capture picture, and finally the response time is calculated according to the screen capture time of the final screen capture picture and the starting time of the APP, so that the test accuracy of the APP response time is improved, and meanwhile, the test cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to an APP response time testing method and device based on image comparison and related media thereof. Background Art

[0002] There are many mobile APP performance test indicators, which are divided into response time and resource consumption. Among them, the APP response time has the greatest impact on user experience. At present, the test method of APP response time is to use video or screenshot, and then manually compare images or use programs to compare images, but these methods have defects: the video method requires high-speed camera equipment, and the screenshot method consumes the computing resources of the test equipment. Both methods will increase the test cost; and manual image comparison and program image comparison will produce errors, resulting in reduced test accuracy. Therefore, a new APP response time test method is urgently needed to solve the problem of low test accuracy and reduce test costs. Summary of the invention

[0003] The embodiments of the present invention provide an APP response time testing method, a device and related media based on image comparison, aiming to solve the problems of low test accuracy and high test cost of APP response time in the prior art.

[0004] In a first aspect, an embodiment of the present invention provides an APP response time testing method based on image comparison, which is applied to a PC side and includes:

[0005] Establishing data connections with a test device and a camera device respectively; wherein the camera device is used to capture screen information of the test device;

[0006] Using the automated testing framework to start the APP on the test device, and record the start time of the APP;

[0007] Acquire the screen information, and use the screenshot API to perform a screenshot operation on the screen information to obtain multiple screenshot images; wherein the multiple screenshot images are arranged in the order of the screenshot time;

[0008] Starting from the last screenshot, compare the screenshots with the preset pictures in reverse order of the screenshot time to obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot;

[0009] Based on the final screenshot image, the corresponding screenshot time is obtained and used as the end time of the APP;

[0010] The time difference between the start time and the end time is calculated to obtain the response time of the APP.

[0011] In a second aspect, an embodiment of the present invention provides an APP response time testing device based on image comparison, comprising:

[0012] A data connection unit, used to establish data connections with a test device and a camera device respectively; wherein the camera device is used to capture screen information of the test device;

[0013] A device startup unit, used to start the APP on the test device using the automated testing framework and record the startup time of the APP;

[0014] A screenshot acquisition unit, used to acquire the screen information, and perform a screenshot operation on the screen information using a screenshot API to obtain a plurality of screenshot images; wherein the plurality of screenshot images are arranged in the order of the screenshot time;

[0015] An image comparison unit is used to compare images with preset images starting from the last screenshot and in reverse order of screenshot time, to obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot;

[0016] A time acquisition unit, used to acquire the corresponding screenshot time based on the final screenshot image and use it as the end time of the APP;

[0017] The data calculation unit is used to calculate the time difference between the start time and the end time to obtain the response time of the APP.

[0018] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image comparison-based APP response time testing method of the first aspect when executing the computer program.

[0019] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the APP response time testing method based on image comparison according to the first aspect is implemented.

[0020] The embodiment of the present invention provides an APP response time test method based on image comparison, which is applied to the PC side, including establishing data connections with a test device and a camera device respectively; the camera device is used to capture the screen information of the test device; the APP on the test device is started and the startup time is recorded; the screen information is obtained and the screen information is captured using a screenshot API to obtain multiple screenshots; starting from the last screenshot, the image is compared with the preset image in reverse order of the screenshot time, and the screenshot of the last change of the APP application interface on the test device is obtained, and it is marked as the final screenshot; based on the final screenshot, the corresponding screenshot time is obtained and used as the end time of the APP; the time difference between the startup time and the end time is calculated to obtain the response time of the APP. The present invention captures the screen information of the test device through a camera device, and compares the screen information to obtain the final screenshot of the last change of the APP application interface on the test device, and finally calculates the response time according to the screenshot time of the final screenshot and the startup time of the APP, so that the test accuracy of the APP response time is improved and the test cost is reduced.

[0021] The embodiment of the present invention also provides an APP response time testing device, a computer device and a storage medium based on image comparison, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0023] Figure 1 A schematic diagram of a flow chart of an APP response time testing method based on image comparison provided by an embodiment of the present invention;

[0024] Figure 2 Another schematic diagram of a flow chart of an APP response time testing method based on image comparison provided by an embodiment of the present invention;

[0025] Figure 3 A schematic diagram of a process of image comparison provided by an embodiment of the present invention;

[0026] Figure 4 A schematic block diagram of an APP response time testing device based on image comparison provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0028] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0029] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0030] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0031] See below Figure 1 , Figure 1 A schematic flow chart of an APP response time test based on image comparison provided in an embodiment of the present invention specifically includes: steps S101 to S106.

[0032] S101, establishing data connections with a test device and a camera device respectively; wherein the camera device is used to capture screen information of the test device;

[0033] S102: Start the APP on the test device using the automated testing framework, and record the start time of the APP;

[0034] S103, obtaining the screen information, and performing a screenshot operation on the screen information using a screenshot API to obtain a plurality of screenshot images; wherein the plurality of screenshot images are arranged in the order of the screenshot time;

[0035] S104, starting from the last screenshot, compare the screenshots with the preset pictures in reverse order of the screenshot time, obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot;

[0036] S105, obtaining a corresponding screenshot time based on the final screenshot image, and using it as the end time of the APP;

[0037] S106: Calculate the time difference between the start time and the end time to obtain the response time of the APP.

[0038] Combination Figure 2 As shown, in step S101, it is necessary to establish a data connection first, connected to the test device and the camera device respectively. The test device refers to a mobile device running the APP to be tested, and the camera device is an external device for capturing the screen information of the test device, such as a digital camera. The test device is connected to the PC side via an appropriate interface (such as USB, HDMI or wireless network, etc.) to receive test instructions in real time. The camera device can establish a connection with the PC side via a USB or Wi-Fi connection to ensure that the screen information of the test device can be captured in real time. The camera device needs to have sufficient resolution and frame rate to accurately record the changes on the test device screen, thereby supporting subsequent image comparison and analysis.

[0039] To ensure a clean test environment, you can use an external camera (or a built-in camera on the PC) to record the screen of the test device instead of recording the screen directly on the test device. This is to avoid situations that may affect the test device during the test, such as additional software load or hardware contact.

[0040] In step S102, the APP to be tested is installed on the test device and started through the automated testing framework. The automated testing framework, such as Appium, MonkeyRunner or other automated testing frameworks that support mobile device operations, is responsible for sending instructions to the test device to control the startup process of the APP. At the beginning of the operation, the automated testing framework sends a startup instruction to the test device through the programming interface, commanding the APP on the test device to start. This startup instruction includes the specified APP package name and activity name (Activity Name) to ensure that the main interface of the target APP can be directly started. While sending the startup instruction, the test framework records the system time at that moment as the start time of the APP startup. This time point is obtained by synchronizing to the time system on the PC to ensure the accuracy of the time record.

[0041] In one embodiment, the step S102 includes:

[0042] Using MonkeyRunner driver to send simulated control instructions to the test device to start the APP on the test device;

[0043] The time module is used to record the startup time of the APP on the test device.

[0044] In this embodiment, MonkeyRunner is a framework that provides automated testing support for test equipment, and can send instructions simulating user operations to the test equipment. After the PC is connected to the test equipment, use the MonkeyRunner-driven API to write a script to specify the package name and activity name (ActivityName) of the APP to be started. Then, by executing these scripts, MonkeyRunner simulates operations such as user clicking icons to trigger the startup of the APP. At the same time, the recording of the startup time is achieved by embedding a time module in the MonkeyRunner-driven script. The specific operation is to use Python's time module to obtain a timestamp before and after sending the instruction to start the APP. Record the exact time of sending the startup instruction as the startup start time.

[0045] In step S103, the PC obtains the content (i.e., screen information) displayed on the screen of the current test device through the communication interface with the camera device, and uses a screenshot API (such as Windows API) to perform a screenshot operation on the acquired screen information. For example, the PrintWindow function in Windows API is used or a combination of GetDC and BitBlt is used to capture the window content. However, considering the performance and screenshot frequency, it is more efficient to use GDI+ (Graphics Device Interface Plus) or WIC (Windows Imaging Component).

[0046] Furthermore, the screen information is continuously captured through the screenshot API to obtain a series of screenshots. The screenshot operation can be set to be timed or triggered according to the test needs. For example, in an automated test script, a screenshot operation can be set to be performed at a certain interval (such as every 20 milliseconds) to capture the continuous screen change process. The screenshots obtained will be sorted in the chronological order of the screenshots. The specific time of the screenshot is recorded in the file name or metadata of each picture to ensure that the subsequent analysis can process these pictures in chronological order.

[0047] In one embodiment, the step S103 includes:

[0048] Controlling the camera device to capture screen information of the test device;

[0049] Performing a screenshot operation on the screen information using the screenshot API according to a preset screenshot frequency to obtain a plurality of the screenshot images, and caching the plurality of the screenshot images into a memory;

[0050] After the test is finished, the formats of the plurality of screenshot images in the memory are converted and written to the disk.

[0051] In the present embodiment, the camera device is configured and started to capture the screen information of the test device. The camera device should be aligned with the display screen of the test device to ensure that all activities occurring on the screen can be clearly recorded. The camera device is connected to the PC end through an appropriate interface (such as USB or network interface) to transmit the captured video data in real time. The screen information is captured using the screenshot API according to the preset screenshot frequency. In order to increase the processing speed and reduce the read and write operations, the screenshot images of all screenshots are first cached in the memory of the PC end, which can quickly process and analyze the screenshot images while avoiding the performance bottlenecks that may be caused by frequent disk I / O operations. After the test is completed, the screenshot images cached in the memory will be converted to a format, such as from the original image format to a format with a higher compression ratio (such as JPEG or PNG) to optimize storage efficiency. The converted images will be written to the disk in batches.

[0052] In one embodiment, the screenshot operation of the screen information is performed using the screenshot API according to a preset screenshot frequency to obtain a plurality of the screenshot images, including:

[0053] Set the frequency of the timer to the screenshot frequency through the SetTimer function or the System.Threading.Timer class;

[0054] The screenshot API is called according to the triggering times of the timer to perform a screenshot operation on the screen information to obtain a plurality of the screenshot pictures.

[0055] In this embodiment, in order to realize the timed screenshot, a timer is first set by programming. In the Windows operating system, the SetTimer function can be used to set the timer; in the .NET environment, the System.Threading.Timer class can be used to implement it. The frequency of the timer is set to the preset screenshot frequency. For example, if a screenshot is required every 20 milliseconds, the timer is set to trigger every 20 milliseconds. The timer is triggered according to the set frequency. Whenever the timer is triggered, a callback function or event handler is executed, and the event handler calls the screenshot API to capture the status of the current screen. After each successful call to the screenshot API, the captured screenshot image will be saved as an image file.

[0056] In one embodiment, converting the formats of the plurality of screenshot images in the memory and writing them to the disk includes:

[0057] Obtain the screenshot time corresponding to the plurality of screenshot images and format them into a time string to obtain a timestamp;

[0058] Combine the timestamp with the APP test case name on the test device to obtain a screenshot file name;

[0059] Each of the screenshot images is saved to a specified disk location and named with the screenshot file name.

[0060] In this embodiment, the screenshot time corresponding to each screenshot image is obtained from the memory, and these time data usually exist in numerical form, indicating the specific moment when the screenshot occurs. These time data are formatted into standard time strings, such as "YYYY-MM-DD_HH-MM-SS-MS", so as to provide a clear time mark for subsequent operations. The formatted time string is combined with the name of the current APP test case. Such a combination ensures the uniqueness of the file name and facilitates subsequent retrieval and analysis. For example, the file name can be set to "TestAppName_20200930_235959_999.png", which contains the application name, date and time specific to milliseconds. Finally, the formatted and named screenshot image is saved to the specified disk location. During the saving process, an appropriate image format (such as JPEG or PNG) can be selected for format conversion to optimize storage space and improve read and write efficiency. Each picture is saved according to its generated file name, which not only helps to maintain the orderliness of storage, but also facilitates quick access and processing in the future.

[0061] In step S104, after all screenshot operations are completed, the captured pictures are arranged in reverse order according to the screenshot time. That is, the last screenshot picture is placed at the top of the sequence, and arranged forward in sequence until the end of the sequence is the picture of the first screenshot. Starting from the first screenshot picture in the sequence (i.e., the last screenshot), image comparison is performed one by one with the preset reference picture. Image comparison can use a variety of algorithms, such as the hash-based perceptual image hash algorithm (pHash) or other similarity detection technology to evaluate the similarity between two pictures. During the comparison process, continue to check each picture forward until a screenshot picture that matches the preset picture is found. This picture is used as the screenshot of the last significant change in the application interface and is marked as the final screenshot picture.

[0062] Combination Figure 3 As shown, in one embodiment, the step S104 includes:

[0063] Reducing each of the screenshots to a specified size to obtain a corresponding reduced screenshot;

[0064] Performing grayscale conversion on each of the reduced screenshot images to obtain a grayscale conversion value corresponding to each pixel in each of the reduced screenshot images;

[0065] For each of the reduced screenshot images, the grayscale average value of the grayscale conversion values ​​of all pixels is calculated, and each of the grayscale conversion values ​​is compared with the grayscale average value; if the grayscale conversion value is greater than or equal to the grayscale average value, the corresponding pixel is set to a first value; if the grayscale conversion value is less than the grayscale average value, the corresponding pixel is set to a second value;

[0066] Integrate all the set values ​​corresponding to each pixel of each of the reduced screenshot images to obtain a hash value corresponding to each of the screenshot images;

[0067] The hash value of each screenshot image is compared with the hash value corresponding to the preset image for similarity, and the hash value most similar to the hash value corresponding to the preset image is obtained to obtain the corresponding final screenshot image.

[0068] In this embodiment, when there are many texts in the interface, the image outline can also be obtained to increase the denoising and lifting effect, and then each captured screenshot image is reduced to a predetermined size to reduce the computational load of subsequent processing. This can be achieved through image processing software or libraries (such as Python's Pillow library) to ensure that the image retains the maximum possible retention of key visual information during the reduction process. Grayscale conversion is performed on each reduced screenshot image to convert the color image into a grayscale image. Grayscale conversion helps to simplify image data, making subsequent processing more efficient. During the conversion process, the color value of each pixel will be converted to a corresponding grayscale value. For each grayscale image, the grayscale average of all pixels is calculated. Then, according to the comparison result of the grayscale value of each pixel with the grayscale average, a set operation is performed: if the grayscale value of a pixel is greater than or equal to the average grayscale value, the first value (for example, 1) is set in the corresponding pixel position; if it is less than the average grayscale value, the second value (for example, 0) is set in the corresponding pixel position. Through the above-mentioned setting process, each grayscale image is converted into a string of binary numbers (hash values). This hash value represents the basic visual content of the image and is highly tolerant to small changes in the image.

[0069] After the image is collected, the perceptual hashing algorithm (pHash) is used for image comparison. pHash is an effective method for detecting image similarity. It converts the image into the frequency domain, extracts features and calculates hash values, and finally compares the hash values ​​of two images to determine whether they are similar. The pHash algorithm can effectively ignore local noise and subtle changes in the image and only focus on the overall structure and content of the image, which is closer to the characteristics of the human visual system when recognizing images. Therefore, even if there are slight color differences or local changes between the images, as long as the overall structure remains unchanged, the image comparison results can still be considered that the two images are the same or very similar.

[0070] Finally, the hash value generated by each screenshot is compared with the hash value of the preset image for similarity. The comparison can be achieved by calculating the number of different bits between the two hash values ​​(similar to the Hamming distance). The screenshot corresponding to the hash value that is most similar to the hash value of the preset image is the final screenshot.

[0071] In one embodiment, comparing the hash value of each screenshot image with the hash value corresponding to the preset image for similarity, obtaining the hash value most similar to the hash value corresponding to the preset image, and obtaining the corresponding final screenshot image includes:

[0072] Compare the hash values ​​of the preset images with the hash values ​​of each of the screenshot images to obtain multiple hash value results;

[0073] Filter the hash value results that meet the hash value range according to a preset hash value range to obtain an expected hash value result;

[0074] The screenshot image corresponding to the highest similarity among the expected hash value results is selected and used as the final screenshot image.

[0075] In this embodiment, the hash value of the preset image is compared with the hash value of each screenshot image. This comparison is achieved by calculating the hash value between each pair of hash values, which is similar to the Hamming distance, which can represent the number of different bits between two hash values. Each comparison obtains a specific hash value result, which reflects the similarity of the two images in visual content. Next, according to the preset hash value range (for example, the hash value result is less than or equal to a certain value), the hash value results that meet the range are screened out. From the screened hash value results, the screenshot corresponding to the result with the highest similarity is further selected. The highest similarity is similar to the case with the smallest Hamming distance, that is, the screenshot with the smallest difference in hash value from the preset image, and this picture will be used as the final screenshot.

[0076] In step S105, the screenshot image that is most similar to the preset image, i.e., the final screenshot image, is determined by the aforementioned image processing and comparison method. After the final screenshot image is determined, the screenshot time is extracted from the file information or associated metadata of the final screenshot image. The screenshot time is usually recorded when the image is generated, included in the file name or metadata of the image file, indicating the specific moment when the image was captured. The extracted screenshot time is defined as the end time of the APP. This time point marks the end of the APP response process, that is, the time interval from the user triggering the event to the APP interface reaching the expected final stable state.

[0077] In step S106, the start time and end time of the APP are obtained. The start time is the moment when the APP starts to execute, which is usually recorded by the automated testing framework when the start instruction is sent. The end time is the timestamp of the final screenshot determined by image analysis, indicating the moment when the APP reaches the expected stable state. The time difference between the start time and the end time is calculated by subtracting the start time from the end time. This time difference, usually in seconds or milliseconds, can reflect the total response time required for the APP to go from startup to a stable state. The obtained response time is a key indicator for measuring the performance of the APP and is used to evaluate the startup efficiency and processing speed of the APP. The shorter the response time, the better the performance of the APP and the better the user experience.

[0078] Combination Figure 4 As shown, Figure 4 A schematic block diagram of an APP response time testing device based on image comparison provided by an embodiment of the present invention, wherein the APP response time testing device based on image comparison 400 includes:

[0079] The data connection unit 401 is used to establish data connections with the test device and the camera device respectively; wherein the camera device is used to capture the screen information of the test device;

[0080] The device startup unit 402 is used to start the APP on the test device using the automated testing framework and record the startup time of the APP;

[0081] The screenshot acquisition unit 403 is used to acquire the screen information and perform a screenshot operation on the screen information using a screenshot API to obtain a plurality of screenshot images; wherein the plurality of screenshot images are arranged in the order of the screenshot time;

[0082] The image comparison unit 404 is used to compare the images with the preset images in reverse order of the screenshot time starting from the last screenshot, to obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot;

[0083] A time acquisition unit 405 is used to acquire the corresponding screenshot time based on the final screenshot image and use it as the end time of the APP;

[0084] The data calculation unit 406 is used to calculate the time difference between the start time and the end time to obtain the response time of the APP.

[0085] In this embodiment, the data connection unit 401 establishes data connections with the test device and the camera device respectively; wherein the camera device is used to capture the screen information of the test device; the device startup unit 402 uses the automated testing framework to start the APP on the test device and records the startup time of the APP; the screenshot acquisition unit 403 acquires the screen information, and uses the screenshot API to perform a screenshot operation on the screen information to obtain multiple screenshot images; wherein the multiple screenshot images are arranged in the order of screenshot time; the image comparison unit 404 starts from the last screenshot image, and compares the image with the preset images in reverse order of the screenshot time, to obtain the screenshot image of the last change of the APP application interface on the test device, and marks it as the final screenshot image; the time acquisition unit 405 obtains the corresponding screenshot time based on the final screenshot image, and uses it as the end time of the APP; the data calculation unit 406 calculates the time difference between the startup time and the end time to obtain the response time of the APP.

[0086] In one embodiment, the device startup unit 402 includes:

[0087] A driver startup unit, used to send a simulated control instruction to the test device using the MonkeyRunner driver to start the APP on the test device;

[0088] The time recording unit is used to record the startup time of the APP on the test device using the time module.

[0089] In one embodiment, the screenshot acquisition unit 403 includes:

[0090] A screen capture unit, used for controlling the camera to capture screen information of the test device;

[0091] A screen capture unit, used to perform a screen capture operation on the screen information using the screen capture API according to a preset screen capture frequency, obtain a plurality of the screen capture pictures, and cache the plurality of the screen capture pictures into a memory;

[0092] The picture saving unit is used to convert the format of the multiple screenshot pictures in the memory and write them to the disk after the test is completed.

[0093] In one embodiment, the screen capture unit includes:

[0094] A screenshot setting unit, used to set the frequency of the timer to the screenshot frequency through the SetTimer function or the System.Threading.Timer class;

[0095] The timed screenshot unit is used to call the screenshot API to perform a screenshot operation on the screen information according to the number of times the timer is triggered, so as to obtain multiple screenshot pictures.

[0096] In one embodiment, the picture saving unit includes:

[0097] A picture format unit, used for obtaining the screenshot time corresponding to the plurality of screenshot pictures and formatting it into a time string to obtain a timestamp;

[0098] A name setting unit, used to combine the timestamp with the APP test case name on the test device to obtain a screenshot file name;

[0099] The picture naming unit is used to save each screenshot picture to a specified disk location and name it with the screenshot file name.

[0100] In one embodiment, the image comparison unit 404 includes:

[0101] A picture reduction unit, used to reduce each of the screenshot pictures to a specified size to obtain a corresponding reduced screenshot picture;

[0102] A grayscale conversion unit, used to perform grayscale conversion on each of the reduced screenshot images to obtain a grayscale conversion value corresponding to each pixel in each of the reduced screenshot images;

[0103] an average calculation unit, for calculating the grayscale average value of the grayscale conversion values ​​of all pixels of each of the reduced screenshot images, and comparing each of the grayscale conversion values ​​with the grayscale average value; if the grayscale conversion value is greater than or equal to the grayscale average value, setting the corresponding pixel to a first value; if the grayscale conversion value is less than the grayscale average value, setting the corresponding pixel to a second value;

[0104] A hash acquisition unit, used to integrate all the set values ​​corresponding to each pixel of each of the reduced screenshot images to obtain a hash value corresponding to each of the screenshot images;

[0105] The hash comparison unit is used to compare the hash value of each screenshot image with the hash value corresponding to the preset image to obtain the hash value most similar to the hash value corresponding to the preset image, and obtain the corresponding final screenshot image.

[0106] In one embodiment, the hash comparison unit includes:

[0107] A value comparison unit, used to compare the hash value corresponding to the preset image with the hash value of each of the screenshot images to obtain multiple hash value results;

[0108] A range acquisition unit, configured to filter the hash value results that meet the preset hash value range according to the preset hash value range to obtain an expected hash value result;

[0109] The hash selection unit is used to select the screenshot image corresponding to the highest similarity in the expected hash value results and use it as the final screenshot image.

[0110] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0111] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0112] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.

[0113] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0114] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. An APP response time testing method based on image comparison, applied to a PC, characterized in that: include: Establishing data connections with a test device and a camera device respectively; wherein the camera device is used to capture screen information of the test device; Using the automated testing framework to start the APP on the test device, and record the start time of the APP; Acquire the screen information, and use the screenshot API to perform a screenshot operation on the screen information to obtain multiple screenshot images; wherein the multiple screenshot images are arranged in the order of the screenshot time; Starting from the last screenshot, compare the screenshots with the preset pictures in reverse order of the screenshot time to obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot; Based on the final screenshot image, the corresponding screenshot time is obtained and used as the end time of the APP; The time difference between the start time and the end time is calculated to obtain the response time of the APP.

2. The APP response time testing method based on image comparison according to claim 1 is characterized in that: Starting from the last screenshot, image comparison is performed with preset images in reverse order of screenshot time to obtain the screenshot of the last change of the APP application interface on the test device, and marking it as the final screenshot, including: Reducing each of the screenshots to a specified size to obtain a corresponding reduced screenshot; Performing grayscale conversion on each of the reduced screenshot images to obtain a grayscale conversion value corresponding to each pixel in each of the reduced screenshot images; For each of the reduced screenshot images, the grayscale average value of the grayscale conversion values ​​of all pixels is calculated, and each of the grayscale conversion values ​​is compared with the grayscale average value; if the grayscale conversion value is greater than or equal to the grayscale average value, the corresponding pixel is set to a first value; if the grayscale conversion value is less than the grayscale average value, the corresponding pixel is set to a second value; Integrate all the set values ​​corresponding to each pixel of each of the reduced screenshot images to obtain a hash value corresponding to each of the screenshot images; The hash value of each screenshot image is compared with the hash value corresponding to the preset image for similarity, and the hash value most similar to the hash value corresponding to the preset image is obtained to obtain the corresponding final screenshot image.

3. The APP response time testing method based on image comparison according to claim 2 is characterized in that: The step of comparing the hash value of each screenshot image with the hash value corresponding to the preset image to obtain the hash value most similar to the hash value corresponding to the preset image, and obtaining the corresponding final screenshot image includes: Compare the hash values ​​of the preset images with the hash values ​​of each of the screenshot images to obtain multiple hash value results; Filter the hash value results that meet the hash value range according to a preset hash value range to obtain an expected hash value result; The screenshot image corresponding to the highest similarity among the expected hash value results is selected and used as the final screenshot image.

4. The APP response time testing method based on image comparison according to claim 1 is characterized in that: The obtaining of the screen information and performing a screenshot operation on the screen information using a screenshot API to obtain a plurality of screenshot images include: Controlling the camera device to capture screen information of the test device; Performing a screenshot operation on the screen information using the screenshot API according to a preset screenshot frequency to obtain a plurality of the screenshot images, and caching the plurality of the screenshot images into a memory; After the test is finished, the formats of the plurality of screenshot images in the memory are converted and written to the disk.

5. The APP response time testing method based on image comparison according to claim 4 is characterized in that: The step of converting the formats of the plurality of screenshot images in the memory and writing them to the disk includes: Obtain the screenshot time corresponding to the plurality of screenshot images and format them into a time string to obtain a timestamp; Combine the timestamp with the APP test case name on the test device to obtain a screenshot file name; Each of the screenshot images is saved to a specified disk location and named with the screenshot file name.

6. The APP response time testing method based on image comparison according to claim 1 is characterized in that: The using of the automated testing framework to start the APP on the test device and recording the start time of the APP includes: Using MonkeyRunner driver to send simulated control instructions to the test device to start the APP on the test device; The time module is used to record the startup time of the APP on the test device.

7. The APP response time testing method based on image comparison according to claim 4 is characterized in that: The method of performing a screenshot operation on the screen information by using the screenshot API according to a preset screenshot frequency to obtain a plurality of screenshot images includes: Set the frequency of the timer to the screenshot frequency through the SetTimer function or the System.Threading.Timer class; The screenshot API is called according to the triggering times of the timer to perform a screenshot operation on the screen information to obtain a plurality of the screenshot pictures.

8. An APP response time testing device based on image comparison, characterized in that: include: A data connection unit, used to establish data connections with a test device and a camera device respectively; wherein the camera device is used to capture screen information of the test device; A device startup unit, used to start the APP on the test device using the automated testing framework and record the startup time of the APP; A screenshot acquisition unit, used to acquire the screen information, and perform a screenshot operation on the screen information using a screenshot API to obtain a plurality of screenshot images; wherein the plurality of screenshot images are arranged in the order of the screenshot time; An image comparison unit is used to compare images with preset images starting from the last screenshot and in reverse order of the screenshot time, to obtain the screenshot of the last change of the APP application interface on the test device, and mark it as the final screenshot; A time acquisition unit, used to acquire the corresponding screenshot time based on the final screenshot image and use it as the end time of the APP; The data calculation unit is used to calculate the time difference between the start time and the end time to obtain the response time of the APP.

9. A computer device, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the APP response time testing method based on image comparison as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the APP response time testing method based on image comparison as described in any one of claims 1 to 7 is implemented.