Disclosure of Invention
The invention aims to provide a visual embedded point testing method and device, which can realize visualization of embedded point testing results and improve embedded point testing efficiency.
In order to achieve the above object, an aspect of the present invention provides a visual embedded point testing method, including:
dynamically injecting a monitoring script into a target page of a buried point to be detected to acquire buried point information in the target page;
intercepting a log message reported by a to-be-detected buried point in a target page through a plug-in RST;
and receiving the buried point information and the log message to obtain a buried point test result, and visually displaying the buried point test result in a tool window form.
Preferably, the method further comprises the following steps:
and limiting the default jump behavior of the target page in the browser so that the default jump behavior is only used for executing jump in the tool window.
Preferably, the method for limiting the default jump behavior of the target page in the browser so that the target page only executes the jump in the tool window comprises the following steps:
when the target page is a tag skip, acquiring a click event of the target page through a monitoring script, and positioning a latest parent tag of the clicked event;
extracting a target jump address based on the href attribute of the latest parent label, returning to a tool window, executing corresponding jump behaviors by the tool window and carrying out buried point test on a new target page again;
when the target page is a non-tag jump, intercepting an access log in the target page through a plug-in RST;
and extracting a target jump address based on a curl field of the access log, returning to the tool window, executing corresponding jump behaviors by the tool window and carrying out buried point test on a new target page again.
Further, before dynamically injecting a monitoring script into the target page of the buried point to be detected to acquire the buried point information in the target page, the method further includes:
and installing a plug-in RST in the browser and simultaneously starting an interception and monitoring function.
Preferably, the method for dynamically injecting the monitoring script into the target page to be detected with the buried point to acquire the buried point information in the target page includes:
when the target page is detected, informing an acquisition script in the target page to pull a monitoring script;
and traversing the DOM tree of the target page by using the monitoring script to obtain the DOM element of the current page, analyzing and sorting to obtain the embedded point information, and returning the embedded point information to the tool window.
Preferably, the method for intercepting the log messages reported by the to-be-detected buried points in the target page through the plug-in RST comprises the following steps:
intercepting an http request reported by a buried point to be detected in a target page through a webRequest API in a plug-in RST to obtain a log message corresponding to the buried point to be detected.
Illustratively, the buried point information includes import information and/or location information of a collection script in a target page, and the log message includes one or more of log detail data, field dimension value information, and pit bit information.
Preferably, the method for receiving the buried point information and the log message to obtain a buried point test result and visually displaying the buried point test result in a tool window form includes:
and integrating and outputting one or more of the lead-in information, the position information, the log detailed data, the field dimension value information and the pit position information of the acquisition script, and displaying and outputting the integrated information in an independent window form.
Preferably, the monitoring script interacts with the tool window data in a Postmessage mode, and the plug-in RST interacts with the tool window data in the Postmessage mode through a sendMessage API.
Compared with the prior art, the visual embedded point testing method provided by the invention has the following beneficial effects:
the visual embedded point testing method provided by the invention comprises the steps of firstly constructing a tool, then dynamically injecting a monitoring script into a target page containing embedded points to be detected by using the tool to acquire embedded point information in the target page, and intercepting log messages reported by the embedded points to be detected in the target page through a plug-in RST (first-class version), wherein the embedded point information comprises introduction information and position information of the acquisition script in the target page, the log messages comprise log detailed data, field dimension value information and pit position information, and finally, the acquired embedded point information and the log messages are collected and integrated to obtain an embedded point testing result which is visually displayed in a tool window form.
Therefore, the target page is embedded into the tool, the visual display of the target page embedded point test result can be realized, the whole process is convenient and efficient, and the method can be completed without professional technicians.
Another aspect of the present invention provides a visual embedded point testing apparatus, which is applied to the visual embedded point testing method mentioned in the above technical solution, and the apparatus includes:
the acquisition module is used for dynamically injecting a monitoring script into a target page of the buried point to be detected so as to acquire buried point information in the target page;
the intercepting module is used for dynamically injecting a monitoring script into a target page of the buried point to be detected so as to acquire buried point information in the target page;
and the display output module is used for receiving the embedded point information and the log message to obtain an embedded point test result and visually displaying the embedded point test result in a tool window form.
Compared with the prior art, the visual embedded point testing device provided by the invention has the same beneficial effect as the visual embedded point testing method provided by the technical scheme, and the detailed description is omitted here.
A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, performing the steps of the above visual buried point testing method.
Compared with the prior art, the beneficial effect of the computer-readable storage medium provided by the invention is the same as that of the visual embedded point testing method provided by the technical scheme, and the detailed description is omitted here.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Referring to fig. 1 and fig. 2, the present embodiment provides a visual embedded point testing method, including:
dynamically injecting a monitoring script into a target page of a buried point to be detected so as to acquire buried point information in the target page; intercepting a log message reported by a to-be-detected buried point in a target page through a plug-in RST; and receiving the embedded point information and the log message to obtain an embedded point test result, and visually displaying the embedded point test result in a tool window form.
According to the visual embedded point testing method, a tool is constructed, then a monitoring script is dynamically injected into a target page containing embedded points to be detected by the tool to acquire embedded point information in the target page, a plug-in RST is used for intercepting log messages reported by the embedded points to be detected in the target page, wherein the embedded point information comprises introduction information and position information of the acquisition script in the target page, the log messages comprise log detailed data, field dimension value information and pit position information, finally the acquired embedded point information and the log messages are collected and integrated to obtain embedded point testing results, and the embedded point testing results are visually displayed in a tool window form.
Therefore, the target page is embedded into the tool, the visual display of the target page embedded point test result can be realized, the whole process is convenient and efficient, and the method can be completed without professional technicians.
In order to implement the continuous testing of the buried point of the new target page after the jump, the above embodiment further includes:
and limiting the default jump behavior of the target page in the browser so that the default jump behavior is only used for executing jump in the tool window.
The specific process is that when the target page is a tag jump, a click event of the target page is obtained through a monitoring script, and the nearest parent-level tag of the clicked event is positioned; extracting a target jump address based on the href attribute of the latest parent label, returning to the tool window, executing corresponding jump behaviors by the tool window and carrying out buried point test on a new target page again; when the target page is a non-tag jump, intercepting an access log in the target page through a plug-in RST; and extracting a target jump address based on a curl field of the access log, returning to the tool window, executing corresponding jump behaviors by the tool window, and performing buried point test on a new target page again.
When the target page is the label skip, monitoring a body click event of the target page through a monitoring script, finding out a latest parent label of a clicked element by bubbling, acquiring an href attribute (including a target skip address) of the current latest parent label, then returning to a tool window through Postmessage, at the moment, forbidding a default skip behavior of the latest parent label in a browser, and after receiving the href attribute of the click element of the target page, setting the target skip address in the tool window as a new target page address by the tool window so as to realize the test of a buried point of the new target page address through the tool window and repeat the steps; when the target page is a non-tag jump, such as js jump, form jump and the like, intercepting an http request reported by a buried point to be detected in the target page through a plug-in RST, acquiring an access log corresponding to the buried point to be detected, extracting a curl field (including a target jump address) of the access log, returning the curl field to a tool window through Postmessage, setting the target jump address in the tool window as a new target page address, and finally testing the buried point of the new target page address through the tool window so as to repeat the steps.
In the embodiment, the user can complete and continuously skip a series of pages and check the buried point condition of the skipped pages, so that the convenience and the efficiency of buried point detection are further improved.
It can be understood that, in the above embodiment, before dynamically injecting a monitoring script into a target page to be detected with a buried point to acquire buried point information in the target page, the method further includes:
and installing a plug-in RST in the browser and simultaneously starting an interception and monitoring function. Therein, the plug-in RST is also called plug-in SN _ RSTool.
In the above embodiment, the method for dynamically injecting the monitoring script into the target page of the buried point to be detected to acquire the buried point information in the target page includes:
when the target page is detected, informing an acquisition script in the target page to pull a monitoring script; and traversing the DOM tree of the target page by using the monitoring script to obtain the DOM element of the current page, and obtaining the embedded point information after analysis and arrangement and returning the embedded point information to the tool window.
In the above embodiment, the method for intercepting the log messages reported by the to-be-detected buried point in the target page through the plug-in RST includes:
intercepting an http request reported by a buried point to be detected in a target page through a webRequest API in a plug-in RST to obtain a log message corresponding to the buried point to be detected.
It needs to be noted that before intercepting an http request, whether a plug-in RST is installed in a user terminal needs to be verified, the step is to judge whether the plug-in RST is installed in a user terminal through message transmission between a verification tool and the plug-in RST, and when the verification result is that the plug-in RST is installed completely, verify whether the plug-in RST installed in the user terminal is the latest version, if not, prompt the user to update the plug-in RST, and finally verify whether a plug-in RST interception monitoring function is started, and when not, prompt the user to start the interception monitoring function; through the self-checking process, the interception and monitoring function of the plug-in RST can be ensured to be normally used.
In the above embodiment, the method for receiving the buried point information and the log message to obtain the buried point test result and visually displaying the buried point test result in the form of the tool window includes:
and integrating and outputting one or more of the lead-in information, the position information, the log detail data, the field dimension value information and the pit position information of the acquisition script (acquisition js), and displaying and outputting the integrated information in an independent window form.
Specifically, the content displayed and output in the independent window includes whether the acquisition js is introduced into the target page or is introduced repeatedly, whether the introduced acquisition js is in a specified position and whether a correct environment is introduced, whether field dimension value information is registered in the buried point management, and the pit position information of all the buried points in the current target page is labeled at the corresponding position of the page.
It should be added that, in the above embodiment, the monitoring script interacts with the tool window data in a Postmessage manner, and the plug-in RST interacts with the tool window data in the Postmessage manner through the sendMessage API.
For the convenience of understanding, the above implementation process is now exemplified by Chrome:
firstly, installing and starting an interception and monitoring function of a Chrome plug-in RST;
inputting a target page URL address of a buried point to be detected into a tool;
dynamically injecting a monitoring script into a target page by the tool;
monitoring a Script to acquire a Script tag on a target page, collecting the introduction condition of the acquisition Script and forbidding the behavior of jumping new windows of all dom elements;
the plug-in RST intercepts an HTTP request related to a target page embedded point to acquire a log message reported by the corresponding embedded point;
and the tool collects the detection results of the buried points and clearly displays the detection results in the form of independent windows according to the configured detection rules.
Example two
The embodiment provides a visual buried point testing device, includes:
the acquisition module is used for dynamically injecting a monitoring script into a target page of the buried point to be detected so as to acquire buried point information in the target page;
the intercepting module is used for dynamically injecting a monitoring script into a target page of the buried point to be detected so as to acquire buried point information in the target page;
and the display output module is used for receiving the buried point information and the log message to obtain a buried point test result and visually displaying the buried point test result in a tool window form.
Compared with the prior art, the beneficial effects of the visual embedded point testing device provided by the embodiment of the invention are the same as the beneficial effects of the visual embedded point testing method provided by the first embodiment, and the details are not repeated herein.
EXAMPLE III
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the steps of the indoor positioning method.
Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the embodiment are the same as those of the visual embedded point testing method provided by the technical scheme, and are not repeated herein.
It will be understood by those skilled in the art that all or part of the steps in the method for implementing the invention may be implemented by hardware instructions related to a program, the program may be stored in a computer-readable storage medium, and when executed, the program includes the steps of the method of the embodiment, and the storage medium may be: ROM/RAM, magnetic disks, optical disks, memory cards, and the like.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.