Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for locating a problem code. The technical scheme is as follows:
in one aspect, a method for locating problem codes is provided, which includes:
receiving an operation request of a plug-in a browser, and monitoring the webpage activity of a current interface;
matching the webpage with screenshot features input by a user in advance, judging whether the webpage accords with the screenshot features, if so, judging that a problem code exists when the webpage is opened, and intercepting the webpage as a target picture, wherein the screenshot features comprise: browser windows, operating features, keywords.
Further, the method further comprises:
receiving one or more of error data name, error source, generation reason and solution corresponding to the target picture input by a user, and forming an error report record with the target picture;
and adding the error report records into an error report record library for storage.
Further, after receiving an operation request of a plug-in a browser and monitoring the webpage activity of the current interface, the method further comprises the following steps:
matching request data with data interception features, and if the request data conforms to the data interception features, acquiring the request data and response data corresponding to the request data, wherein the data interception features comprise: request header IP, browser window, request interface, request type.
Further, after obtaining the request data and the response data, the method further comprises:
and according to an operation instruction made by a user after screening, receiving one or more of error data name, error source, generation reason and solution corresponding to the request data and the response data input by the user, and forming an error report record with the request data and the response data to be added into an error report record library.
Further, the method further comprises:
receiving and executing an operation request for the error reporting record, wherein the operation request comprises: a conditional query request or a picture query request.
In another aspect, an apparatus for locating problem codes is provided, the apparatus comprising: the starting module is used for monitoring the webpage activity of the current interface after receiving the operation request of the plug-in the browser;
the judging module is used for matching the webpage with screenshot features which are input in advance, judging whether the webpage accords with the screenshot features, if so, judging that problem codes exist when the webpage is opened, and the screenshot features comprise: one or more of a browser window, an operating feature, and a keyword;
and the picture acquisition module is used for intercepting the webpage as a target picture when the problem code is judged.
Further, the apparatus further comprises:
an error reporting record repository, the error reporting record repository comprising: the error report record generating module is used for receiving one or more of error data names, error sources, production reasons and solutions which are input by a user and correspond to the target picture, and forming an error report record with the target picture;
and the storage module is used for storing the error report records comprising the target picture.
Further, the apparatus further comprises:
the data acquisition module is used for matching request data with data interception features after receiving an operation request of a plug-in a browser and monitoring the webpage activity of a current interface, and acquiring the request data and response data corresponding to the request data if the request data conforms to the data interception features, wherein the data interception features comprise: request header IP, browser window, request interface, request type.
Further, the error record generating module is further configured to receive one or more of an error data name, an error source, a generation reason, and a solution, which are input by a user and correspond to the request data and the response data, and form an error record with the request data and the response data;
the storage module is further configured to store an error report record including the request data and the response data according to an operation instruction made by the user after the screening.
Further, the error record library further comprises: an operation module, configured to receive and execute the operation request for error reporting record, where the operation request includes: a conditional query request or a picture query request.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
1. the invention has two functions of screenshot positioning and data positioning, can position problem codes in time when accidental problems occur, and does not need manual search;
2. the problem codes can be positioned in a targeted manner under the specific scene condition according to the user setting, and the user requirements are met;
3. the error reporting database is arranged, so that technical reference can be provided for the problem of subsequent reproduction, the energy waste caused by solving the problem of reproduction is reduced, and the working efficiency is improved;
4. the invention can also be used for storing operation records during regression testing, and is convenient for function backtracking in the later period.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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.
In the existing program test field, the mode of positioning error codes is mainly divided into two modes of packet capturing and screenshot. For positioning error codes in a packet capturing mode, a general packet capturing tool only provides parameters for capturing data according to IP, a request interface and a clear stream type, and cannot provide more parameter types according to a specific scene. For positioning error codes in a screenshot mode, manual processing is needed to be judged manually at present, automatic screenshot processing cannot be achieved, workload of testers is increased, and working efficiency of the testers is reduced.
Based on the technical problems in the prior art, the technical scheme disclosed by the invention provides a method and a device capable of automatically positioning problem codes, which can automatically intercept the current interface picture, automatically capture the request and respond to data to position error codes according to the conditions preset by a user, and finally form an error report record to be stored in an error report record library for reference of subsequent reproduction error processing.
Example 1
As shown in fig. 1, a method of locating a problem code includes:
receiving a plug-in running request in a browser, and monitoring the webpage activity of a current interface;
matching the webpage with screenshot features, wherein the screenshot features comprise: one or more of a browser window, an operating feature, and a keyword;
judging whether the webpage displayed on the current interface meets the screenshot characteristic or not, and if so, judging that a problem code exists when the webpage on the current interface is opened;
and intercepting the webpage displayed on the current interface as a target picture.
It should be noted that the above method provides a method for automatically positioning the problem code by means of screenshot. The method is used as a plug-in of a browser, the plug-in is required to be started before the method is used, monitoring of webpage activities is started after the plug-in is started, and once the webpage accords with screenshot features, picture capture is carried out. The screenshot feature in the method is preset by a user, and the webpage is matched with the screenshot feature according to the content of the screenshot feature, wherein the screenshot feature specifically comprises one or more of the following conditions:
whether the web page displayed by the current interface belongs to a browser window,
whether the web page displayed by the current interface is obtained according to the operation characteristics,
whether the webpage displayed by the current interface contains the keywords or not.
After the target picture is obtained, the method disclosed by the invention further comprises the following steps:
receiving one or more of error data name, error source, generation reason and solution corresponding to the target picture input by a user, and forming an error report record with the target picture;
and adding the error report records into an error report record library for storage.
The error reporting record library in the method is mainly used for managing error reporting records in a unified way and can be used as a reference for solving the same or similar program problems in the following process. The error reporting record consists of a target picture and a text description of the target picture, the text description is input by a user and can comprise one or more of error data name, error source, generation reason and solution, and the complete error reporting record can more effectively provide a reference function.
Besides positioning the problem codes in a screenshot mode, the method provided by the invention also comprises the step of positioning the problem codes in a data capture mode, and after monitoring the webpage activity of the current interface, the method disclosed by the invention also comprises the following steps:
matching the request data with the data interception feature, and if the request data conforms to the data interception feature, acquiring the request data and response data corresponding to the request data, wherein the data interception feature comprises: one or more of request header IP, browser window, request interface and request type;
and according to the operation instruction made by the user after screening, receiving one or more of error data name, error source, generation reason and solution corresponding to the request data and the response data input by the user, and forming an error report record with the request data and the response data to be added into the error report record library for storage.
In the method, a problem code is positioned by data interception, wherein a request header IP in a data interception feature is an IP address in request data, a browser window is a browser window to which an open webpage belongs, a request interface is an interface for sending the request data, and the request type is mainly a format type contained in the request data, and the method comprises the following steps: html, json, css, js, png, jpg, and the like.
Based on the method, the error record comprising the target picture and the error record comprising the request data and the response data exist in the error record library, and the error records can be separately displayed and arranged according to the type of the error record. The error report record library can receive a condition query request or a picture query request of a user for error report records and search the error report records. The conditional query request for the error report record including the target picture may be according to: and querying any one or more of error data name, error source, browser window, operation characteristic and keyword. The conditional query request for an error log comprising request data and response data may be based on: and querying any one or more of error data name, error source, request header IP, browser window, request interface and request type. The picture query request is mainly suitable for querying error report records including the target picture, the user can input the intercepted picture, the system compares the intercepted picture with the pictures in the error report record library, and the approximate error report records are displayed to the user.
As shown in fig. 2, based on the above method for positioning problem codes, the present invention also discloses a device for positioning problem codes, which includes:
and the starting module is used for monitoring the webpage activity of the current interface after receiving the operation request of the plug-in the browser.
The judging module is used for matching the webpage with the screenshot feature input in advance, judging whether the webpage accords with the screenshot feature, if so, judging that a problem code exists when the webpage is opened, wherein the screenshot feature comprises: browser windows, operating features, keywords.
And the picture acquisition module is used for intercepting the webpage as a target picture when the problem code is judged.
And the data acquisition module is used for matching the request data with the data interception characteristic after receiving an operation request of a plug-in the browser and monitoring the webpage activity of the current interface, and acquiring the request data and the corresponding response data if the request data conforms to the data interception characteristic. The data interception features include: request header IP, browser window, request interface, request type.
An error reporting record library comprising: the device comprises an error report record generation module, a storage module and an operation module. And the error report record generating module is used for receiving one or more of error names, error sources, production reasons and solutions which are input by a user and correspond to the target picture to form an error report record with the target picture, and receiving one or more of error data names, error sources, production reasons and solutions which are input by the user and correspond to the request data and the response data to form an error report record with the request data and the response data. The storage module is used for storing error reporting records. An operation module, configured to receive and execute an operation request for reporting an error record, where the operation request includes: a conditional query request or a picture query request.
The device for positioning the problem codes can realize two functions of screenshot positioning and positioning according to the request data, finally stores the formed error reporting data into the error reporting database, realizes the unified management of the problem codes, forms the error system library and is convenient for subsequent searching and reference.
Example 2
Fig. 3 and 4 are schematic diagrams of an interface of a plug-in for locating problem codes. The plug-in unit runs on the basis of the browser, and can be developed by using technologies such as HTML, javaScript and CSS. The plug-in comprises two positioning functions of picture positioning and data request positioning, and can position the problem code of the appointed scene according to the characteristic condition preset by the user. FIG. 3 is a schematic interface diagram of a plug-in for locating problem codes when a user selects the screenshot function, and FIG. 4 is a schematic interface diagram of a plug-in for a user selecting a plug-in for requesting data to locate problem codes. The right side of fig. 3 is a screenshot feature presetting area, wherein when the screenshot is triggered by setting the operation feature, screenshot delay can be set so as to avoid the situation that the screenshot is invalid due to incomplete webpage expansion, and when the keyword is preset, the keyword management can be adopted to select common keywords, and the user can also input the keywords by himself. The left side of fig. 3 is a target picture display area, and the upper trace button is a monitoring start button of the plug-in. The right side of fig. 4 is a data capture feature preset area, which includes four setting modules, namely, a specified request header IP, a specified browser window, a specified request interface, and a request type selection, and can be input by a user. The left side of fig. 4 is a request data and response data display area, the tracking button on the display area is also a monitoring start button of the plug-in, and the export button is a button for exporting the intercepted request data and corresponding data.
The plug-in for positioning the problem code comprises: the device comprises a starting module, a judging module, a picture acquiring module, a data acquiring module and an error reporting record library.
The starting module is used for monitoring the activity condition of the webpage on the current interface after the plug-in is started. In the screenshot function interface, the starting module sends the activity condition of the webpage to the judging module, and if the user selects the request function, the starting module sends the activity condition of the webpage to the data acquiring module.
And after receiving the webpage activity condition, the judging module matches the webpage with the screenshot feature, judges that the code of the webpage which accords with the screenshot feature is wrong, and sends a screenshot request to the picture acquiring module.
And the picture acquisition module starts to capture the picture after receiving the screenshot request, and triggers the screenshot after receiving the screenshot request and waiting for the delay time if the user sets the screenshot delay. The target picture intercepted by the picture is the picture of the webpage with the error, and the user can directly generate the error report record of the target picture. In the process of obtaining the target picture according to the keyword, if the keyword is 'failure', when a window including 'failure' appears in the webpage as shown in fig. 5, the webpage is directly captured.
In the data acquisition function interface, after receiving the webpage activity condition, the data acquisition module matches the request data generated in the activity of the webpage with the data interception characteristic, and intercepts the request data conforming to the data interception characteristic and the response data corresponding to the request data. The user needs to judge whether the intercepted data has a problem code by himself, and if the intercepted data has the problem code, the problem code can be generated into an error report record.
The generation of the error reporting records is carried out in an error reporting record library. The error reporting record library comprises: the device comprises an error report record generation module, a storage module and an operation module. And the error report record generating module is used for generating an error report record according to the text content input by the user, the target picture or the request data and the response data. The storage module is used for storing the error reporting records. And the operation module user inquires the error report record according to the condition inquiry request or the picture inquiry request of the user.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
1. the invention has two functions of screenshot positioning and data positioning, can position problem codes in time when accidental problems occur, and does not need manual search;
2. the problem codes can be positioned in a targeted manner under the specific scene condition according to the user setting, and the user requirements are met;
3. the error reporting database is arranged, so that technical reference can be provided for the problem of subsequent reproduction, the energy waste caused by solving the problem of reproduction is reduced, and the working efficiency is improved;
4. the invention can also be used for storing operation records during regression testing, and is convenient for function backtracking in the later period.
All the above-mentioned optional technical solutions can be combined arbitrarily to form the optional embodiments of the present invention, and are not described herein again.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and should not be taken as limiting the scope of the present invention, which is intended to cover any modifications, equivalents, improvements, etc. within the spirit and scope of the present invention.