Movatterモバイル変換


[0]ホーム

URL:


CN111752817A - Method, device, device and storage medium for determining page loading time - Google Patents

Method, device, device and storage medium for determining page loading time
Download PDF

Info

Publication number
CN111752817A
CN111752817ACN202010615975.0ACN202010615975ACN111752817ACN 111752817 ACN111752817 ACN 111752817ACN 202010615975 ACN202010615975 ACN 202010615975ACN 111752817 ACN111752817 ACN 111752817A
Authority
CN
China
Prior art keywords
page
screenshot
loading
screenshots
time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010615975.0A
Other languages
Chinese (zh)
Inventor
高栋南
陈光辉
潘文杰
张亚南
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hanhai Information Technology Shanghai Co Ltd
Original Assignee
Hanhai Information Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hanhai Information Technology Shanghai Co LtdfiledCriticalHanhai Information Technology Shanghai Co Ltd
Priority to CN202010615975.0ApriorityCriticalpatent/CN111752817A/en
Publication of CN111752817ApublicationCriticalpatent/CN111752817A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本申请公开了一种页面加载时长的确定方法、装置、设备及存储介质,属于测试技术领域。所述方法包括:基于目标页面的页面地址,开始加载目标页面;在加载目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;对多个页面截图进行图像分析,以从多个页面截图中识别出加载开始页面截图和加载完成页面截图;基于加载开始页面截图的第一截图时间以及加载完成页面截图的第二截图时间,确定目标页面的加载时长。如此,提供了一种基于图像分析的页面加载时长确定方法,不依赖于Appium的自动化框架和元素定位机制即可实现,从而提高了页面加载时长的确定效率和准确率。

Figure 202010615975

The present application discloses a method, device, device and storage medium for determining page loading duration, which belong to the technical field of testing. The method includes: starting to load the target page based on the page address of the target page; in the process of loading the target page, continuously taking screenshots of the real-time display page to obtain multiple page screenshots and the screenshot time of each page screenshot; Perform image analysis on page screenshots to identify the loading start page screenshot and the loading completion page screenshot from multiple page screenshots; based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completion page screenshot, determine the Load time. In this way, a method for determining page loading duration based on image analysis is provided, which can be implemented without relying on Appium's automated framework and element positioning mechanism, thereby improving the efficiency and accuracy of determining page loading duration.

Figure 202010615975

Description

Translated fromChinese
页面加载时长的确定方法、装置、设备及存储介质Method, device, device and storage medium for determining page loading time

技术领域technical field

本申请涉及测试技术领域,特别涉及一种页面加载时长的确定方法、装置、设备及存储介质。The present application relates to the technical field of testing, and in particular, to a method, apparatus, device and storage medium for determining page loading duration.

背景技术Background technique

页面加载时长是指页面从开始加载到加载完成使用的时长,即从页面被打开到该页面完整显示出来使用的时长,用于指示页面加载耗时,是衡量终端性能一个重要参数。The page loading time refers to the time from when the page is loaded to when the page is loaded, that is, the time from when the page is opened to when the page is fully displayed.

相关技术中,主要依赖Appium(一种自动化测试开源工具)对待测试的目标网页进行测速,并将目标页面中的指定页面元素加载出现作为目标页面加载完成的标志,来确定目标页面的加载时长。具体地,在页面测试过程中,当检测到对目标页面的页面入口的触发操作时,开始加载目标页面,并在加载目标页面的过程中,通过Appium遍历实时显示页面的层级结构,来查找实时显示页面的层级结构中是否包括指定页面元素。如果当前显示页面的层级结构中包括指定页面元素,则确定当前显示页面中出现了指定页面元素,进而确定目标页面加载完成。然后,确定加载完成时间,将加载完成时间与页面入口的触发时间之间的时长,确定为目标页面的加载时长。In the related art, Appium (an open source tool for automated testing) is mainly used to measure the speed of the target web page to be tested, and the loading and appearance of a specified page element in the target page is used as a sign that the target page is loaded to determine the loading time of the target page. Specifically, in the page testing process, when a trigger operation on the page entry of the target page is detected, the target page starts to be loaded, and during the process of loading the target page, Appium traverses the hierarchical structure of the real-time display page to find the real-time display page. Whether the specified page element is included in the hierarchy of the displayed page. If the hierarchical structure of the currently displayed page includes the specified page element, it is determined that the specified page element appears in the currently displayed page, and then it is determined that the loading of the target page is completed. Then, the loading completion time is determined, and the duration between the loading completion time and the triggering time of the page entry is determined as the loading duration of the target page.

但是,通过Appium遍历页面层级结构的过程较为复杂,当目标页面的层级结构过多时,遍历过程耗时较久,测试效率较低。而且,将指定页面元素加载出现作为目标页面加载完成的标志,来确定页面加载时长的方式准确率也较低,比如,当指定页面元素加载出现但其他页面元素尚未出现时,目标页面实际并未加载完成,这种情况下确定出的加载时长并不准确。However, the process of traversing the page hierarchy through Appium is more complicated. When there are too many hierarchical structures of the target page, the traversal process takes a long time and the test efficiency is low. Moreover, the method of determining the loading time of the page by taking the loading of the specified page element as a sign that the loading of the target page is completed is also less accurate. For example, when the loading of the specified page element appears but other page elements have not yet appeared, the target page does not actually appear The loading is complete, and the determined loading time in this case is not accurate.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种页面加载时长的确定方法、装置、设备及存储介质,可以用于解决相关技术中存在的测试效率较低以及测试结果可能不准确的问题。所述技术方案如下:The embodiments of the present application provide a method, apparatus, device, and storage medium for determining page loading duration, which can be used to solve the problems of low test efficiency and possibly inaccurate test results in the related art. The technical solution is as follows:

一方面,提供了一种页面加载时长的确定方法,所述方法包括:In one aspect, a method for determining page loading duration is provided, the method comprising:

基于目标页面的页面地址,开始加载所述目标页面,所述目标页面为待确定加载时长的页面;Start loading the target page based on the page address of the target page, where the target page is a page whose loading duration is to be determined;

在加载所述目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;In the process of loading the target page, continuous screenshots are taken on the real-time display page to obtain multiple page screenshots and the screenshot time of each page screenshot;

对所述多个页面截图进行图像分析,以从所述多个页面截图中识别出加载开始页面截图和加载完成页面截图;Perform image analysis on the multiple page screenshots to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots;

基于所述加载开始页面截图的第一截图时间和所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长。The loading duration of the target page is determined based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.

可选地,所述对所述多个页面截图进行图像分析,包括:Optionally, performing image analysis on the multiple page screenshots includes:

基于所述多个页面截图中相邻页面截图的图像指纹差异,确定所述加载开始页面截图,每个页面截图的图像指纹用于指示对应页面截图;Determine the screenshot of the loading start page based on the difference in image fingerprints of the screenshots of adjacent pages in the multiple page screenshots, and the image fingerprint of each page screenshot is used to indicate the corresponding page screenshot;

基于所述多个页面截图中位于末尾页面截图之前的页面截图与所述末尾页面截图之间的图像指纹差异,确定所述加载完成页面截图。Based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page among the screenshots of the multiple pages, the screenshot of the page after loading is determined.

可选地,所述基于所述多个页面截图中相邻页面截图的图像指纹差异,确定所述加载开始页面截图,包括:Optionally, determining the screenshot of the loading start page based on the image fingerprint difference of the screenshots of adjacent pages among the multiple page screenshots includes:

按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图;According to the sequence of the screenshot time from front to back, successively obtain screenshots of adjacent pages from the plurality of page screenshots;

每获取到一对相邻页面截图,则确定获取的相邻页面截图中每个页面截图的图像指纹;Each time a pair of adjacent page screenshots are obtained, determine the image fingerprint of each page screenshot in the obtained adjacent page screenshots;

若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异小于或等于第一差异阈值,则返回按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图的步骤;If, based on the obtained image fingerprints of each page screenshot in the adjacent page screenshots, it is determined that the difference between the obtained image fingerprints of the adjacent page screenshots is less than or equal to the first difference threshold, then return the screenshots in the order from front to back. , the steps of successively obtaining screenshots of adjacent pages from the multiple page screenshots;

若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异大于第一差异阈值,则将所述获取的相邻页面截图中的任一页面截图确定为所述加载开始页面截图。If it is determined based on the image fingerprint of each page screenshot in the obtained adjacent page screenshots that the difference between the image fingerprints of the obtained adjacent page screenshots is greater than the first difference threshold, A screenshot of any page is determined to be a screenshot of the loading start page.

可选地,所述基于所述多个页面截图中位于末尾页面截图之前的页面截图与所述末尾页面截图之间的图像指纹差异,确定所述加载完成页面截图,包括:Optionally, the determining the loading completed page screenshot based on the image fingerprint difference between the page screenshot before the last page screenshot and the last page screenshot among the plurality of page screenshots includes:

按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图;According to the sequence of the screenshot time from back to front, sequentially obtain page screenshots from the page screenshots located before the last page screenshot included in the plurality of page screenshots;

每获取到一个页面截图,则将获取的页面截图作为第一页面截图,确定所述第一页面截图的图像指纹;Each time a page screenshot is obtained, the obtained page screenshot is taken as the first page screenshot, and the image fingerprint of the first page screenshot is determined;

若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异小于或等于第二差异阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤;If, based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is less than or equal to the second difference threshold, then return to the screen according to the screenshot. In the order of time from back to front, the steps of sequentially acquiring page screenshots from the page screenshots located before the last page screenshot included in the multiple page screenshots;

若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异大于第二差异阈值,则将位于所述第一页面截图之后的第二页面截图确定为所述加载完成页面截图。If it is determined based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold The second page screenshot after the one page screenshot is determined to be the loading completed page screenshot.

可选地,所述将位于所述第一页面截图之后的第二页面截图确定为所述加载完成页面截图之前,还包括:Optionally, determining the second page screenshot after the first page screenshot as before the loading completed page screenshot further includes:

确定所述第二页面截图与所述末尾页面截图之间的指定图像差异指标,所述指定图像差异指标包括差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值中的至少一种;Determine the specified image difference index between the screenshot of the second page and the screenshot of the last page, where the specified image difference index includes the pixel ratio of the difference pixels, the difference between the pixel mean values of the difference image part, and the pixels of the difference image part at least one of the differences in standard deviations;

若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则执行将所述第二页面截图确定为所述加载开始页面截图的步骤。If the specified image difference index between the second page screenshot and the last page screenshot is less than or equal to the corresponding index threshold, the step of determining the second page screenshot as the loading start page screenshot is performed.

可选地,所述确定所述第一页面截图与所述末尾页面截图之间的指定图像差异指标之后,还包括:Optionally, after determining the specified image difference index between the screenshot of the first page and the screenshot of the last page, the method further includes:

若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤。If the specified image difference index between the screenshot of the second page and the screenshot of the last page is greater than the corresponding index threshold, return to the order of the screenshot time from the back to the front, from the screenshots of the multiple pages including those located in the Follow the steps to obtain page screenshots in the page screenshot before the last page screenshot.

可选地,所述在加载所述目标页面的过程中,对实时显示页面进行连续截图,包括:Optionally, during the process of loading the target page, continuous screenshots are taken of the real-time display page, including:

在加载所述目标页面的过程中,按照预设截图频率对实时显示页面进行截图;In the process of loading the target page, screenshot the real-time display page according to the preset screenshot frequency;

在按照所述预设截图频率对实时显示页面进行截图的过程中,每截图得到一个页面截图,则获取所述页面截图的截图时间;In the process of taking a screenshot of the real-time display page according to the preset screenshot frequency, every screenshot is obtained a page screenshot, then the screenshot time of the page screenshot is obtained;

若当前时间与所述目标页面的开始加载时间之间的时长大于或等于时长阈值,则停止截图。If the duration between the current time and the start loading time of the target page is greater than or equal to the duration threshold, the screenshot is stopped.

可选地,所述基于目标页面的页面地址,开始加载所述目标页面之前,还包括:Optionally, before starting to load the target page based on the page address of the target page, the method further includes:

若接收到页面测试指令,则遍历测试页面列表,所述测试页面列表包括多个待测试页面的页面地址;If a page test instruction is received, traverse a test page list, where the test page list includes page addresses of multiple pages to be tested;

在遍历所述测试页面列表的过程中,每遍历到一个待测试页面的页面地址,则将遍历到的待测试页面确定为所述目标页面,并执行基于所述目标页面的页面地址,开始加载所述目标页面的步骤。In the process of traversing the list of test pages, each time a page address of a page to be tested is traversed, the page to be tested that has been traversed is determined as the target page, and the page address based on the target page is executed to start loading the target page steps.

可选地,所述基于所述加载开始页面截图的第一截图时间和所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长,包括:Optionally, determining the loading duration of the target page based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot includes:

确定所述第一截图时间与所述第二截图时间之间的时长;determining the duration between the first screenshot time and the second screenshot time;

将所述第一截图时间与所述第二截图时间之间的时长,确定为所述目标页面的加载时长。The duration between the first screenshot time and the second screenshot time is determined as the loading duration of the target page.

另一方面,提供了一种页面加载时长的确定装置,所述装置包括:In another aspect, an apparatus for determining page loading duration is provided, the apparatus comprising:

加载模块,用于基于目标页面的页面地址,开始加载所述目标页面,所述目标页面为待确定加载时长的页面;a loading module, configured to start loading the target page based on the page address of the target page, where the target page is a page whose loading duration is to be determined;

截图模块,用于在加载所述目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;A screenshot module, used for continuously taking screenshots of the real-time display page in the process of loading the target page, to obtain multiple page screenshots and the screenshot time of each page screenshot;

识别模块,用于对所述多个页面截图进行图像分析,以从所述多个页面截图中识别出加载开始页面截图和加载完成页面截图;an identification module, configured to perform image analysis on the multiple page screenshots, so as to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots;

确定模块,用于基于所述加载开始页面截图的第一截图时间和所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长。A determining module, configured to determine the loading duration of the target page based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.

可选地,所述识别模块包括:Optionally, the identification module includes:

第一识别单元,用于基于所述多个页面截图中相邻页面截图的图像指纹差异,确定所述加载开始页面截图,每个页面截图的图像指纹用于指示对应页面截图;a first identification unit, configured to determine the loading start page screenshot based on the difference in image fingerprints of adjacent page screenshots among the multiple page screenshots, and the image fingerprint of each page screenshot is used to indicate the corresponding page screenshot;

第二识别单元,用于基于所述多个页面截图中位于末尾页面截图之前的页面截图与所述末尾页面截图之间的图像指纹差异,确定所述加载完成页面截图。The second identification unit is configured to determine the loading completed page screenshot based on the image fingerprint difference between the page screenshot before the last page screenshot and the last page screenshot among the plurality of page screenshots.

可选地,所述第一识别单元用于:Optionally, the first identification unit is used for:

按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图;According to the sequence of the screenshot time from front to back, successively obtain screenshots of adjacent pages from the plurality of page screenshots;

每获取到一对相邻页面截图,则确定获取的相邻页面截图中每个页面截图的图像指纹;Each time a pair of adjacent page screenshots are obtained, determine the image fingerprint of each page screenshot in the obtained adjacent page screenshots;

若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异小于或等于第一差异阈值,则返回按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图的步骤;If, based on the obtained image fingerprints of each page screenshot in the adjacent page screenshots, it is determined that the difference between the obtained image fingerprints of the adjacent page screenshots is less than or equal to the first difference threshold, then return the screenshots in the order from front to back. , the steps of successively obtaining screenshots of adjacent pages from the multiple page screenshots;

若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异大于第一差异阈值,则将所述获取的相邻页面截图中的任一页面截图确定为所述加载开始页面截图。If it is determined based on the image fingerprint of each page screenshot in the obtained adjacent page screenshots that the difference between the image fingerprints of the obtained adjacent page screenshots is greater than the first difference threshold, A screenshot of any page is determined to be a screenshot of the loading start page.

可选地,所述第二识别单元用于:Optionally, the second identification unit is used for:

按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图;According to the sequence of the screenshot time from back to front, sequentially obtain page screenshots from the page screenshots located before the last page screenshot included in the plurality of page screenshots;

每获取到一个页面截图,则将获取的页面截图作为第一页面截图,确定所述第一页面截图的图像指纹;Each time a page screenshot is obtained, the obtained page screenshot is taken as the first page screenshot, and the image fingerprint of the first page screenshot is determined;

若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异小于或等于第二差异阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤;If, based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is less than or equal to the second difference threshold, then return to the screen according to the screenshot. In the order of time from back to front, the steps of sequentially acquiring page screenshots from the page screenshots located before the last page screenshot included in the multiple page screenshots;

若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异大于第二差异阈值,则将位于所述第一页面截图之后的第二页面截图确定为所述加载完成页面截图。If it is determined based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold The second page screenshot after the one page screenshot is determined to be the loading completed page screenshot.

可选地,所述第二识别单元用于:Optionally, the second identification unit is used for:

确定所述第二页面截图与所述末尾页面截图之间的指定图像差异指标,所述指定图像差异指标包括差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值中的至少一种;Determine the specified image difference index between the screenshot of the second page and the screenshot of the last page, where the specified image difference index includes the pixel ratio of the difference pixels, the difference between the pixel mean values of the difference image part, and the pixels of the difference image part at least one of the differences in standard deviations;

若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则执行将所述第二页面截图确定为所述加载开始页面截图的步骤。If the specified image difference index between the second page screenshot and the last page screenshot is less than or equal to the corresponding index threshold, the step of determining the second page screenshot as the loading start page screenshot is performed.

可选地,所述第二识别单元用于:Optionally, the second identification unit is used for:

若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤。If the specified image difference index between the screenshot of the second page and the screenshot of the last page is greater than the corresponding index threshold, return to the order of the screenshot time from the back to the front, from the screenshots of the multiple pages including those located in the Follow the steps to obtain page screenshots in the page screenshot before the last page screenshot.

可选地,所述截图模块用于:Optionally, the screenshot module is used for:

在加载所述目标页面的过程中,按照预设截图频率对实时显示页面进行截图;In the process of loading the target page, screenshot the real-time display page according to the preset screenshot frequency;

在按照所述预设截图频率对实时显示页面进行截图的过程中,每截图得到一个页面截图,则获取所述页面截图的截图时间;In the process of taking a screenshot of the real-time display page according to the preset screenshot frequency, every screenshot is obtained a page screenshot, then the screenshot time of the page screenshot is obtained;

若当前时间与所述目标页面的开始加载时间之间的时长大于或等于时长阈值,则停止截图。If the duration between the current time and the start loading time of the target page is greater than or equal to the duration threshold, the screenshot is stopped.

可选地,所述装置还包括:Optionally, the device further includes:

遍历模块,用于若接收到页面测试指令,则遍历测试页面列表,所述测试页面列表包括多个待测试页面的页面地址;a traversal module, configured to traverse a test page list if a page test instruction is received, where the test page list includes page addresses of multiple pages to be tested;

触发模块,用于在遍历所述测试页面列表的过程中,每遍历到一个待测试页面的页面地址,则将遍历到的待测试页面确定为所述目标页面,并触发加载模块基于所述目标页面的页面地址,开始加载所述目标页面。The triggering module is configured to determine the traversed to-be-tested page as the target page every time a page address of a to-be-tested page is traversed in the process of traversing the test page list, and trigger the loading module based on the target page The page address of the page to start loading the target page.

可选地,所述确定模块用于:Optionally, the determining module is used to:

确定所述第一截图时间与所述第二截图时间之间的时长;determining the duration between the first screenshot time and the second screenshot time;

将所述第一截图时间与所述第二截图时间之间的时长,确定为所述目标页面的加载时长。The duration between the first screenshot time and the second screenshot time is determined as the loading duration of the target page.

另一方面,还提供了一种电子设备包括:In another aspect, there is also provided an electronic device comprising:

处理器;processor;

用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;

其中,所述处理器被配置为执行上述任一种页面加载时长的确定方法。Wherein, the processor is configured to execute any one of the above methods for determining the page loading duration.

另一方面,还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有指令,所述指令被处理器执行时实现上述任一种页面加载时长的确定方法。In another aspect, a computer-readable storage medium is also provided, where instructions are stored on the computer-readable storage medium, and when the instructions are executed by a processor, any one of the foregoing methods for determining a page loading duration is implemented.

在另一实施例中,还提供了一种计算机程序产品,当所述计算机程序产品被执行时,用于实现上述任一种页面加载时长的确定方法。In another embodiment, a computer program product is also provided, which, when the computer program product is executed, is used to implement any one of the above-mentioned methods for determining a page loading duration.

本申请实施例提供的技术方案带来的有益效果是:The beneficial effects brought by the technical solutions provided in the embodiments of the present application are:

本申请实施例中,可以在加载目标页面的过程中,自动对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间,然后基于图像分析从多个页面截图中准确识别出加载开始页面截图和加载完成页面截图,并根据两者的截图时间来确定页面加载时长,这种页面加载时长的确定方法处理过程简单且准确性较高,不依赖于Appium的自动化框架和元素定位机制即可实现,从而提高了页面加载时长的确定效率和准确率。In the embodiment of the present application, during the process of loading the target page, continuous screenshots of the real-time display page can be automatically taken to obtain multiple page screenshots and the screenshot time of each page screenshot, and then accurately identify from the multiple page screenshots based on image analysis. Take a screenshot of the loading start page and the loading completion page, and determine the page loading time according to the screenshot time of the two. This method of determining the page loading time has a simple processing process and high accuracy, and does not depend on Appium's automation framework and elements. The positioning mechanism can be implemented, thereby improving the efficiency and accuracy of determining the page loading time.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.

图1是本申请实施例提供的一种页面加载时长的确定方法的流程图;1 is a flowchart of a method for determining a page loading duration provided by an embodiment of the present application;

图2是本申请实施例提供的一种识别加载开始页面截图的示意图;FIG. 2 is a schematic diagram of a screenshot of an identification loading start page provided by an embodiment of the present application;

图3是本申请实施例提供的一种识别加载完成页面截图的示意图;3 is a schematic diagram of a screenshot of a page identifying a loading completion provided by an embodiment of the present application;

图4是本申请实施例提供的一种测试日志的示意图;4 is a schematic diagram of a test log provided by an embodiment of the present application;

图5是本申请实施例提供的另一种页面加载时长的确定方法的流程图;5 is a flowchart of another method for determining page loading duration provided by an embodiment of the present application;

图6是本申请实施例提供的一种页面截图的存储目标的示意图;6 is a schematic diagram of a storage target of a page screenshot provided by an embodiment of the present application;

图7是本申请实施例提供的一种页面加载时长的确定装置的结构框图;7 is a structural block diagram of an apparatus for determining a page loading duration provided by an embodiment of the present application;

图8是本申请实施例提供的一种终端的结构框图。FIG. 8 is a structural block diagram of a terminal provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

在对本申请实施例进行详细地解释说明之前,先对本申请实施例的应用场景予以说明。Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are described first.

本申请实施例应用于页面测速场景中,通过确定某个页面被打开到完整显示所使用的加载时长,来确定页面加载速度。另外,本申请实施例提供的页面加载时长的确定方法应用于待测试的电子设备中,该电子设备可以为手机、平板电脑、计算机、可穿戴设备或车载设备等,本申请实施例对此不作限定。The embodiment of the present application is applied to a page speed measurement scenario, and the page loading speed is determined by determining the loading time used for a certain page to be opened to complete display. In addition, the method for determining the page loading duration provided by the embodiment of the present application is applied to the electronic device to be tested, and the electronic device may be a mobile phone, a tablet computer, a computer, a wearable device, or a vehicle-mounted device, etc. limited.

需要说明的是,本申请实施例提供的页面加载时长的确定方法是一种基于图像识别的页面加载时长确定方法,能够在页面加载过程中,自动对实时显示页面进行连续截图,并通过图像分析从截图中准确识别出加载开始页面截图和加载完成页面截图,然后根据两者的截图时间间隔来确定页面加载时长,如此,不依赖于Appium的自动化框架和元素定位机制即可实现页面加载时长的确定,提高了页面加载时长的确定效率和准确率。It should be noted that the method for determining the page loading duration provided by the embodiment of the present application is a method for determining the page loading duration based on image recognition, which can automatically take continuous screenshots of the real-time display page during the page loading process, and analyze the images through image analysis. Accurately identify the screenshot of the loading start page and the loading completion page screenshot from the screenshot, and then determine the page loading time according to the time interval between the two screenshots. In this way, the page loading time can be realized without relying on Appium's automatic framework and element positioning mechanism. Determined, which improves the efficiency and accuracy of determining the page loading time.

图1是本申请实施例提供的一种页面加载时长的确定方法的流程图,该方法用于电子设备中。参见图1,该方法包括:FIG. 1 is a flowchart of a method for determining a page loading duration provided by an embodiment of the present application, and the method is used in an electronic device. Referring to Figure 1, the method includes:

步骤101:基于目标页面的页面地址,开始加载目标页面。Step 101: Start to load the target page based on the page address of the target page.

其中,目标页面为待测试的任一页面,即待确定加载时长的页面。目标页面可以为网页页面或客户端页面等,本申请实施例对此不作限定。The target page is any page to be tested, that is, the page whose loading time is to be determined. The target page may be a web page or a client page, etc., which is not limited in this embodiment of the present application.

作为一个示例,可以在检测到对目标页面的页面入口的触发操作时,获取目标页面的页面地址,基于目标页面的页面地址,开始加载目标页面。As an example, when a triggering operation on the page entry of the target page is detected, the page address of the target page may be obtained, and the target page may be loaded based on the page address of the target page.

其中,该页面入口用于打开目标页面,可以为图片、选项或目标页面的链接地址等,本申请实施例对此不作限定。对页面入口的触发操作可以由用户执行,比如,该触发操作可以为用户对页面入口的点击操作等。The page entry is used to open the target page, and may be a picture, an option, or a link address of the target page, etc., which is not limited in this embodiment of the present application. The triggering operation on the page entry may be performed by the user, for example, the triggering operation may be the user's click operation on the page entry, and the like.

作为另一个示例,可以在接收页面测试指令时,获取目标页面的页面地址,基于目标页面的页面地址,开始加载目标页面。As another example, the page address of the target page may be obtained when the page test instruction is received, and the target page may be loaded based on the page address of the target page.

其中,该页面测试指令用于指示对目标页面进行测试,可以由用户通过指定操作触发,也可以在当前时间到达测试时间时自动触发,比如周期性触发,也可以在电子设备处于空闲状态时自动触发等,本申请实施例对此不作限定。Among them, the page test instruction is used to instruct the target page to be tested, which can be triggered by the user through a specified operation, or can be triggered automatically when the current time reaches the test time, such as periodic triggering, or it can be automatically triggered when the electronic device is in an idle state Triggers, etc., are not limited in this embodiment of the present application.

需要说明的是,本申请实施例还可以对多个待测试页面进行批量测试,目标页面为多个待测试页面中的任一个。而且,在对这多个待测试页面进行批量测试的过程中,每个待测试页面均可以采用目标页面的测试方式进行测试。It should be noted that, in this embodiment of the present application, batch testing can also be performed on multiple pages to be tested, and the target page is any one of the multiple pages to be tested. Moreover, in the process of batch testing the plurality of pages to be tested, each page to be tested may be tested in the test method of the target page.

比如,若接收到页面测试指令,则遍历测试页面列表,在遍历测试页面列表的过程中,每遍历到一个待测试页面的页面地址,则将遍历到的待测试页面确定为目标页面,并基于目标页面的页面地址,开始加载目标页面,以确定目标页面的加载时长。其中,测试页面列表包括多个待测试页面的页面地址。For example, if a page test instruction is received, the test page list is traversed. During the process of traversing the test page list, each time a page address of a page to be tested is traversed, the traversed page to be tested is determined as the target page, and based on The page address of the target page to start loading the target page to determine the loading time of the target page. The test page list includes page addresses of multiple pages to be tested.

在一种可能的实现方式中,本申请实施例提供的页面加载时长的确定方法对应的页面测试逻辑能够以测试脚本的形式展现,该测试脚本为一段程序代码。也即是,可以通过执行该测试脚本,实现本申请实施例提供的页面加载时长的确定方法。比如,当需要进行页面测试时,可以启动该测试脚本,通过该测试脚本读取测试页面列表,对测试页面列表中的各个待测试页面进行批量测试,来确定每个待测试页面的页面加载时长。In a possible implementation manner, the page test logic corresponding to the method for determining the page loading duration provided by the embodiment of the present application can be presented in the form of a test script, where the test script is a piece of program code. That is, the method for determining the page loading duration provided by the embodiment of the present application can be implemented by executing the test script. For example, when a page test needs to be performed, the test script can be started, the test page list can be read through the test script, and each to-be-tested page in the test page list can be tested in batches to determine the page loading time of each to-be-tested page .

作为一个示例,若目标页面为目标应用的某个页面,则在基于目标页面的页面地址,开始加载目标页面之前,还可以先对目标应用进行初始化,在初始化完成之后,再基于目标页面的页面地址,开始加载目标页面。比如,可以在接收到页面测试指令后,对目标应用进行初始化。该页面测试指令可以为启动测试脚本的指令等。As an example, if the target page is a certain page of the target application, before starting to load the target page based on the page address of the target page, the target application can also be initialized, and after the initialization is completed, the page based on the target page can be initialized. address to start loading the target page. For example, the target application may be initialized after receiving the page test instruction. The page test instruction may be an instruction to start a test script, or the like.

其中,对目标应用进行初始化的操作可以包括清除待测试的目标页面的缓存数据的操作等。通过清除目标页面的缓冲数据,可以避免在加载目标页面时,可能会基于目标页面的缓存数据对目标页面进行加载,导致所确定的页面加载时长无法准确反映实际加载时长的问题。The operation of initializing the target application may include an operation of clearing cached data of the target page to be tested, and the like. By clearing the buffered data of the target page, the target page may be loaded based on the cached data of the target page when the target page is loaded, so that the determined page loading time cannot accurately reflect the actual loading time.

步骤102:在加载目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间。Step 102: During the process of loading the target page, continuous screenshots are taken of the real-time display page to obtain multiple page screenshots and the screenshot time of each page screenshot.

作为一个示例,可以通过截图线程,在加载目标页面的过程中,对实时显示页面进行连续截图。其中,该截图线程用于实时所显示页面进行连续截图,比如按照预设截图频率对实时显示页面进行截图。示例的,该预设截图频率大于频率阈值,以实现对页面加载过程的高速截图。As an example, continuous screenshots of the real-time display page may be taken during the process of loading the target page through the screenshot thread. The screenshot thread is used to take continuous screenshots of the displayed page in real time, for example, to take screenshots of the real-time displayed page according to a preset screenshot frequency. For example, the preset screenshot frequency is greater than the frequency threshold, so as to achieve high-speed screenshots of the page loading process.

需要说明的是,该截图线程可以在开始加载目标页面时启动,也可以在开始加载目标页面之前启动。比如,可以在接收到页面测试指令后,启动截图线程。该页面测试指令可以为启动测试脚本的指令等。通过在开始加载目标页面之前即启动截图线程,可以提高对加载过程进行截图的完整性,避免了无法及时对开始加载页面进行截图的可能性。It should be noted that the screenshot thread can be started when the target page starts to be loaded, or can be started before the target page starts to be loaded. For example, the screenshot thread can be started after receiving the page test command. The page test instruction may be an instruction to start a test script, or the like. By starting the screenshot thread before starting to load the target page, the completeness of the screenshot of the loading process can be improved, and the possibility of not being able to take the screenshot of the starting page to be loaded in time can be avoided.

作为一个示例,可以在加载目标页面的过程中,按照预设截图频率对实时显示页面进行截图,而且,在按照预设截图频率对实时显示页面进行截图的过程中,每截图得到一个页面截图,即获取该页面截图的截图时间。As an example, in the process of loading the target page, a screenshot of the real-time display page can be taken according to the preset screenshot frequency, and in the process of taking a screenshot of the real-time display page according to the preset screenshot frequency, one screenshot of the page is obtained for each screenshot. That is, the screenshot time of the screenshot of the page.

作为一个示例,在获取该页面截图的截图时间之后,还可以基于获取的截图时间,生成该页面截图的截图时间戳,并将该截图时间戳添加到该页面截图的图像信息中。As an example, after obtaining the screenshot time of the screenshot of the page, a screenshot timestamp of the screenshot of the page may also be generated based on the obtained screenshot time, and the screenshot timestamp is added to the image information of the screenshot of the page.

另外,在对实时显示页面进行连续截图的过程中,还可以在截图一段时间后,停止截图。比如,在当前时间与目标页面的开始加载时间之间的时长大于或等于时长阈值,则默认目标页面已加载完成,进而停止对实时显示页面进行截图。如此,可以在启动截图线程并截图一段时间后,默认目标页面已加载完成,并停止对目标页面的加载过程进行截图。In addition, in the process of continuously taking screenshots of the real-time display page, it is also possible to stop taking screenshots after a period of time. For example, if the duration between the current time and the start loading time of the target page is greater than or equal to the duration threshold, the default target page has been loaded, and the screenshot of the real-time display page is stopped. In this way, after starting the screenshot thread and taking screenshots for a period of time, the default target page has been loaded, and the screenshot of the loading process of the target page is stopped.

其中,该时长阈值可以根据目标页面的最长加载时长设置,比如,该时长阈值可以为5秒或6秒等。The duration threshold may be set according to the longest loading duration of the target page, for example, the duration threshold may be 5 seconds or 6 seconds.

作为一个示例,在对实时显示页面进行连续截图的过程中,还可以对页面截图进行压缩处理,然后基于压缩处理后的页面截图,确定目标页面的加载时长。其中,压缩处理后的页面截图的图像质量小于压缩处理前的页面截图的图像质量,比如压缩处理后的页面截图的图像质量为压缩处理前的页面截图的图像质量的1/n,n大于1,比如,n4或8等,本申请实施例对此不作限定。As an example, in the process of continuously taking screenshots of the real-time display page, the page screenshots may also be compressed, and then the loading time of the target page is determined based on the compressed page screenshots. The image quality of the page screenshot after compression processing is lower than the image quality of the page screenshot before compression processing. For example, the image quality of the page screenshot after compression processing is 1/n of the image quality of the page screenshot before compression processing, and n is greater than 1 , for example, n4 or 8, etc., which are not limited in this embodiment of the present application.

作为一个示例,在加载目标页面的过程中,对实时显示页面进行连续截图之后,还可以先对这多个页面截图以及每个页面截图的截图时间进行存储。比如,将这多个页面截图以及每个页面截图的截图时间存储在目标页面对应的存储目录中。或者,也可以在截图过程中,实时存储得到的页面截图,比如每个得到一个页面截图,则将页面截图和对应的截图时间自动存储在目标页面对应的文件夹目录中。As an example, in the process of loading the target page, after continuous screenshots of the real-time display page are taken, the screenshots of the multiple pages and the screenshot time of each page screenshot may also be stored first. For example, the multiple page screenshots and the screenshot time of each page screenshot are stored in a storage directory corresponding to the target page. Alternatively, the obtained page screenshots can also be stored in real time during the screenshot process. For example, each time a page screenshot is obtained, the page screenshot and the corresponding screenshot time are automatically stored in the folder directory corresponding to the target page.

作为一个示例,对这多个页面截图以及每个页面截图的截图时间进行存储时,可以将这多个页面截图以对应的截图时间戳进行命名。当然,也可以采用其他命名方式进行命名,本申请实施例对此不作限定。As an example, when storing the multiple page screenshots and the screenshot time of each page screenshot, the multiple page screenshots may be named with corresponding screenshot timestamps. Certainly, other naming manners may also be used for naming, which is not limited in this embodiment of the present application.

需要说明的是,通过对截图数据进行存储,可以基于这些截图数据进行离线计算或数据回放,并能够提供数据分析日志来佐证分析有效性。It should be noted that, by storing the screenshot data, offline calculation or data playback can be performed based on the screenshot data, and a data analysis log can be provided to prove the validity of the analysis.

步骤103:对多个页面截图进行图像分析,以从多个页面截图中识别出加载开始页面截图和加载完成页面截图。Step 103: Perform image analysis on the multiple page screenshots to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots.

也即是,本申请实施例可以采用图像分析的方式,从多个页面截图中识别出加载开始页面截图和加载完成页面截图,即识别出开始加载的页面和加载完成的页面,使得识别出的加载开始页面截图和加载完成页面截图更接近用户视觉上看到的加载开始页面和加载完成页面,从而使得检测结果与视觉体验更为接近,进而提高确定加载时长的准确性。That is, in this embodiment of the present application, an image analysis method can be used to identify the screenshots of the loading start page and the loading completion page from multiple page screenshots, that is, to identify the page that starts to load and the page that is loaded, so that the identified The screenshots of the loading start page and the loading completion page are closer to the loading start page and the loading completion page that the user visually sees, so that the detection results are closer to the visual experience, thereby improving the accuracy of determining the loading time.

本申请实施例中,可以基于多个页面截图的图像指纹,从多个页面截图中识别出加载开始页面截图和加载完成页面截图。其中,每个页面截图的图像指纹用于指示对应的页面截图,可以采用图像指纹生成算法得到。比如,可以基于页面截图的图像信息,采用图像指纹生成算法生成页面截图的图像指纹。In the embodiment of the present application, the screenshot of the loading start page and the screenshot of the loading completion page may be identified from the multiple page screenshots based on the image fingerprints of the multiple page screenshots. The image fingerprint of each page screenshot is used to indicate the corresponding page screenshot, and can be obtained by using an image fingerprint generation algorithm. For example, based on the image information of the page screenshot, an image fingerprint generation algorithm may be used to generate the image fingerprint of the page screenshot.

示例的,图像信息可以包括图像特征或其他图像信息,图像指纹生成算法可以为哈希算法,图像指纹可以为页面截图的哈希值等。For example, the image information may include image features or other image information, the image fingerprint generation algorithm may be a hash algorithm, and the image fingerprint may be a hash value of a screenshot of a page.

作为一个示例,对多个页面截图进行图像分析可以包括如下步骤:As an example, performing image analysis on multiple page screenshots may include the following steps:

步骤1031:基于多个页面截图中相邻页面截图的图像指纹差异,确定加载开始页面截图。Step 1031: Based on the image fingerprint difference of the adjacent page screenshots among the multiple page screenshots, determine the loading start page screenshot.

作为一个示例,可以基于图像指纹差异大于第一差异阈值的相邻页面截图,确定加载开始页面截图。比如,按照截图时间从前到后的顺序,从多个页面截图中确定图像指纹差异大于第一差异阈值的第一对相邻页面截图,将该第一对相邻页面截图中的任一页面截图确定为加载开始页面截图。As an example, the screenshot of the loading start page may be determined based on the screenshots of adjacent pages whose image fingerprint difference is greater than the first difference threshold. For example, according to the order of the screenshot time, determine the first pair of adjacent page screenshots whose image fingerprint difference is greater than the first difference threshold from multiple page screenshots, and take a screenshot of any page in the first pair of adjacent page screenshots Make sure to load a screenshot of the start page.

其中,第一差异阈值可以预先设置,比如可以设置为20或30等。另外,可以将该第一对相邻页面截图中的前一个页面截图确定为加载页面截图,或者将后一个页面截图确定为加载页面截图。The first difference threshold may be preset, for example, may be set to 20 or 30 or the like. In addition, the previous page screenshot in the first pair of adjacent page screenshots may be determined as the loading page screenshot, or the latter page screenshot may be determined as the loading page screenshot.

作为一个示例,基于多个页面截图中相邻页面截图的图像指纹差异,确定加载开始页面截图可以包括如下步骤:As an example, based on the difference in image fingerprints of adjacent page screenshots among multiple page screenshots, determining the loading start page screenshot may include the following steps:

1)按照截图时间从前到后的顺序,从多个页面截图中依次获取相邻页面截图。1) Take screenshots of adjacent pages in sequence from the screenshots of multiple pages in the order of the screenshot time.

2)每获取到一对相邻页面截图,则确定获取的相邻页面截图中每个页面截图的图像指纹。2) Each time a pair of adjacent page screenshots are obtained, the image fingerprint of each page screenshot in the obtained adjacent page screenshots is determined.

3)若基于获取的相邻页面截图中每个页面截图的图像指纹,确定获取的相邻页面截图的图像指纹差异小于或等于第一差异阈值,则返回按照截图时间从前到后的顺序,从多个页面截图中依次获取相邻页面截图。3) If, based on the image fingerprints of each page screenshot in the obtained adjacent page screenshots, it is determined that the difference between the obtained image fingerprints of the adjacent page screenshots is less than or equal to the first difference threshold, then return according to the screenshot time from front to back. In the screenshots of multiple pages, the screenshots of adjacent pages are obtained in sequence.

其中,邻页面截图的图像指纹差异是指相邻页面截图的图像指纹之间的差值,第一差异阈值为预先设置的差异阈值。The image fingerprint difference of the screenshots of adjacent pages refers to the difference between the image fingerprints of the screenshots of the adjacent pages, and the first difference threshold is a preset difference threshold.

也即是,若获取的相邻页面截图的图像指纹差异较小,则返回步骤1),继续获取下一对相邻页面截图,然后确定下一对相邻页面截图的图像指纹差异。That is, if the difference between the image fingerprints of the obtained screenshots of adjacent pages is small, return to step 1), continue to obtain the next pair of screenshots of adjacent pages, and then determine the difference in image fingerprints of the next pair of screenshots of adjacent pages.

4)若基于获取的相邻页面截图中每个页面截图的图像指纹,确定获取的相邻页面截图的图像指纹差异大于第一差异阈值,则将获取的相邻页面截图中的任一页面截图确定为加载开始页面截图。4) If it is determined based on the image fingerprint of each page screenshot in the obtained adjacent page screenshots that the difference between the obtained image fingerprints of the adjacent page screenshots is greater than the first difference threshold, then any page screenshot in the obtained adjacent page screenshots will be taken. Make sure to load a screenshot of the start page.

可以将获取的相邻页面截图中的前一个页面截图作为加载开始页面截图,也可以将后一个页面截图作为加载开始页面截图。将后一个页面截图作为家长开始页面截图的准确度更高。The screenshot of the previous page in the obtained screenshots of adjacent pages can be used as the screenshot of the loading start page, and the screenshot of the latter page can also be used as the screenshot of the loading start page. Taking the screenshot of the latter page as the screenshot of the parent start page is more accurate.

请参考图2,可以按照截图时间从前到后的顺序,依次计算当前页面截图与下一个页面截图之间的图像指纹差异。如果某个页面截图与下一个页面截图之间的图像指纹差异小于或等于图像差异阈值20,则确定该页面截图不满足加载开始条件,即确定该页面截图中不是加载开始页面截图;若某个页面截图与下一个页面截图之间的图像指纹差异大于图像差异阈值20,则确定该页面截图满足加载开始条件,即确定该页面截图为加载开始页面截图。Referring to FIG. 2 , the image fingerprint difference between the screenshot of the current page and the screenshot of the next page can be calculated in sequence according to the screenshot time. If the image fingerprint difference between a page screenshot and the next page screenshot is less than or equal to the image difference threshold of 20, it is determined that the page screenshot does not meet the loading start condition, that is, it is determined that the page screenshot is not the loading start page screenshot; If the image fingerprint difference between the page screenshot and the next page screenshot is greater than the image difference threshold of 20, it is determined that the page screenshot satisfies the loading start condition, that is, the page screenshot is determined to be the loading start page screenshot.

步骤1032:基于多个页面截图中位于末尾页面截图之前的页面截图与末尾页面截图之间的图像指纹差异,确定加载完成页面截图。Step 1032 : Based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page among the screenshots of the multiple pages, it is determined that the screenshot of the page after loading is completed.

作为一个示例,可以基于位于末尾页面截图之前的页面截图中与末尾页面截图之间的图像指纹差异小于或等于第二差异阈值的页面截图,确定加载完成页面截图。As an example, it may be determined that the loading completion page screenshot is based on the page screenshot before the last page screenshot and the page screenshot whose image fingerprint difference between the last page screenshot is less than or equal to the second difference threshold.

需要说明的是,在截图过程中,目标页面可能在截图停止之前就已经加载完成,在加载完成后,实时显示的画面将一直保持在加载完成的状态,这将导致截图得到的多个页面截图中可能会出现多个加载完成页面截图,本申请实施例中,为了准确确定加载完成时间,也就需要从多个页面截图中准确确定出首次出现的加载完成页面截图。比如,基于位于末尾页面截图之前的页面截图中与末尾页面截图之间的图像指纹差异,来确定首次出现的加载完成页面截图。It should be noted that during the screenshot process, the target page may have been loaded before the screenshot is stopped. After the loading is completed, the real-time display screen will remain in the loaded state, which will result in multiple page screenshots obtained from the screenshot. There may be multiple screenshots of the loading completion page. In this embodiment of the present application, in order to accurately determine the loading completion time, it is necessary to accurately determine the first loading completed page screenshot from the multiple page screenshots. For example, based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page, the first occurrence of the screenshot of the loading completed page is determined.

本申请实施例中,可以从位于末尾页面截图之前的页面截图中,确定最后一个与末尾页面截图之间的图像指纹差异小于或等于第二差异阈值的页面截图,将该页面截图确定为加载完成页面截图。或者,确定第一个与末尾页面截图之间的图像指纹差异大于第二差异阈值的页面截图,将该页面截图之后的一个页面截图确定为加载完成页面截图。In this embodiment of the present application, from the screenshots of the pages before the screenshot of the last page, it is possible to determine the screenshot of the last page whose image fingerprint difference between the screenshot of the last page and the screenshot of the last page is less than or equal to the second difference threshold, and determine the screenshot of the page as the loading completed. Screenshot of the page. Or, determine a page screenshot whose image fingerprint difference between the first and last page screenshots is greater than the second difference threshold, and determine a page screenshot after the page screenshot as a loaded page screenshot.

其中,第二差异阈值可以预先设置,且第二差异阈值与第一差异阈值可以相同,也可以不同,本申请实施例对此不作限定。The second difference threshold may be preset, and the second difference threshold may be the same as or different from the first difference threshold, which is not limited in this embodiment of the present application.

由于加载完成页面的出现时间一般比较靠后,因此,为了提高加载完成页面截图的识别效率,可以采用从后到前的顺序识别加载完成页面截图。Since the appearance time of the loaded page is generally later, in order to improve the recognition efficiency of the screenshot of the loaded page, the screenshot of the loaded page can be identified in order from back to front.

作为一个示例,基于多个页面截图中位于末尾页面截图之前的页面截图与末尾页面截图之间的图像指纹差异,确定加载完成页面截图的步骤包括:As an example, based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page among the screenshots of multiple pages, the steps of determining the screenshot of the page after loading includes:

1)按照截图时间从后到前的顺序,从多个页面截图包括的位于末尾页面截图之前的页面截图中依次获取页面截图。1) According to the sequence of the screenshot time from back to front, the page screenshots are sequentially obtained from the page screenshots located before the last page screenshot included in the multiple page screenshots.

2)每获取到一个页面截图,则将获取的页面截图作为第一页面截图,并确定第一页面截图的图像指纹。2) Each time a page screenshot is obtained, the obtained page screenshot is taken as the first page screenshot, and the image fingerprint of the first page screenshot is determined.

3)若基于第一页面截图的图像指纹和末尾页面截图的图像指纹,确定第一页面截图与末尾页面截图的图像指纹差异小于或等于第二差异阈值,则返回按照截图时间从后到前的顺序,从多个页面截图包括的位于末尾页面截图之前的页面截图中依次获取页面截图的步骤。3) If based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprint of the screenshot of the first page and the screenshot of the last page is less than or equal to the second difference threshold, then return according to the screenshot time from back to front. Sequentially, the steps of sequentially acquiring page screenshots from the page screenshots included in the multiple page screenshots that are located before the last page screenshot.

也即是,若第一页面截图与末尾页面截图的图像指纹差异较小,则返回步骤1),继续从位于末尾页面截图之前的页面截图中获取页面截图,并确定获取的页面截图与末尾页面截图的图像指纹差异。That is, if the difference between the image fingerprints of the first page screenshot and the last page screenshot is small, go back to step 1), continue to obtain page screenshots from the page screenshots located before the last page screenshot, and determine the obtained page screenshot and the last page. Screenshot of image fingerprint difference.

4)若基于第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定第一页面截图与所述末尾页面截图的图像指纹差异大于第二差异阈值,则将位于第一页面截图之后的第二页面截图确定为加载完成页面截图。4) If based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprint of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold, then it will be located after the screenshot of the first page. The second page screenshot is determined as the loading completed page screenshot.

进一步地,为了提高图像识别的准确度,在确定第一页面截图与所述末尾页面截图的图像指纹差异大于第二差异阈值之后,还可以先确定位于第一页面截图之后的第二页面截图与末尾页面截图之间的指定图像差异指标。若第二页面截图与末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则将第二页面截图确定为加载开始页面截图。若第二页面截图与末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从后到前的顺序,从多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤。Further, in order to improve the accuracy of image recognition, after it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold, it is also possible to first determine that the screenshot of the second page after the screenshot of the first page is different from the screenshot of the first page. The specified image difference metric between screenshots at the end of the page. If the specified image difference index between the screenshot of the second page and the screenshot of the last page is less than or equal to the corresponding index threshold, the screenshot of the second page is determined as the screenshot of the loading start page. If the specified image difference index between the screenshot of the second page and the screenshot of the last page is greater than the corresponding index threshold, return the pages that are included in the screenshots of multiple pages and located before the screenshot of the last page in the order of the screenshot time from back to front. Follow the steps to obtain page screenshots in Screenshots.

其中,指定图像差异指标包括差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值中的至少一种。The specified image difference index includes at least one of the pixel ratio of the difference pixels, the difference between the pixel mean values of the difference image part, and the difference between the pixel standard deviations of the difference image part.

其中,差异像素的占比是指第二页面截图中与末尾页面截图不相同的像素点数目与第二页面截图的总像素点数目之间的比例。差异图像部分的像素均值的差值是指第一像素均值与第二像素均值之间的差值,第一像素均值是指第二页面截图中与末尾页面截图不相同的第一图像部分的像素均值,第二像素均值是指末尾页面截图中与第二页面截图不相同的第二图像部分的像素均值。差异图像部分的像素标准差的差值是指第一像素标准差与第二像素标准差之间的差值。第一像素标准差为第一图像部分的像素标准差,第二像素标准差为第二图像部分的像素标准差。The proportion of different pixels refers to the ratio between the number of pixels in the screenshot of the second page that are different from the screenshot of the last page and the total number of pixels in the screenshot of the second page. The difference between the pixel mean values of the difference image part refers to the difference between the first pixel mean value and the second pixel mean value, and the first pixel mean value refers to the pixels of the first image part in the screenshot of the second page that are different from the screenshot of the last page. The mean value, the second pixel mean value refers to the pixel mean value of the part of the second image in the screenshot of the last page that is different from the screenshot of the second page. The difference value of the pixel standard deviation of the difference image portion refers to the difference value between the first pixel standard deviation and the second pixel standard deviation. The first pixel standard deviation is the pixel standard deviation of the first image portion, and the second pixel standard deviation is the pixel standard deviation of the second image portion.

比如,可以确定第二页面截图与末尾页面截图之间的差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值,若像素占比小于占比阈值,差异部分图像的像素均值的差值小于第一差值阈值,且差异部分图像的像素标准差的差值小于第二差值阈值,则将第二页面截图确定为加载开始页面截图。For example, it is possible to determine the pixel ratio of the difference pixels between the screenshot of the second page and the screenshot of the last page, the difference between the pixel mean values of the difference image part and the pixel standard deviation of the difference image part, if the pixel ratio is less than the pixel ratio Threshold, the difference between the pixel mean values of the difference image is less than the first difference threshold, and the difference between the pixel standard deviations of the difference image is less than the second difference threshold, then the second page screenshot is determined as the loading start page screenshot.

在另一实施例中,还可以按照截图时间从前到后的顺序,从多个页面截图中依次获取页面截图;每获取到一个页面截图,则将获取的页面截图作为第三页面截图,确定第三页面截图的图像指纹;若基于第三页面截图的图像指纹和末尾页面截图的图像指纹,确定第三页面截图与末尾页面截图的图像指纹差异大于第三差异阈值,则返回按照截图时间从前到后的顺序,从多个页面截图中依次获取页面截图的步骤;若基于第三页面截图的图像指纹和末尾页面截图的图像指纹,确定第三页面截图与末尾页面截图的图像指纹差异小于或等于第三差异阈值,则将该第三页面截图确定为加载完成页面截图。In another embodiment, page screenshots may also be sequentially obtained from multiple page screenshots in the order of the screenshot time; each time a page screenshot is obtained, the obtained page screenshot is used as the third page screenshot, and the first page screenshot is determined. The image fingerprints of the screenshots of three pages; if, based on the image fingerprints of the screenshots of the third page and the image fingerprints of the screenshots of the last page, it is determined that the difference between the image fingerprints of the screenshots of the third page and the screenshots of the last page is greater than the third difference threshold, return the screenshot time from front to The steps of obtaining page screenshots from multiple page screenshots in sequence; if based on the image fingerprint of the third page screenshot and the image fingerprint of the last page screenshot, it is determined that the difference between the image fingerprints of the third page screenshot and the last page screenshot is less than or equal to For the third difference threshold, the third page screenshot is determined as the loading completed page screenshot.

进一步地,确定第三页面截图与末尾页面截图的图像指纹差异小于或等于第三差异阈值之后,还可以先确定第三页面截图与末尾页面截图之间的指定图像差异指标。若第三页面截图与末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则将第三页面截图确定为加载开始页面截图。若第三页面截图与末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从前到后的顺序,从多个页面截图中依次获取页面截图的步骤。Further, after it is determined that the difference between the image fingerprints of the screenshot of the third page and the screenshot of the last page is less than or equal to the third difference threshold, the specified image difference index between the screenshot of the third page and the screenshot of the last page can also be determined first. If the specified image difference index between the screenshot of the third page and the screenshot of the last page is less than or equal to the corresponding index threshold, the screenshot of the third page is determined as the screenshot of the loading start page. If the specified image difference index between the screenshot of the third page and the screenshot of the last page is greater than the corresponding index threshold, return to the step of sequentially obtaining page screenshots from multiple page screenshots in the order of the screenshot time from front to back.

请参考图3,可以按照页面截图从后到前的顺序,依次计算每个页面截图与末尾页面截图之间的图像指纹差异。如果某个页面截图与末尾页面截图之间的图像指纹差异小于或等于差异阈值20,且与末尾页面截图之间的差异像素占比小于阈值2%,则确定该页面截图为加载完成页面截图。Referring to FIG. 3 , the image fingerprint difference between each page screenshot and the last page screenshot can be calculated sequentially in the order of page screenshots from back to front. If the image fingerprint difference between a screenshot of a page and the screenshot of the last page is less than or equal to the difference threshold of 20, and the difference pixel ratio between the screenshot of the last page and the screenshot of the last page is less than the threshold of 2%, it is determined that the screenshot of the page is a screenshot of the loaded page.

步骤104:基于加载开始页面截图的第一截图时间以及加载完成页面截图的第二截图时间,确定目标页面的加载时长。Step 104: Determine the loading time of the target page based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.

也即是,可以确定第一截图时间与第二截图时间之间的时长,将第一截图时间与第二截图时间之间的时长,确定为目标页面的加载时长。That is, the duration between the first screenshot time and the second screenshot time can be determined, and the duration between the first screenshot time and the second screenshot time can be determined as the loading duration of the target page.

作为一个示例,还可以获取加载开始页面截图的第一截图时间戳以及加载完成页面截图的第二截图时间戳,基于第一截图时间戳和第二截图时间戳,确定目标页面的加载时长。其中,第一截图时间戳用于指示加载开始页面截图的截图时间,第二截图时间戳用于指示加载完成页面截图的截图时间。As an example, the first screenshot timestamp of the screenshot of the loading start page and the second screenshot timestamp of the completed page screenshot may also be obtained, and the loading duration of the target page is determined based on the first screenshot timestamp and the second screenshot timestamp. Wherein, the first screenshot timestamp is used to indicate the screenshot time of the page screenshot at the start of loading, and the second screenshot timestamp is used to indicate the screenshot time of the page screenshot after the loading is completed.

比如,确定第一截图时间戳与第二截图时间戳之间的时长,将确定的时长作为目标页面的加载时长。For example, the duration between the timestamp of the first screenshot and the timestamp of the second screenshot is determined, and the determined duration is used as the loading duration of the target page.

进一步地,还可以基于加载开始页面截图、加载完成页面截图、图像识别结果、以及目标页面的加载时长,生成测试日志。请参考图4,该测试日志可以包括目标页面的加载开始页面截图的名称、加载完成页面截图的名称、图像识别结果、页面截图的存储路径以及加载时长等。Further, the test log may also be generated based on the screenshot of the loading start page, the screenshot of the loading completion page, the image recognition result, and the loading time of the target page. Referring to FIG. 4 , the test log may include the name of the screenshot of the loading start page of the target page, the name of the screenshot of the page after the loading is completed, the image recognition result, the storage path of the page screenshot, and the loading time.

本申请实施例中,可以在加载目标页面的过程中,自动对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间,然后基于图像分析从多个页面截图中准确识别出加载开始页面截图和加载完成页面截图,并根据两者的截图时间来确定页面加载时长,这种页面加载时长的确定方法处理过程简单且准确性较高,不依赖于Appium的自动化框架和元素定位机制即可实现,从而提高了页面加载时长的确定效率和准确率。In the embodiment of the present application, during the process of loading the target page, continuous screenshots of the real-time display page can be automatically taken to obtain multiple page screenshots and the screenshot time of each page screenshot, and then accurately identify from the multiple page screenshots based on image analysis. Take a screenshot of the loading start page and the loading completion page, and determine the page loading time according to the screenshot time of the two. This method of determining the page loading time has a simple processing process and high accuracy, and does not depend on Appium's automation framework and elements. The positioning mechanism can be implemented, thereby improving the efficiency and accuracy of determining the page loading time.

图5是本申请实施例提供的另一种页面加载时长的确定方法的流程图,该方法应用于电子设备,如图5所示,该方法包括如下步骤:FIG. 5 is a flowchart of another method for determining page loading duration provided by an embodiment of the present application. The method is applied to an electronic device. As shown in FIG. 5 , the method includes the following steps:

步骤501:启动测试脚本,通过测试脚本读取测试页面列表。Step 501: Start the test script, and read the test page list through the test script.

其中,该测试脚本用于确定测试页面的加载时长,该测试脚本为本申请实施例提供的页面加载时长的确定方法的处理逻辑所对应的测试代码。测试页面列表包括多个待测试页面的页面地址,是根据测试需求预先设置得到。Wherein, the test script is used to determine the loading duration of the test page, and the test script is the test code corresponding to the processing logic of the method for determining the page loading duration provided by the embodiment of the present application. The test page list includes page addresses of multiple pages to be tested, which are preset according to test requirements.

在读取测试页面列表时,可以遍历测试页面列表,每遍历到一个测试页面的页面地址,基于该测试页面的页面地址执行如下步骤502-507。When reading the test page list, the test page list can be traversed, and each time a page address of a test page is traversed, the following steps 502-507 are performed based on the page address of the test page.

步骤502:对目标应用进行初始化,启动初始化后的目标应用。Step 502: Initialize the target application, and start the initialized target application.

在目标应用进行初始化的过程中,可以清除目标应用的页面缓存数据,以避免在加载测试页面时,可能会基于页面缓存数据对测试页面进行加载,导致所确定的页面加载时长无法准确反映实际加载时长的问题。During the initialization process of the target application, the page cache data of the target application can be cleared, so as to avoid loading the test page based on the page cache data when the test page is loaded, so that the determined page loading time cannot accurately reflect the actual loading. question of time.

步骤503:启动截图线程,通过截图线程对所显示页面进行连续截图。Step 503: Start the screenshot thread, and continuously take screenshots of the displayed page through the screenshot thread.

其中,该截图线程可以为高速截图线程,可以按照预设截图频率对所显示页面进行截图,该预设截图频率大于频率阈值。The screenshot thread may be a high-speed screenshot thread, and may screenshot the displayed page according to a preset screenshot frequency, where the preset screenshot frequency is greater than a frequency threshold.

在截图过程中,每截图得到一个页面截图时,还可以将该页面截图存储到该测试页面对应的存储目录中。另外,还可以将该页面截图的截图时间戳存储到该页面截图的图像信息中。During the screenshot process, when a screenshot of a page is obtained for each screenshot, the screenshot of the page can also be stored in a storage directory corresponding to the test page. In addition, the screenshot timestamp of the screenshot of the page can also be stored in the image information of the screenshot of the page.

请参考图6,测试页面列表包括多个精选点评页面,在精选点评页面1加载的过程中,可以将在其加载过程中截图得到的页面截图存储到文件夹1中。其中,文件夹1用于存储精选点评页面1在加载过程中的页面截图。另外,还可以在每个页面截图的图像信息中存储该页面截图的截图时间戳。Referring to FIG. 6 , the test page list includes multiple featured comment pages. During the loading process of the featured comment page 1, the screenshots of the pages obtained during the loading process can be stored in the folder 1. Among them, the folder 1 is used to store the page screenshots of the featured review page 1 during the loading process. In addition, the screenshot timestamp of each page screenshot can also be stored in the image information of each page screenshot.

步骤504:基于待测试页面的页面地址,开始加载对应的待测试页面。Step 504: Based on the page address of the page to be tested, start loading the corresponding page to be tested.

也即是,可以基于待测试页面的页面地址,打开对应的待测试页面。That is, the corresponding page to be tested can be opened based on the page address of the page to be tested.

其中,该待测试页面为测试页面列表中的任一待测试页面,比如为当前遍历到的一个待测试页面。The page to be tested is any page to be tested in the list of test pages, for example, a page to be tested that is currently traversed.

步骤505:截图一段时间后默认待测试页面已加载完成,并停止截图线程。Step 505: After a period of screenshots, it is assumed that the page to be tested has been loaded by default, and the screenshot thread is stopped.

比如,可以在截图流程启动预设时长后,停止该截图线程。其中,该预设时长可以基于测试页面的最长加载时长设置得到。For example, the screenshot thread can be stopped after the screenshot process starts for a preset duration. The preset duration may be set based on the longest loading duration of the test page.

步骤506:对截图得到的多个页面截图进行图像分析,以从多个页面截图中识别出加载开始页面截图和加载完成页面截图。Step 506: Perform image analysis on the multiple page screenshots obtained by the screenshots, so as to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots.

其中,步骤506的实现过程与上述图1实施例中的步骤103同理,具体实现过程可以参考步骤103的相关描述,本申请实施例对此不作限定。The implementation process ofstep 506 is the same as that ofstep 103 in the above-mentioned embodiment of FIG. 1 . For the specific implementation process, reference may be made to the relevant description ofstep 103 , which is not limited in this embodiment of the present application.

步骤507:基于加载开始页面截图的截图时间戳和加载完成页面截图的截图时间戳,确定待测试页面的加载时长。Step 507: Determine the loading duration of the page to be tested based on the screenshot timestamp of the screenshot of the loading start page and the screenshot timestamp of the screenshot of the loading completed page.

比如,确定加载开始页面截图的截图时间戳和加载完成页面截图的截图时间戳之间的时长,将确定的时长作为该测试页面的加载时长。For example, determine the duration between the screenshot timestamp of the screenshot of the loading start page and the screenshot timestamp of the completed page screenshot, and use the determined duration as the loading duration of the test page.

在确定该待测试页面的加载时长之后,还可以继续遍历测试页面列表,然后基于遍历到的下一个待测试页面的页面地址,重复步骤202-207,确定下一个待测试页面的加载时长,直至遍历到测试页面列表中的最后一个待测试页面的页面地址为止。After determining the loading time of the page to be tested, you can continue to traverse the list of test pages, and then repeat steps 202-207 based on the traversed page address of the next page to be tested to determine the loading time of the next page to be tested, until Traverse to the page address of the last to-be-tested page in the list of test pages.

图7是本申请实施例提供的一种页面加载时长的确定装置的结构框图,该装置集成于电子设备中,该电子设备可以为手机、平板电脑或计算机等终端。如图7所示,该装置包括:7 is a structural block diagram of an apparatus for determining page loading duration provided by an embodiment of the present application. The apparatus is integrated into an electronic device, and the electronic device may be a terminal such as a mobile phone, a tablet computer, or a computer. As shown in Figure 7, the device includes:

加载模块701,用于基于目标页面的页面地址,开始加载该目标页面,该目标页面为待确定加载时长的页面;Loading module 701, configured to start loading the target page based on the page address of the target page, where the target page is the page whose loading duration is to be determined;

截图模块702,用于在加载该目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;A screenshot module 702, configured to continuously take screenshots of the real-time display page during the process of loading the target page, to obtain multiple page screenshots and the screenshot time of each page screenshot;

识别模块703,用于对该多个页面截图进行图像分析,以从该多个页面截图中识别出加载开始页面截图和加载完成页面截图;an identification module 703, configured to perform image analysis on the multiple page screenshots, to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots;

确定模块704,用于基于该加载开始页面截图的第一截图时间和该加载完成页面截图的第二截图时间,确定该目标页面的加载时长。The determiningmodule 704 is configured to determine the loading duration of the target page based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.

可选地,该识别模块703包括:Optionally, the identification module 703 includes:

第一识别单元,用于基于该多个页面截图中相邻页面截图的图像指纹差异,确定该加载开始页面截图,每个页面截图的图像指纹用于指示对应页面截图;a first identification unit, configured to determine the screenshot of the loading start page based on the image fingerprint difference of the screenshots of adjacent pages in the multiple page screenshots, and the image fingerprint of each page screenshot is used to indicate the corresponding page screenshot;

第二识别单元,用于基于该多个页面截图中位于末尾页面截图之前的页面截图与该末尾页面截图之间的图像指纹差异,确定该加载完成页面截图。The second identification unit is configured to determine the loading completed page screenshot based on the image fingerprint difference between the page screenshot before the last page screenshot and the last page screenshot among the plurality of page screenshots.

可选地,该第一识别单元用于:Optionally, the first identification unit is used for:

按照截图时间从前到后的顺序,从该多个页面截图中依次获取相邻页面截图;Obtain the screenshots of adjacent pages from the screenshots of the multiple pages in the order of the screenshot time from front to rear;

每获取到一对相邻页面截图,则确定获取的相邻页面截图中每个页面截图的图像指纹;Each time a pair of adjacent page screenshots are obtained, determine the image fingerprint of each page screenshot in the obtained adjacent page screenshots;

若基于该获取的相邻页面截图中每个页面截图的图像指纹,确定该获取的相邻页面截图的图像指纹差异小于或等于第一差异阈值,则返回按照截图时间从前到后的顺序,从该多个页面截图中依次获取相邻页面截图的步骤;If, based on the obtained image fingerprints of each page screenshot in the adjacent page screenshots, it is determined that the difference between the obtained image fingerprints of the adjacent page screenshots is less than or equal to the first difference threshold, then return the screenshots in the order from front to back, starting from The steps of sequentially obtaining screenshots of adjacent pages in the multiple page screenshots;

若基于该获取的相邻页面截图中每个页面截图的图像指纹,确定该获取的相邻页面截图的图像指纹差异大于第一差异阈值,则将该获取的相邻页面截图中的任一页面截图确定为该加载开始页面截图。If it is determined based on the image fingerprints of each page screenshot in the obtained adjacent page screenshots that the difference between the image fingerprints of the obtained adjacent page screenshots is greater than the first difference threshold, then any page in the obtained adjacent page screenshots will be processed. The screenshot is determined to be the screenshot of the loading start page.

可选地,该第二识别单元用于:Optionally, the second identification unit is used for:

按照截图时间从后到前的顺序,从该多个页面截图包括的位于该末尾页面截图之前的页面截图中依次获取页面截图;According to the sequence of the screenshot time from back to front, sequentially obtain page screenshots from the page screenshots located before the last page screenshot included in the multiple page screenshots;

每获取到一个页面截图,则将获取的页面截图作为第一页面截图,确定该第一页面截图的图像指纹;Each time a page screenshot is obtained, the obtained page screenshot is taken as the first page screenshot, and the image fingerprint of the first page screenshot is determined;

若基于该第一页面截图的图像指纹和该末尾页面截图的图像指纹,确定该第一页面截图与该末尾页面截图的图像指纹差异小于或等于第二差异阈值,则返回按照截图时间从后到前的顺序,从该多个页面截图包括的位于该末尾页面截图之前的页面截图中依次获取页面截图的步骤;If, based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is less than or equal to the second difference threshold, return the screenshot time from last to last Steps of sequentially acquiring page screenshots from the page screenshots that are included in the multiple page screenshots and located before the last page screenshot;

若基于该第一页面截图的图像指纹和该末尾页面截图的图像指纹,确定该第一页面截图与该末尾页面截图的图像指纹差异大于第二差异阈值,则将位于该第一页面截图之后的第二页面截图确定为该加载完成页面截图。If, based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold, the image fingerprint located after the screenshot of the first page will be The second page screenshot is determined to be a screenshot of the loading completion page.

可选地,该第二识别单元用于:Optionally, the second identification unit is used for:

确定该第二页面截图与该末尾页面截图之间的指定图像差异指标,该指定图像差异指标包括差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值中的至少一种;Determine the specified image difference index between the screenshot of the second page and the screenshot of the last page, where the specified image difference index includes the pixel ratio of the difference pixels, the difference between the pixel mean values of the difference image portion, and the pixel standard deviation of the difference image portion. at least one of the differences;

若该第二页面截图与该末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则执行将该第二页面截图确定为该加载开始页面截图的步骤。If the specified image difference index between the second page screenshot and the last page screenshot is less than or equal to the corresponding index threshold, the step of determining the second page screenshot as the loading start page screenshot is performed.

可选地,该第二识别单元用于:Optionally, the second identification unit is used for:

若该第二页面截图与该末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从后到前的顺序,从该多个页面截图包括的位于该末尾页面截图之前的页面截图中依次获取页面截图的步骤。If the specified image difference index between the screenshot of the second page and the screenshot of the last page is greater than the corresponding index threshold, return the screenshots in the order of the screenshot time from back to front, from the screenshots of the multiple pages before the screenshot of the last page. Steps to obtain page screenshots in sequence in Page Screenshots.

可选地,该截图模块702用于:Optionally, the screenshot module 702 is used for:

在加载该目标页面的过程中,按照预设截图频率对实时显示页面进行截图;In the process of loading the target page, take screenshots of the real-time display page according to the preset screenshot frequency;

在按照该预设截图频率对实时显示页面进行截图的过程中,每截图得到一个页面截图,则获取该页面截图的截图时间;During the process of taking screenshots of the real-time display page according to the preset screenshot frequency, each screenshot obtained is a page screenshot, and the screenshot time of the page screenshot is obtained;

若当前时间与该目标页面的开始加载时间之间的时长大于或等于时长阈值,则停止截图。If the duration between the current time and the start loading time of the target page is greater than or equal to the duration threshold, the screenshot is stopped.

可选地,该装置还包括:Optionally, the device also includes:

遍历模块,用于若接收到页面测试指令,则遍历测试页面列表,该测试页面列表包括多个待测试页面的页面地址;a traversal module, configured to traverse a test page list if a page test instruction is received, where the test page list includes page addresses of multiple pages to be tested;

触发模块,用于在遍历该测试页面列表的过程中,每遍历到一个待测试页面的页面地址,则将遍历到的待测试页面确定为该目标页面,并触发加载模块基于该目标页面的页面地址,开始加载该目标页面。The triggering module is used to determine the traversed to-be-tested page as the target page every time the page address of a to-be-tested page is traversed in the process of traversing the test page list, and trigger the loading module to load the page based on the target page address to start loading the target page.

可选地,该确定模块704用于:Optionally, the determiningmodule 704 is used to:

确定该第一截图时间与该第二截图时间之间的时长;determining the duration between the first screenshot time and the second screenshot time;

将该第一截图时间与该第二截图时间之间的时长,确定为该目标页面的加载时长。The duration between the first screenshot time and the second screenshot time is determined as the loading duration of the target page.

本申请实施例中,可以在加载目标页面的过程中,自动对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间,然后基于图像分析从多个页面截图中准确识别出加载开始页面截图和加载完成页面截图,并根据两者的截图时间来确定页面加载时长,这种页面加载时长的确定方法处理过程简单且准确性较高,不依赖于Appium的自动化框架和元素定位机制即可实现,从而提高了页面加载时长的确定效率和准确率。In the embodiment of the present application, during the process of loading the target page, continuous screenshots of the real-time display page can be automatically taken to obtain multiple page screenshots and the screenshot time of each page screenshot, and then accurately identify from the multiple page screenshots based on image analysis. Take a screenshot of the loading start page and the loading completion page, and determine the page loading time according to the screenshot time of the two. This method of determining the page loading time has a simple processing process and high accuracy, and does not depend on Appium's automation framework and elements. The positioning mechanism can be implemented, thereby improving the efficiency and accuracy of determining the page loading time.

需要说明的是:上述实施例提供的页面加载时长的确定装置在确定页面的加载时长时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的页面加载时长的确定装置与页面加载时长的确定方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that: when the device for determining the page loading duration provided by the above-mentioned embodiment determines the loading duration of the page, only the division of the above-mentioned functional modules is used as an example for illustration. The functional modules of the device are completed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device for determining page loading duration provided by the above embodiments and the embodiments of the method for determining page loading duration belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

图8示出了本申请一个示例性实施例提供的终端800的结构框图。该终端800可以是:智能手机、平板电脑、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio LayerIV,动态影像专家压缩标准音频层面4)播放器、笔记本电脑或台式电脑。终端800还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。FIG. 8 shows a structural block diagram of a terminal 800 provided by an exemplary embodiment of the present application. The terminal 800 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, the standard audio layer of the moving picture experts compression), MP4 (Moving Picture Experts Group Audio Layer IV, the standard audio layer of the moving picture experts compression) 4) Player, laptop or desktop computer.Terminal 800 may also be called user equipment, portable terminal, laptop terminal, desktop terminal, and the like by other names.

通常,终端800包括有:处理器801和存储器802。Generally, the terminal 800 includes: aprocessor 801 and amemory 802 .

处理器801可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器801可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器801也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central ProcessingUnit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器801可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器801还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。Theprocessor 801 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. Theprocessor 801 may adopt at least one hardware form among DSP (Digital Signal Processing, digital signal processing), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, programmable logic array) accomplish. Theprocessor 801 may also include a main processor and a coprocessor. The main processor is a processor used to process data in a wake-up state, also called a CPU (Central Processing Unit, central processing unit); A low-power processor for processing data in a standby state. In some embodiments, theprocessor 801 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is used for rendering and drawing the content that needs to be displayed on the display screen. In some embodiments, theprocessor 801 may further include an AI (Artificial Intelligence, artificial intelligence) processor, where the AI processor is used to process computing operations related to machine learning.

存储器802可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器802还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器802中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器801所执行以实现本申请中方法实施例提供的页面加载时长的确定方法。Memory 802 may include one or more computer-readable storage media, which may be non-transitory.Memory 802 may also include high-speed random access memory, as well as non-volatile memory, such as one or more disk storage devices, flash storage devices. In some embodiments, a non-transitory computer-readable storage medium in thememory 802 is used to store at least one instruction, and the at least one instruction is used to be executed by theprocessor 801 to implement the page loading provided by the method embodiments in this application. method of determining the duration.

在一些实施例中,终端800还可选包括有:外围设备接口803和至少一个外围设备。处理器801、存储器802和外围设备接口803之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口803相连。具体地,外围设备包括:射频电路804、触摸显示屏805、摄像头806、音频电路807、定位组件808和电源809中的至少一种。In some embodiments, the terminal 800 may optionally further include: aperipheral device interface 803 and at least one peripheral device. Theprocessor 801, thememory 802 and theperipheral device interface 803 may be connected by a bus or a signal line. Each peripheral device can be connected to theperipheral device interface 803 through a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of aradio frequency circuit 804 , atouch display screen 805 , acamera 806 , anaudio circuit 807 , apositioning component 808 and apower supply 809 .

外围设备接口803可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器801和存储器802。在一些实施例中,处理器801、存储器802和外围设备接口803被集成在同一芯片或电路板上;在一些其他实施例中,处理器801、存储器802和外围设备接口803中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。Theperipheral device interface 803 may be used to connect at least one peripheral device related to I/O (Input/Output) to theprocessor 801 and thememory 802 . In some embodiments,processor 801,memory 802, and peripherals interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one ofprocessor 801,memory 802, and peripherals interface 803 or The two can be implemented on a separate chip or circuit board, which is not limited in this embodiment.

射频电路804用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路804通过电磁信号与通信网络以及其他通信设备进行通信。射频电路804将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路804包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路804可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:城域网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路804还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。Theradio frequency circuit 804 is used for receiving and transmitting RF (Radio Frequency, radio frequency) signals, also called electromagnetic signals. Theradio frequency circuit 804 communicates with the communication network and other communication devices via electromagnetic signals. Theradio frequency circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, theradio frequency circuit 804 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. Theradio frequency circuit 804 may communicate with other terminals through at least one wireless communication protocol. The wireless communication protocols include, but are not limited to, metropolitan area networks, mobile communication networks of various generations (2G, 3G, 4G and 5G), wireless local area networks and/or WiFi (Wireless Fidelity, wireless fidelity) networks. In some embodiments, theradio frequency circuit 804 may further include a circuit related to NFC (Near Field Communication, short-range wireless communication), which is not limited in this application.

显示屏805用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏805是触摸显示屏时,显示屏805还具有采集在显示屏805的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器801进行处理。此时,显示屏805还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏805可以为一个,设置终端800的前面板;在另一些实施例中,显示屏805可以为至少两个,分别设置在终端800的不同表面或呈折叠设计;在再一些实施例中,显示屏805可以是柔性显示屏,设置在终端800的弯曲表面上或折叠面上。甚至,显示屏805还可以设置成非矩形的不规则图形,也即异形屏。显示屏805可以采用LCD(LiquidCrystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。Thedisplay screen 805 is used to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When thedisplay screen 805 is a touch display screen, thedisplay screen 805 also has the ability to acquire touch signals on or above the surface of thedisplay screen 805 . The touch signal can be input to theprocessor 801 as a control signal for processing. At this time, thedisplay screen 805 may also be used to provide virtual buttons and/or virtual keyboards, also referred to as soft buttons and/or soft keyboards. In some embodiments, there may be onedisplay screen 805, which is provided on the front panel of the terminal 800; in other embodiments, there may be at least twodisplay screens 805, which are respectively arranged on different surfaces of the terminal 800 or in a folded design; In still other embodiments, thedisplay screen 805 may be a flexible display screen, which is disposed on a curved surface or a folding surface of the terminal 800 . Even, thedisplay screen 805 can also be set as a non-rectangular irregular figure, that is, a special-shaped screen. Thedisplay screen 805 can be made of materials such as LCD (Liquid Crystal Display, liquid crystal display), OLED (Organic Light-Emitting Diode, organic light emitting diode).

摄像头组件806用于采集图像或视频。可选地,摄像头组件806包括前置摄像头和后置摄像头。通常,前置摄像头设置在终端的前面板,后置摄像头设置在终端的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件806还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。Thecamera assembly 806 is used to capture images or video. Optionally, thecamera assembly 806 includes a front camera and a rear camera. Usually, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth-of-field camera to realize the background blur function, the main camera It is integrated with the wide-angle camera to achieve panoramic shooting and VR (Virtual Reality, virtual reality) shooting functions or other integrated shooting functions. In some embodiments,camera assembly 806 may also include a flash. The flash can be a single color temperature flash or a dual color temperature flash. Dual color temperature flash refers to the combination of warm light flash and cold light flash, which can be used for light compensation under different color temperatures.

音频电路807可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器801进行处理,或者输入至射频电路804以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端800的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器801或射频电路804的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路807还可以包括耳机插孔。Audio circuitry 807 may include a microphone and speakers. The microphone is used to collect the sound waves of the user and the environment, convert the sound waves into electrical signals, and input them to theprocessor 801 for processing, or to theradio frequency circuit 804 to realize voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively disposed in different parts of the terminal 800 . The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from theprocessor 801 or theradio frequency circuit 804 into sound waves. The loudspeaker can be a traditional thin-film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for distance measurement and other purposes. In some embodiments,audio circuitry 807 may also include a headphone jack.

定位组件808用于定位终端800的当前地理位置,以实现导航或LBS(LocationBased Service,基于位置的服务)。定位组件808可以是基于美国的GPS(GlobalPositioning System,全球定位系统)、中国的北斗系统、俄罗斯的格雷纳斯系统或欧盟的伽利略系统的定位组件。Thepositioning component 808 is used to locate the current geographic location of the terminal 800 to implement navigation or LBS (Location Based Service, location-based service). Thepositioning component 808 may be a positioning component based on the GPS (Global Positioning System, global positioning system) of the United States, the Beidou system of China, the Grenas system of Russia, or the Galileo system of the European Union.

电源809用于为终端800中的各个组件进行供电。电源809可以是交流电、直流电、一次性电池或可充电电池。当电源809包括可充电电池时,该可充电电池可以支持有线充电或无线充电。该可充电电池还可以用于支持快充技术。Thepower supply 809 is used to power various components in theterminal 800 . Thepower source 809 may be alternating current, direct current, disposable batteries or rechargeable batteries. When thepower source 809 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

在一些实施例中,终端800还包括有一个或多个传感器810。该一个或多个传感器810包括但不限于:加速度传感器811、陀螺仪传感器812、压力传感器813、指纹传感器814、光学传感器815以及接近传感器816。In some embodiments, terminal 800 also includes one or more sensors 810 . The one or more sensors 810 include, but are not limited to, an acceleration sensor 811 , a gyro sensor 812 , a pressure sensor 813 , a fingerprint sensor 814 , an optical sensor 815 , and a proximity sensor 816 .

加速度传感器811可以检测以终端800建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器811可以用于检测重力加速度在三个坐标轴上的分量。处理器801可以根据加速度传感器811采集的重力加速度信号,控制触摸显示屏805以横向视图或纵向视图进行用户界面的显示。加速度传感器811还可以用于游戏或者用户的运动数据的采集。The acceleration sensor 811 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by theterminal 800 . For example, the acceleration sensor 811 can be used to detect the components of the gravitational acceleration on the three coordinate axes. Theprocessor 801 can control thetouch display screen 805 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 811 . The acceleration sensor 811 can also be used for game or user movement data collection.

陀螺仪传感器812可以检测终端800的机体方向及转动角度,陀螺仪传感器812可以与加速度传感器811协同采集用户对终端800的3D动作。处理器801根据陀螺仪传感器812采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。The gyroscope sensor 812 can detect the body direction and rotation angle of the terminal 800 , and the gyroscope sensor 812 can cooperate with the acceleration sensor 811 to collect 3D actions of the user on theterminal 800 . Theprocessor 801 can implement the following functions according to the data collected by the gyroscope sensor 812 : motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

压力传感器813可以设置在终端800的侧边框和/或触摸显示屏805的下层。当压力传感器813设置在终端800的侧边框时,可以检测用户对终端800的握持信号,由处理器801根据压力传感器813采集的握持信号进行左右手识别或快捷操作。当压力传感器813设置在触摸显示屏805的下层时,由处理器801根据用户对触摸显示屏805的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。The pressure sensor 813 may be disposed on the side frame of the terminal 800 and/or the lower layer of thetouch display screen 805 . When the pressure sensor 813 is disposed on the side frame of the terminal 800, the user's holding signal of the terminal 800 can be detected, and theprocessor 801 can perform left and right hand identification or shortcut operations according to the holding signal collected by the pressure sensor 813. When the pressure sensor 813 is disposed on the lower layer of thetouch display screen 805 , theprocessor 801 controls the operability controls on the UI interface according to the user's pressure operation on thetouch display screen 805 . The operability controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.

指纹传感器814用于采集用户的指纹,由处理器801根据指纹传感器814采集到的指纹识别用户的身份,或者,由指纹传感器814根据采集到的指纹识别用户的身份。在识别出用户的身份为可信身份时,由处理器801授权该用户执行相关的敏感操作,该敏感操作包括解锁屏幕、查看加密信息、下载软件、支付及更改设置等。指纹传感器814可以被设置终端800的正面、背面或侧面。当终端800上设置有物理按键或厂商Logo时,指纹传感器814可以与物理按键或厂商Logo集成在一起。The fingerprint sensor 814 is used to collect the user's fingerprint, and theprocessor 801 identifies the user's identity according to the fingerprint collected by the fingerprint sensor 814 , or the fingerprint sensor 814 identifies the user's identity according to the collected fingerprint. When the user's identity is identified as a trusted identity, theprocessor 801 authorizes the user to perform related sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. The fingerprint sensor 814 may be provided on the front, back or side of the terminal 800 . When the terminal 800 is provided with physical buttons or a manufacturer's logo, the fingerprint sensor 814 may be integrated with the physical buttons or the manufacturer's logo.

光学传感器815用于采集环境光强度。在一个实施例中,处理器801可以根据光学传感器815采集的环境光强度,控制触摸显示屏805的显示亮度。具体地,当环境光强度较高时,调高触摸显示屏805的显示亮度;当环境光强度较低时,调低触摸显示屏805的显示亮度。在另一个实施例中,处理器801还可以根据光学传感器815采集的环境光强度,动态调整摄像头组件806的拍摄参数。Optical sensor 815 is used to collect ambient light intensity. In one embodiment, theprocessor 801 may control the display brightness of thetouch display screen 805 according to the ambient light intensity collected by the optical sensor 815 . Specifically, when the ambient light intensity is high, the display brightness of thetouch display screen 805 is increased; when the ambient light intensity is low, the display brightness of thetouch display screen 805 is decreased. In another embodiment, theprocessor 801 may also dynamically adjust the shooting parameters of thecamera assembly 806 according to the ambient light intensity collected by the optical sensor 815 .

接近传感器816,也称距离传感器,通常设置在终端800的前面板。接近传感器816用于采集用户与终端800的正面之间的距离。在一个实施例中,当接近传感器816检测到用户与终端800的正面之间的距离逐渐变小时,由处理器801控制触摸显示屏805从亮屏状态切换为息屏状态;当接近传感器816检测到用户与终端800的正面之间的距离逐渐变大时,由处理器801控制触摸显示屏805从息屏状态切换为亮屏状态。A proximity sensor 816 , also called a distance sensor, is usually provided on the front panel of the terminal 800 . The proximity sensor 816 is used to collect the distance between the user and the front of the terminal 800 . In one embodiment, when the proximity sensor 816 detects that the distance between the user and the front of the terminal 800 gradually decreases, theprocessor 801 controls thetouch display screen 805 to switch from the bright screen state to the off screen state; when the proximity sensor 816 detects When the distance between the user and the front of the terminal 800 gradually increases, theprocessor 801 controls thetouch display 805 to switch from the off-screen state to the bright-screen state.

本领域技术人员可以理解,图8中示出的结构并不构成对终端800的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。Those skilled in the art can understand that the structure shown in FIG. 8 does not constitute a limitation on the terminal 800, and may include more or less components than the one shown, or combine some components, or adopt different component arrangements.

在示例性的实施例中,还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有指令,所述指令被处理器执行时实现上述页面加载时长的确定方法。In an exemplary embodiment, a computer-readable storage medium is also provided, and instructions are stored on the computer-readable storage medium, and when the instructions are executed by a processor, the above-mentioned method for determining a page loading duration is implemented.

在示例性实施例中,还提供了一种计算机程序产品,当该计算机程序产品被执行时,其用于实现上述页面加载时长的确定方法。In an exemplary embodiment, a computer program product is also provided, when the computer program product is executed, it is used to implement the above-mentioned method for determining a page loading duration.

应当理解的是,在本文中提及的“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。It should be understood that references herein to "a plurality" means two or more. "And/or", which describes the association relationship of the associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship.

本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, etc.

以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are only optional embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the protection of the present application. within the range.

Claims (12)

Translated fromChinese
1.一种页面加载时长的确定方法,其特征在于,所述方法包括:1. A method for determining a page loading duration, wherein the method comprises:基于目标页面的页面地址,开始加载所述目标页面,所述目标页面为待确定加载时长的页面;Start loading the target page based on the page address of the target page, where the target page is a page whose loading duration is to be determined;在加载所述目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;In the process of loading the target page, continuous screenshots are taken on the real-time display page to obtain multiple page screenshots and the screenshot time of each page screenshot;对所述多个页面截图进行图像分析,以从所述多个页面截图中识别出加载开始页面截图和加载完成页面截图;Perform image analysis on the multiple page screenshots to identify the loading start page screenshot and the loading completion page screenshot from the multiple page screenshots;基于所述加载开始页面截图的第一截图时间和所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长。The loading duration of the target page is determined based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.2.如权利要求1所述的方法,其特征在于,所述对所述多个页面截图进行图像分析,包括:2. The method of claim 1, wherein the performing image analysis on the plurality of page screenshots comprises:基于所述多个页面截图中相邻页面截图的图像指纹差异,确定所述加载开始页面截图,每个页面截图的图像指纹用于指示对应页面截图;Determine the screenshot of the loading start page based on the difference in image fingerprints of the screenshots of adjacent pages in the multiple page screenshots, and the image fingerprint of each page screenshot is used to indicate the corresponding page screenshot;基于所述多个页面截图中位于末尾页面截图之前的页面截图与所述末尾页面截图之间的图像指纹差异,确定所述加载完成页面截图。Based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page among the screenshots of the multiple pages, the screenshot of the page after loading is determined.3.如权利要求2所述的方法,其特征在于,所述基于所述多个页面截图中相邻页面截图的图像指纹差异,确定所述加载开始页面截图,包括:3. The method according to claim 2, wherein, determining the screenshot of the loading start page based on the image fingerprint difference of the screenshots of adjacent pages in the multiple page screenshots, comprising:按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图;According to the sequence of the screenshot time from front to back, successively obtain screenshots of adjacent pages from the plurality of page screenshots;每获取到一对相邻页面截图,则确定获取的相邻页面截图中每个页面截图的图像指纹;Each time a pair of adjacent page screenshots are obtained, determine the image fingerprint of each page screenshot in the obtained adjacent page screenshots;若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异小于或等于第一差异阈值,则返回按照截图时间从前到后的顺序,从所述多个页面截图中依次获取相邻页面截图的步骤;If, based on the obtained image fingerprints of each page screenshot in the adjacent page screenshots, it is determined that the difference between the obtained image fingerprints of the adjacent page screenshots is less than or equal to the first difference threshold, then return the screenshots in the order from front to back. , the steps of successively obtaining screenshots of adjacent pages from the multiple page screenshots;若基于所述获取的相邻页面截图中每个页面截图的图像指纹,确定所述获取的相邻页面截图的图像指纹差异大于第一差异阈值,则将所述获取的相邻页面截图中的任一页面截图确定为所述加载开始页面截图。If it is determined based on the image fingerprint of each page screenshot in the obtained adjacent page screenshots that the difference between the image fingerprints of the obtained adjacent page screenshots is greater than the first difference threshold, A screenshot of any page is determined to be a screenshot of the loading start page.4.如权利要求2所述的方法,其特征在于,所述基于所述多个页面截图中位于末尾页面截图之前的页面截图与所述末尾页面截图之间的图像指纹差异,确定所述加载完成页面截图,包括:4. The method according to claim 2, wherein, determining the loading based on the image fingerprint difference between the screenshot of the page before the screenshot of the last page and the screenshot of the last page in the plurality of page screenshots. Complete a screenshot of the page, including:按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图;According to the sequence of the screenshot time from back to front, sequentially obtain page screenshots from the page screenshots located before the last page screenshot included in the plurality of page screenshots;每获取到一个页面截图,则将获取的页面截图作为第一页面截图,确定所述第一页面截图的图像指纹;Each time a page screenshot is obtained, the obtained page screenshot is taken as the first page screenshot, and the image fingerprint of the first page screenshot is determined;若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异小于或等于第二差异阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤;If, based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page, it is determined that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is less than or equal to the second difference threshold, then return to the screen according to the screenshot. In the order of time from back to front, the steps of sequentially acquiring page screenshots from the page screenshots located before the last page screenshot included in the multiple page screenshots;若基于所述第一页面截图的图像指纹和所述末尾页面截图的图像指纹,确定所述第一页面截图与所述末尾页面截图的图像指纹差异大于第二差异阈值,则将位于所述第一页面截图之后的第二页面截图确定为所述加载完成页面截图。If it is determined based on the image fingerprint of the screenshot of the first page and the image fingerprint of the screenshot of the last page that the difference between the image fingerprints of the screenshot of the first page and the screenshot of the last page is greater than the second difference threshold The second page screenshot after the one page screenshot is determined to be the loading completed page screenshot.5.如权利要求4所述的方法,其特征在于,所述将位于所述第一页面截图之后的第二页面截图确定为所述加载完成页面截图之前,还包括:5. The method of claim 4, wherein determining the second page screenshot after the first page screenshot as before the loading completed page screenshot, further comprising:确定所述第二页面截图与所述末尾页面截图之间的指定图像差异指标,所述指定图像差异指标包括差异像素的像素占比、差异图像部分的像素均值的差值以及差异图像部分的像素标准差的差值中的至少一种;Determine the specified image difference index between the screenshot of the second page and the screenshot of the last page, where the specified image difference index includes the pixel ratio of the difference pixels, the difference between the pixel mean values of the difference image part, and the pixels of the difference image part at least one of the differences in standard deviations;若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标小于或等于对应的指标阈值,则执行将所述第二页面截图确定为所述加载开始页面截图的步骤。If the specified image difference index between the second page screenshot and the last page screenshot is less than or equal to the corresponding index threshold, the step of determining the second page screenshot as the loading start page screenshot is performed.6.如权利要求5所述的方法,其特征在于,所述确定所述第一页面截图与所述末尾页面截图之间的指定图像差异指标之后,还包括:6. The method according to claim 5, wherein after determining the specified image difference index between the screenshot of the first page and the screenshot of the last page, the method further comprises:若所述第二页面截图与所述末尾页面截图之间的指定图像差异指标大于对应的指标阈值,则返回按照截图时间从后到前的顺序,从所述多个页面截图包括的位于所述末尾页面截图之前的页面截图中依次获取页面截图的步骤。If the specified image difference index between the screenshot of the second page and the screenshot of the last page is greater than the corresponding index threshold, return to the order of the screenshot time from the back to the front, from the screenshots of the multiple pages including those located in the Follow the steps to obtain page screenshots in the page screenshot before the last page screenshot.7.如权利要求1-6任一所述的方法,其特征在于,所述在加载所述目标页面的过程中,对实时显示页面进行连续截图,包括:7. The method according to any one of claims 1-6, wherein, in the process of loading the target page, continuously taking screenshots of the real-time display page, comprising:在加载所述目标页面的过程中,按照预设截图频率对实时显示页面进行截图;In the process of loading the target page, screenshot the real-time display page according to the preset screenshot frequency;在按照所述预设截图频率对实时显示页面进行截图的过程中,每截图得到一个页面截图,则获取所述页面截图的截图时间;In the process of taking a screenshot of the real-time display page according to the preset screenshot frequency, every screenshot is obtained a page screenshot, then the screenshot time of the page screenshot is obtained;若当前时间与所述目标页面的开始加载时间之间的时长大于或等于时长阈值,则停止截图。If the duration between the current time and the start loading time of the target page is greater than or equal to the duration threshold, the screenshot is stopped.8.如权利要求1-6任一所述的方法,其特征在于,所述基于目标页面的页面地址,开始加载所述目标页面之前,还包括:8. The method according to any one of claims 1-6, wherein, before starting to load the target page based on the page address of the target page, the method further comprises:若接收到页面测试指令,则遍历测试页面列表,所述测试页面列表包括多个待测试页面的页面地址;If a page test instruction is received, traverse a test page list, where the test page list includes page addresses of multiple pages to be tested;在遍历所述测试页面列表的过程中,每遍历到一个待测试页面的页面地址,则将遍历到的待测试页面确定为所述目标页面,并执行基于所述目标页面的页面地址,开始加载所述目标页面的步骤。In the process of traversing the list of test pages, each time a page address of a page to be tested is traversed, the page to be tested that has been traversed is determined as the target page, and the page address based on the target page is executed to start loading the target page steps.9.如权利要求1-6任一所述的方法,其特征在于,所述基于所述加载开始页面截图的第一截图时间和所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长,包括:9. The method according to any one of claims 1-6, wherein the target is determined based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot The load time of the page, including:确定所述第一截图时间与所述第二截图时间之间的时长;determining the duration between the first screenshot time and the second screenshot time;将所述第一截图时间与所述第二截图时间之间的时长,确定为所述目标页面的加载时长。The duration between the first screenshot time and the second screenshot time is determined as the loading duration of the target page.10.一种页面加载时长的确定装置,其特征在于,所述装置包括:10. A device for determining a page loading duration, wherein the device comprises:加载模块,用于基于目标页面的页面地址,开始加载所述目标页面,所述目标页面为待确定加载时长的页面;a loading module, configured to start loading the target page based on the page address of the target page, where the target page is a page whose loading duration is to be determined;截图模块,用于在加载所述目标页面的过程中,对实时显示页面进行连续截图,得到多个页面截图以及每个页面截图的截图时间;A screenshot module, used for continuously taking screenshots of the real-time display page in the process of loading the target page, to obtain multiple page screenshots and the screenshot time of each page screenshot;识别模块,用于基于所述目标页面的标准加载开始页面和标准加载完成页面,从所述多个页面截图中识别加载开始页面截图和加载完成页面截图;an identification module, configured to identify the screenshot of the loading start page and the screenshot of the loading completion page from the screenshots of the multiple pages based on the standard loading start page and the standard loading completion page of the target page;确定模块,用于基于所述加载开始页面截图的第一截图时间以及所述加载完成页面截图的第二截图时间,确定所述目标页面的加载时长。A determining module, configured to determine the loading duration of the target page based on the first screenshot time of the loading start page screenshot and the second screenshot time of the loading completed page screenshot.11.一种电子设备,其特征在于,所述电子设备包括:11. An electronic device, characterized in that the electronic device comprises:处理器;processor;用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;其中,所述处理器被配置为执行权利要求1-9所述的任一项方法的步骤。wherein the processor is configured to perform the steps of any of the methods of claims 1-9.12.一种计算机可读存储介质,所述计算机可读存储介质上存储有指令,其特征在于,所述指令被处理器执行时实现权利要求1-9所述的任一项方法的步骤。12. A computer-readable storage medium storing instructions on the computer-readable storage medium, wherein when the instructions are executed by a processor, the steps of any one of the methods of claims 1-9 are implemented.
CN202010615975.0A2020-06-302020-06-30 Method, device, device and storage medium for determining page loading timePendingCN111752817A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202010615975.0ACN111752817A (en)2020-06-302020-06-30 Method, device, device and storage medium for determining page loading time

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202010615975.0ACN111752817A (en)2020-06-302020-06-30 Method, device, device and storage medium for determining page loading time

Publications (1)

Publication NumberPublication Date
CN111752817Atrue CN111752817A (en)2020-10-09

Family

ID=72676796

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202010615975.0APendingCN111752817A (en)2020-06-302020-06-30 Method, device, device and storage medium for determining page loading time

Country Status (1)

CountryLink
CN (1)CN111752817A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111581558A (en)*2020-04-272020-08-25北京达佳互联信息技术有限公司Method, device and equipment for determining page loading duration and storage medium
CN112241502A (en)*2020-10-162021-01-19北京字节跳动网络技术有限公司Page loading detection method and device
CN113177176A (en)*2021-05-212021-07-27脸萌有限公司Feature construction method, content display method and related device
CN113688043A (en)*2021-08-252021-11-23北京三快在线科技有限公司Application program testing method, device, server, iOS device and medium
CN113778825A (en)*2021-08-242021-12-10北京达佳互联信息技术有限公司Method and device for determining page index parameters, storage medium and electronic equipment
CN114827754A (en)*2022-02-232022-07-29阿里巴巴(中国)有限公司Method and device for detecting video first frame time
CN117076284A (en)*2023-10-182023-11-17荣耀终端有限公司Page loading time length detection method, equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110825456A (en)*2019-11-012020-02-21北京博睿宏远数据科技股份有限公司Loading time calculation method and device, computer equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110825456A (en)*2019-11-012020-02-21北京博睿宏远数据科技股份有限公司Loading time calculation method and device, computer equipment and storage medium

Cited By (12)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111581558A (en)*2020-04-272020-08-25北京达佳互联信息技术有限公司Method, device and equipment for determining page loading duration and storage medium
CN111581558B (en)*2020-04-272024-03-05北京达佳互联信息技术有限公司Page loading time length determining method, device, equipment and storage medium
CN112241502A (en)*2020-10-162021-01-19北京字节跳动网络技术有限公司Page loading detection method and device
CN113177176A (en)*2021-05-212021-07-27脸萌有限公司Feature construction method, content display method and related device
CN113778825A (en)*2021-08-242021-12-10北京达佳互联信息技术有限公司Method and device for determining page index parameters, storage medium and electronic equipment
CN113778825B (en)*2021-08-242025-01-07北京达佳互联信息技术有限公司 Method and device for determining page index parameters, storage medium and electronic device
CN113688043A (en)*2021-08-252021-11-23北京三快在线科技有限公司Application program testing method, device, server, iOS device and medium
CN113688043B (en)*2021-08-252022-07-26北京三快在线科技有限公司Application program testing method, device, server, iOS device and medium
CN114827754A (en)*2022-02-232022-07-29阿里巴巴(中国)有限公司Method and device for detecting video first frame time
CN114827754B (en)*2022-02-232023-09-12阿里巴巴(中国)有限公司Video first frame time detection method and device
CN117076284A (en)*2023-10-182023-11-17荣耀终端有限公司Page loading time length detection method, equipment and storage medium
CN117076284B (en)*2023-10-182024-04-05荣耀终端有限公司 Page loading time detection method, device and storage medium

Similar Documents

PublicationPublication DateTitle
CN111752817A (en) Method, device, device and storage medium for determining page loading time
CN110674022B (en)Behavior data acquisition method and device and storage medium
CN110837473B (en)Application program debugging method, device, terminal and storage medium
CN110059686B (en)Character recognition method, device, equipment and readable storage medium
CN111857793A (en)Network model training method, device, equipment and storage medium
CN110839128A (en) Photographic behavior detection method, device and storage medium
CN111177137A (en)Data deduplication method, device, equipment and storage medium
CN114064450A (en)Application program testing method and device, electronic equipment and storage medium
WO2021027890A1 (en)License plate image generation method and device, and computer storage medium
CN109783176B (en)Page switching method and device
CN109684123B (en)Problem resource positioning method, device, terminal and storage medium
CN114720932A (en)Battery management system signal sampling precision testing method and device, upper computer and storage medium
CN112765988A (en)Entity linking method, device and computer storage medium
CN111752719A (en) Method and Device for Detecting Caton
CN111797017A (en)Method and device for storing log, test equipment and storage medium
CN112100528A (en)Method, device, equipment and medium for training search result scoring model
CN113342645B (en)Method, device, equipment and storage medium for testing business function
CN110321059B (en)Data processing method, device and computer readable storage medium
CN110992954A (en)Method, device, equipment and storage medium for voice recognition
CN112308104A (en)Abnormity identification method and device and computer storage medium
CN112463603B (en) Memory leak detection method, device, terminal and storage medium
CN112181915A (en)Method, device, terminal and storage medium for executing service
CN113590877B (en)Method and device for acquiring annotation data
CN111061918A (en)Graph data processing method and device and storage medium
CN110851435B (en)Data storage method and device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp