Detailed Description
In the prior art, in the process of providing services to the outside of an application, a target page in the application is generally monitored to determine whether to correctly display target content in the target page of the application.
In general, a method capable of being manually checked is adopted when monitoring a target page of an application. Taking the example of whether the logo and the document of the second application are correctly displayed in the target page of the first application, the related auditor of the second application can manually audit the target page of the first application to judge whether the logo and the document of the second application are correctly displayed in the target page of the first application.
However, in practical application, although the manual auditing method is simpler, the whole auditing process needs to spend a great deal of time and manpower resources, so that the method is not easy to realize, and therefore, whether the target content is correctly displayed in the target page cannot be effectively monitored.
In order to solve the above technical problems, an embodiment of the present application provides a content monitoring method and apparatus, where the method includes: acquiring a picture corresponding to a target page; identifying the picture and determining layout parameters of target content in the picture; based on the layout parameters, whether the target content is correctly displayed in the target page is determined.
According to the technical scheme provided by the embodiment of the application, when the content in the target page is monitored, the layout parameters of the target content in the picture corresponding to the target page can be identified through the picture identification method, and whether the target content is correctly displayed in the target page is judged based on the layout parameters of the target content, so that the intelligent monitoring of the target content in the target page can be realized.
In order to make the technical solution of the present application better understood by those skilled in the art, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, shall fall within the scope of the application.
It should be noted that, in the application scenario provided by the embodiment of the present application, the second application may monitor whether the logo and the document of the second application are correctly displayed in the target page of the first application, where in the application scenario, the target page described in the embodiment of the present application may be understood as the target page in the first application, and the target content may be understood as the logo and the document of the second application. The target page in the first application may be understood as a page that the second application requires the first application to display its logo and text, or may also be understood as a page designated by the first application and used for displaying its logo and text, which is not specifically limited, where the logo of the second application may be regarded as a target icon included in the target content, and the text of the second application may be regarded as a target text included in the target content.
Besides the application scenario described above, the technical solution provided by the embodiment of the present application may also be used in other application scenarios that need to monitor whether the target content is correctly displayed in the target page, which is not illustrated here.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
FIG. 1 is a flow chart of a content monitoring method according to an embodiment of the present application. The content monitoring method is as follows.
S102: and obtaining a picture corresponding to the target page.
In S102, when whether the target content is correctly displayed in the target page of the target application needs to be monitored, a picture corresponding to the target page may be acquired. The picture corresponding to the target page may include content in the target page.
The method for obtaining the picture corresponding to the target page in the embodiment may include the following steps:
first, a target application is run at a test terminal.
Specifically, the target application may be installed in a test terminal using a script, and the test terminal may be a smart phone, a simulator, or other terminals capable of running the application.
After the target application is installed in the test terminal, the target application can be run in the test terminal by utilizing a script and an open source software app, and the specific steps include: and sending a starting instruction to the open source software appium by utilizing the script, and starting and running the target application by the open source software appium after receiving the starting instruction.
Second, a target page of the target application is accessed.
After the test terminal runs the target application, the script and the open source software app ium can be utilized to operate the target application, so that the target page in the target application can be accessed. Specifically, assuming that the target page is a certain page after logging in the target application, the specific steps for accessing the target page are as follows:
transmitting an instruction for opening a login page to an open source software app ium by utilizing a script, and opening the login page of a target application after the open source software app ium receives the instruction; after a login page is opened, a login instruction comprising a user name and a password is sent to the open source software appium by utilizing a script, and after the open source software appium receives the login instruction, a target application is logged in based on the user name and the password; after logging in the target application, the script is utilized to send an access instruction to a target page in the target application to the open source software appium, and after receiving the access instruction, the open source software appium opens the target page in the target application to realize access to the target page in the target application.
And thirdly, capturing a target page to obtain a picture corresponding to the target page.
When the target application is subjected to screenshot, the method can be realized by utilizing a script and an open source software app, and the specific steps are as follows: after a target page of a target application is opened, a screenshot instruction is sent to an open source software app ium by utilizing a script, and after the open source software app ium receives the screenshot instruction, the target page is subjected to screenshot, and a picture corresponding to the target page is obtained.
And finally, obtaining a picture corresponding to the target page.
It should be understood that, in this embodiment, the picture corresponding to the target page may be obtained through other implementation manners, which are not illustrated here.
After the picture corresponding to the target page is acquired, S104 may be executed.
S104: and identifying the picture and determining the layout parameters of the target content in the picture.
In S104, after the picture corresponding to the target page is obtained, the picture may be identified, and the layout parameters of the target content in the picture may be determined. The layout parameters of the target content in the picture can be understood as information related to the layout of the target content in the target page in the picture, and can be specifically used for judging whether the target content is correctly displayed in the target page.
In this embodiment, the target content may include a target icon and a target text, and when determining a layout parameter of the target content in the picture, the layout parameter of the target icon in the picture and the layout parameter of the target text in the picture may be determined. The layout parameters of the target icon in the picture may include position information of the target icon in the picture, and the layout parameters of the target text in the picture may include position information of the target text in the picture.
When determining the layout parameters of the target icon in the picture, the method can be realized based on an icon identification model obtained through pre-training. In this embodiment, the icon recognition model may be obtained based on training layout parameters of the target icon in a plurality of sample pictures, and the specific implementation manner is as follows:
first, a plurality of sample icons is acquired.
The plurality of sample pictures can comprise target icons, and preferably, in order to facilitate the icon recognition model to recognize the target icons with different layout parameters, the layout parameters of the target icons in the plurality of acquired sample pictures can be different.
Secondly, the layout parameters of the target icons in a plurality of sample pictures are obtained.
The layout parameters of the target icons in the plurality of sample pictures can be obtained in a labeling mode.
And finally, learning and training the target icons in the plurality of sample pictures based on layout parameters of the target icons in the plurality of sample pictures to obtain an icon identification model.
After the icon identification model is obtained through training, when the picture is identified and the layout parameters of the target icon in the picture are determined, the picture can be used as the input of the model, and the output of the model is the layout parameters of the target icon in the picture.
It should be noted that, in this embodiment, the layout parameters of the target icon in the picture may have two cases, one is that the layout parameters of the target icon in the picture are not null, and the other is that the layout parameters of the target icon in the picture are null, and when the layout parameters are not null, it may be stated that the target icon is identified in the picture; when the layout parameter is empty, it may be stated that the target icon is not recognized in the picture. The present embodiment may be described by taking an example in which the layout parameters are not null.
Optionally, when the layout parameters of the target icon in the picture are identified based on the icon identification model, in order to avoid false identification, the accuracy of the identification result (which may be given by the icon identification model) may be further determined, and if the accuracy of the identification result is greater than or equal to a set value (which may be determined according to the actual situation), the identification result may be considered as not being false identification; if the accuracy of the recognition result is smaller than the set value, the recognition result may be considered to be erroneous, and at this time, the erroneous recognition result may be ignored.
When determining the layout parameters of the target text in the picture, the embodiment can be realized based on a text recognition technology, and the specific steps are as follows:
firstly, recognizing a picture based on a character recognition technology, and obtaining layout parameters of texts in the picture, wherein the character recognition technology can be an optical character recognition (OCR, optical Character Recognition) technology.
And secondly, matching the identified text with the target text, if the matching is successful, determining that the target text is included in the picture, and if the matching is failed, determining that the target text is not included in the picture. The embodiment may be described by taking the example that the picture includes the target text.
Finally, when the picture is determined to comprise the target text, the layout parameters of the target text in the picture can be obtained according to the text recognition result of the target text.
After the layout parameters of the target content in the picture are identified based on the above-described method, S106 may be performed.
Optionally, if the layout parameter of the target icon in the picture is null (i.e. the target icon is not identified in the picture) or the target text is not identified in the picture, it may be directly determined that the target content is not correctly displayed in the target page, without executing S106.
S106: based on the layout parameters, whether the target content is correctly displayed in the target page is determined.
In S106, it may be determined whether the target content is correctly shown in the target page based on the layout parameters of the target icon included in the target content in the picture and the layout parameters of the target text in the picture. The layout parameters of the target icon may include position information of the target icon in the picture, and the layout parameters of the target text may include position information of the target text in the picture.
When determining whether the target content is correctly displayed in the target page based on the position information of the target icon in the picture and the position information of the target text in the picture, the method may include the steps of:
first, dividing a target icon and a target text to obtain at least one group, wherein the distance between the target icon and the target text included in one group is within a set distance.
In this embodiment, considering that when the target page correctly displays the target icon and the target text included in the target content, the distance between the target icon and the target text is within a set distance, for example, the target icon is above the target text and the distance between the target icon and the target text is within the set distance, when determining whether the target page correctly displays the target content, the target icon and the target text may be divided based on the position information of the target icon in the picture and the position information of the target text in the picture, and the target text and the target icon with the distance within the set distance are taken as a group, so as to obtain at least one group. The set distance may be determined according to practical situations, and is not specifically limited herein.
Secondly, for one of the groups, whether the target icon and the target text in the group are correctly displayed in the target page can be determined based on the position information of the target icon and the position information of the target text in the group.
In this embodiment, when the target icons and the target texts in the group are correctly displayed in the target page, the sizes of the target icons in the group conform to the preset sizes, and the target icons and the target texts in the group are located in the preset area of the target page, so that the target icons and the target texts in the group can be determined whether to correctly display the target icons and the target texts in the group in the target page by taking the target icons and the target texts as the judgment criteria.
Specifically, the location information of the target icon in the picture and the location information of the target text in the picture may be used to determine the regions of the target icon and the target text in the picture, and the size of the target icon may be determined based on the location information of the target icon, where, when the size of the target icon is determined, parameters such as the length and the width of the target icon may be calculated based on the abscissa and the ordinate included in the location information of the target icon, so as to obtain the size of the target icon.
After the areas of the target icons and the target texts in the pictures and the sizes of the target icons are obtained, whether the target icons and the target texts are located in the preset areas of the pictures or not can be judged, whether the sizes of the target icons accord with the preset sizes or not can be judged, and if yes, the target icons and the target texts included in the groups can be correctly displayed in the target pages; if not, that is, the target icon and the target text are not located in the preset area of the picture, or the size of the target icon does not accord with the preset size, it can be determined that the target icon and the target text in the group are not correctly displayed in the target page.
So far, for one of the groupings, it may be determined whether the target icon and the target text included in the grouping are correctly presented in the target page. Whether the target icon and the target text included in the other group are correctly presented in the target page can be determined based on the same method, and a description thereof will not be repeated.
Optionally, in the process of determining whether the target content is correctly displayed in the target page, when the target text and the target icon are grouped, if at least one group is not obtained, it may be indicated that the distance between the target icon and the target text is not within the set distance, and at this time, it may be directly determined that the target content is not correctly displayed in the target page.
If at least one group is obtained, considering that the number of the target icons and the target texts included in one group is one when the target texts and the target icons in the target content are correctly displayed by the target page, judging whether the number of the target icons and the target texts included in one group is one or not according to one group, if so, further judging whether the target texts and the target icons included in the group are correctly displayed by the target page by the method; if not, the target icons and the target texts in the group which are not correctly displayed in the target page can be directly determined without further judgment.
Optionally, after determining whether the target icon and the target text are correctly displayed in the target page, notification information may also be generated, so that a related person may determine whether the target icon and the target text are correctly displayed in the target page. The notification information may be mail, short message, etc.
For ease of understanding the entire solution, reference may be made to fig. 2.
Fig. 2 is a flow chart of a content monitoring method according to an embodiment of the application. The content monitoring method shown in fig. 2 may include the steps of:
s201: and obtaining a picture corresponding to the target page.
The picture corresponding to the target page can comprise content in the target page.
When obtaining a picture corresponding to a target page, one implementation method includes: running a target application at a test terminal; accessing a target page of a target application; screenshot is carried out on the target page, and a picture corresponding to the target page is obtained; and obtaining a picture corresponding to the target page.
S202: and identifying the picture based on the icon identification model obtained through pre-training, and determining the layout parameters of the target icon in the picture.
The icon recognition model may be trained based on layout parameters of the target icon in a plurality of sample pictures, and a specific implementation may refer to the relevant content recorded in the embodiment shown in fig. 1, which is not repeated here. The layout parameters of the target icon in the picture may include position information of the target icon in the picture.
When the picture is identified based on the icon identification model, the picture can be used as the input of the model, and the output of the model is the layout parameter of the target icon in the picture.
S203: and carrying out character recognition on the picture, and determining layout parameters of the target text in the picture.
Specifically, first, a layout parameter of a text in a picture in the picture may be identified based on a text recognition technique, the layout parameter including location information; and secondly, if the matching between the identified text and the target text is successful, determining that the target text is included in the picture, and obtaining layout parameters of the target text in the picture based on a text identification result.
S204: and grouping the target icon and the target text to obtain at least one group.
Specifically, the target icon and the target text within a set distance may be divided into a group based on a layout parameter of the target icon in the picture and a layout parameter of the target text in the picture, so as to obtain at least one group, where the layout parameter of the target icon in the picture includes position information of the target icon in the picture, the layout parameter of the target text in the picture includes position information of the target text in the picture, and the set distance may be determined according to an actual situation.
S205: for one of the groupings, the regions of the target icon and target text included in the grouping in the picture, and the size of the target icon are determined.
In S205, it may be determined whether the target icon and the target text included in the group are correctly shown in the target page, taking one of the groups as an example.
Specifically, the areas of the target icon and the target text in the picture may be determined based on the position information of the target icon and the target text included in the group, and the size of the target icon may be determined based on the position information of the target icon included in the group.
S206: and judging whether the target icon and the target text in the group are positioned in a preset area of the picture, wherein the size of the target icon accords with the preset size.
If yes, S207 may be performed; if not, i.e. the target icon and the target text in the group are not located in the preset area, or the size of the target icon does not conform to the preset size, S208 may be executed.
S207: and determining the target icon and the target text in the correct display group in the target page.
S208: and determining that the target icon and the target text are not correctly displayed in the target page.
Optionally, in S202 above, if the layout parameter of the target icon in the picture is empty, S208 may be executed; in S203 above, if the target text is not recognized in the picture, S208 may be executed; in S204, if at least one group is not obtained, S208 may be executed, and if the number of target icons and target texts included in the obtained group does not satisfy the requirement, S208 may be executed.
According to the technical scheme provided by the embodiment of the application, when the content in the target page is monitored, the layout parameters of the target content in the picture corresponding to the target page can be identified through the picture identification method, and whether the target content is correctly displayed in the target page is judged based on the layout parameters of the target content, so that the intelligent monitoring of the target content in the target page can be realized.
The foregoing describes certain embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Fig. 3 is a schematic structural view of an electronic device according to an embodiment of the present application. Referring to fig. 3, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 3, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, and forms the content monitoring device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
acquiring a picture corresponding to a target page;
identifying the picture and determining layout parameters of target content in the picture;
based on the layout parameters, whether the target content is correctly displayed in the target page is determined.
The method performed by the content monitoring device disclosed in the embodiment of fig. 3 of the present application may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
The electronic device may also execute the methods of fig. 1 and fig. 2, and implement the functions of the content monitoring device in the embodiments shown in fig. 1 and fig. 2, which are not described herein again.
Of course, other implementations, such as a logic device or a combination of hardware and software, are not excluded from the electronic device of the present application, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or a logic device.
The embodiments of the present application also provide a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the methods of the embodiments shown in fig. 1 and 2, and in particular to perform the operations of:
acquiring a picture corresponding to a target page;
identifying the picture and determining layout parameters of target content in the picture;
based on the layout parameters, whether the target content is correctly displayed in the target page is determined.
Fig. 4 is a schematic structural view of a content monitoring apparatus 40 according to an embodiment of the present application. Referring to fig. 4, in a software implementation, the content monitoring device 40 may include: an acquisition unit 41, an identification unit 42, and a determination unit 43, wherein:
an acquisition unit 41 that acquires a picture corresponding to a target page;
the identifying unit 42 identifies the picture and determines the layout parameters of the target content in the picture;
the determining unit 43 determines whether the target content is correctly presented in the target page based on the layout parameters.
Optionally, the target content includes a target icon and a target text.
Optionally, the identifying unit 42 identifies the picture, and determines layout parameters of the target content in the picture, including:
and identifying the picture based on an icon identification model obtained through pre-training, determining layout parameters of the target icon in the picture, and training the icon identification model based on the layout parameters of the target icon in a plurality of sample pictures.
Optionally, the layout parameter of the target icon in the picture includes position information, and the layout parameter of the target text in the picture includes position information.
Optionally, the determining unit 43 determines whether the target content is correctly displayed in the target page, including:
dividing the target icon and the target text to obtain at least one group, wherein the distance between the target icon and the target text in one group is within a set distance;
for one of the packets, the following is performed:
and determining whether the target icon and the target text included in the group are correctly displayed in the target page or not based on the position information of the target icon and the target text included in the group.
Optionally, the determining unit 43 determines whether the target icon and the target text included in the group are correctly displayed in the target page, including:
judging whether the target icons and the target texts included in the group are positioned in a preset area of the picture or not based on the position information of the target icons and the target texts included in the group, and judging whether the sizes of the target icons included in the group accord with the preset sizes or not;
if yes, determining that the target icons and the target texts included in the groups are correctly displayed in the target page;
if not, determining that the target icons and the target texts included in the group are not correctly displayed in the target page.
Optionally, the obtaining unit 41 obtains a picture corresponding to the target page, including:
running a target application at a test terminal;
accessing a target page of the target application;
screenshot is carried out on the target page, and a picture corresponding to the target page is obtained;
and obtaining a picture corresponding to the target page.
The content monitoring device 40 provided in the embodiment of the present application may also execute the methods of fig. 1 and fig. 2, and implement the functions of the content monitoring device in the embodiment shown in fig. 1 and fig. 2, which are not described herein again.
In summary, the foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The embodiments of the present application are described in a progressive manner, and the same and similar parts of the embodiments are all referred to each other, and each embodiment is mainly described in the differences from the other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.