A white screen detection method, device, computer equipment and storage medium
By traversing the target DOM nodes in the DOM tree after the page is loaded, combining the hierarchical information and interactive behavior, we can determine whether the page has a white screen, which solves the problem of misjudgment of white screen detection in the existing technology, and improves the accuracy of the detection results sex.
Patent Information
- Application Number
- CN202210366413.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-04-08
AI Technical Summary
Existing white screen detection methods are prone to misjudgment, resulting in inaccurate detection results and inaccurate determination of whether the white screen appears on the page.
After the target page is loaded, in response to the change of the DOM tree, it traverses the target DOM node in the DOM tree, determines its hierarchical information, and determines whether the page has a white screen based on the hierarchical information and preset interactive behavior.
By more accurately determining whether the page has a white screen, it reduces misjudgment and improves the accuracy of the white screen detection results.
Smart Images

Figure CN114722776B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a white screen detection method, device, computer equipment and storage medium. Background Art
[0002] When a browser loads a page, under normal circumstances, the page will fully display the page content and the page can respond to various user interactions. However, under abnormal circumstances, the page does not display any content, or the page can fully display the page content but cannot respond to any user interactions. This phenomenon is called a white screen. After a page white screen occurs, users cannot browse the page content normally or perform any operations on the page, affecting the normal use of users. White screen detection can quickly determine the cause of the white screen so that it can be repaired as soon as possible.
[0003] In practice, the white screen detection process is usually performed in a short period of time when the page starts loading, and only the visible DOM nodes in the document object model DOM tree are detected. If no visible DOM nodes are detected, it is directly judged as a white screen. The above white screen detection process is prone to misjudgment, resulting in inaccurate detection results. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a white screen detection method, apparatus, computer equipment and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a white screen detection method, including:
[0006] After the target page is loaded, in response to a change in the document object model DOM tree of the target page, traverse the target DOM nodes in the DOM tree during the target idle period to determine the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM nodes are DOM nodes whose corresponding content elements have been displayed on the target page;
[0007] Whether a white screen appears on the target page is determined based on the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page.
[0008] In an optional implementation, determining whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page includes:
[0009] Determine the total node score of the target DOM node based on the level information of each target DOM node in the DOM tree and the preset scores corresponding to each level;
[0010] When the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior, it is determined that a white screen appears on the target page.
[0011] In an optional implementation manner, when the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior, determining that a white screen appears on the target page includes:
[0012] After determining that the total node score is less than a preset score threshold, determining whether a preset interactive behavior occurs on the target page within a target duration, and if determining that the preset interactive behavior does not occur, determining that a white screen appears on the target page.
[0013] In an optional implementation manner, the target duration is determined according to the following steps:
[0014] After determining that the total node score is less than the preset score threshold, determining a comparison result between the current target time interval from the start of loading the target page and the preset time interval;
[0015] If the target time interval is less than the preset time interval, the first preset duration is used as the target duration; if the target time interval is greater than or equal to the preset time interval, the second preset duration is used as the target duration; the first preset duration is greater than the second preset duration.
[0016] In an optional implementation manner, after determining the total node score of the target DOM node, the method further includes:
[0017] When the total node score is less than the preset score threshold and the preset interactive behavior occurs on the target page, a screenshot of the current target page is taken, and the screenshot result and a feedback result corresponding to the preset interactive behavior occurring on the target page are reported.
[0018] In an optional implementation, in response to a change in the document object model DOM tree of the target page, traversing the target DOM node in the DOM tree during a target idle period includes:
[0019] In response to a change in the document object model DOM tree of the target page, determining whether there is an uncompleted historical traversal task in an idle period closest to the time when the DOM tree is changed;
[0020] If it does not exist, the idle time period closest to the time when the DOM tree is changed is used as the target idle time period, and the target DOM nodes in the DOM tree are traversed within the target idle time period;
[0021] If it exists, the first idle period that appears after the idle period is taken as the target idle period, and the target DOM nodes in the DOM tree are traversed within the target idle period.
[0022] In an optional implementation manner, the method further includes:
[0023] In response to the DOM tree changing again within the target duration and the total node score corresponding to the change in the DOM tree being greater than or equal to the preset score threshold, stopping determining whether the target page has the preset interactive behavior within the target duration.
[0024] In a second aspect, an embodiment of the present disclosure further provides a white screen detection device, including:
[0025] A first determination module is used for, after the target page is loaded, in response to a change in the document object model DOM tree of the target page, traversing the target DOM nodes in the DOM tree within a target idle period, and determining the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM node is a DOM node whose corresponding content element has been displayed on the target page;
[0026] The second determination module is used to determine whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page.
[0027] In a third aspect, an embodiment of the present disclosure further provides a computer device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0028] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.
[0029] The white screen detection method provided by the embodiment of the present disclosure can first traverse the target DOM nodes in the DOM tree when the DOM tree changes after the target page is loaded, and then determine whether a white screen appears on the target page based on the hierarchical information of each traversed target DOM node in the DOM tree, and the occurrence of the preset interactive behavior corresponding to the target page. Among them, according to the occurrence of the preset interactive behavior corresponding to the target page, it can be determined whether the user can have the preset interactive behavior with the target page, that is, whether the user can continue to use the target page. In the above process, compared with the solution of directly judging whether the target page is a white screen based only on the traversal result of the target DOM node, it can be more accurately determined whether the target page is a white screen, which reduces the situation of misjudgment to a certain extent.
[0030] Furthermore, the disclosed embodiment can score the target DOM nodes based on the hierarchical information of each target DOM node in the DOM tree and the preset scores corresponding to each hierarchy, and determine whether a white screen appears on the target page based on the scoring results and whether the preset interactive behavior occurs on the target page, thereby improving the accuracy of the white screen detection results.
[0031] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0033] Figure 1 A schematic diagram of a process of a white screen detection method provided by an embodiment of the present disclosure is shown;
[0034] Figure 2 A schematic diagram showing a flow chart of another white screen detection method provided by an embodiment of the present disclosure;
[0035] Figure 3 A schematic diagram of the structure of a white screen detection device provided by an embodiment of the present disclosure is shown;
[0036] Figure 4 A schematic diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0038] In the actual white screen detection process, usually within three seconds after the page is loaded, it is detected whether there is a visible DOM node under the target node. If no visible DOM node is detected, it is directly judged as a white screen. The above white screen detection process is only performed when the page starts to render, and is not performed for the entire cycle of the page. When the page rendering time is long, it is judged as a white screen based on the detection results in a short period of time. In this case, it is easy to make a misjudgment, resulting in inaccurate detection results.
[0039] Based on this, the present disclosure provides a white screen detection method, which can first traverse the target DOM nodes in the DOM tree when the target page is loaded and changed, and then determine whether a white screen appears on the target page based on the hierarchical information of each traversed target DOM node in the DOM tree and the occurrence of the preset interactive behavior corresponding to the target page. Among them, according to the occurrence of the preset interactive behavior corresponding to the target page, it can be determined whether the user can have the preset interactive behavior with the target page, that is, whether the user can continue to use the target page. In the above process, compared with the solution of directly judging whether the target page is a white screen based only on the traversal result of the target DOM node, it can be more accurately determined whether the target page is a white screen, and the misjudgment can be reduced to a certain extent.
[0040] The defects existing in the above schemes and the proposed solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.
[0041] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0042] To facilitate understanding of this embodiment, a white screen detection method disclosed in the embodiment of the present disclosure is first introduced in detail. The executor of the white screen detection method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities.
[0043] The white screen detection method provided by the embodiment of the present disclosure is described below by taking the execution subject as a terminal device as an example.
[0044] See also Figure 1 FIG. 1 is a flow chart of a white screen detection method provided by an embodiment of the present disclosure, wherein the method includes S101 to S102, wherein:
[0045] S101: After the target page is loaded, in response to a change in the document object model DOM tree of the target page, traverse the target DOM nodes in the DOM tree during a target idle period to determine the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM node is a DOM node whose corresponding content element has been displayed on the target page.
[0046] In the disclosed embodiment, the target page may refer to a page in the browser. The completion of loading the target page refers to the completion of loading the target page by the browser. In the target page after loading is completed, the page content may be fully displayed or may not be fully displayed.
[0047] For the target page after loading, first determine whether the document object model DOM tree of the target page has changed. If a change has occurred, the step of traversing the target DOM nodes in the DOM tree during the target idle period in response to the change in the DOM tree of the target page can be executed. In the specific implementation process, the Mutation Observer mutation observer can be used to obtain related events of changes in the DOM tree in the first idle period after the browser finishes loading the target page. Each time the browser is in an idle period, the Mutation Observer can be used to obtain related events of changes in the DOM tree. Among them, the browser can be in an idle period after Request Animation Frame requests an animation frame, that is, after the browser renders a frame of image, and after receiving Request Idle Callback. The situation where the DOM tree changes mainly includes changes such as modification, deletion, and addition of DOM nodes in the DOM tree.
[0048] Here, the target idle period may refer to the idle period that the browser is in after the DOM tree is changed and is closest to the time when the DOM tree is changed, or refers to the first idle period that occurs after the idle period that is closest to the time when the DOM tree is changed. By traversing the target DOM nodes in the DOM tree during the target idle period, the phenomenon of browser freeze during the non-idle period of the browser can be avoided.
[0049] Specifically, the target idle period refers to the idle period in which the browser is located after the DOM tree is changed, which is closest to the time when the DOM tree is changed, or it refers to the first idle period after the idle period closest to the time when the DOM tree is changed. It can be determined based on whether there are unfinished historical traversal tasks in the idle period closest to the time when the DOM tree is changed, or whether the user initiates a network request.
[0050] Exemplarily, in one implementation, in response to a change in the DOM tree of the target page, it may be determined whether there is an uncompleted historical traversal task in an idle period closest to the time when the DOM tree is changed.
[0051] Here, the traversal task may refer to a task of traversing the target DOM nodes in the DOM tree after the DOM tree is changed, so as to determine the hierarchical information of each target DOM node traversed in the DOM tree. The unfinished historical traversal task may refer to a traversal task that has not been executed for the target DOM nodes in the DOM tree after the historical change of the DOM tree occurs, and the historical traversal task will be executed in the idle time period closest to the time when the DOM tree is changed.
[0052] If there is no unfinished historical traversal task in the idle period closest to the time when the DOM tree is changed, the idle period closest to the time when the DOM tree is changed is used as the target idle period, and the target DOM node in the DOM tree is traversed in the target idle period.
[0053] If there are unfinished historical traversal tasks in the idle period closest to the time when the DOM tree is changed, the first idle period after the idle period is taken as the target idle period, and the target DOM node in the DOM tree is traversed in the target idle period.
[0054] Here, usually, a traversal task can be executed at most once in an idle period of the browser. Therefore, when there is an unfinished historical traversal task in the idle period closest to the moment when the current DOM tree changes, the first idle period after the idle period can be used as the target idle period. That is, the historical traversal task will be executed in the idle period closest to the moment when the current DOM tree changes, and the traversal task corresponding to the current DOM tree change will be executed in the first idle period after the idle period.
[0055] In addition, usually, if the DOM tree changes multiple times in succession, only the traversal task corresponding to the last change of the DOM tree is executed. Therefore, in the first idle period after the idle period, that is, the target idle period, only the traversal task corresponding to the current DOM tree change is executed, that is, the traversal tasks corresponding to other DOM tree changes before the current DOM tree change are no longer executed.
[0056] In the disclosed embodiment, the DOM nodes, i.e., target DOM nodes, of the corresponding content elements displayed on the target page are mainly traversed. Here, the hierarchical information of each target DOM node in the DOM tree can be determined for each traversed target DOM node.
[0057] In the process of traversing the target DOM node in the DOM tree, the traversal can be started from the root node of the document.body file corresponding to the DOM tree or the target node specified by the user in the DOM tree. Considering that the deeper the DOM node in the DOM tree is, the less influence it has on the white screen detection result, the level to be traversed can be preset here, that is, only the preset level of the DOM tree is traversed, for example, starting from the root node of the DOM tree, only the 1st to 4th levels of the DOM tree are traversed.
[0058] The hierarchical information of each traversed target DOM node in the DOM tree can be used in the subsequent step of determining whether a white screen appears on the target page, that is, step S102.
[0059] S102: Determine whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page.
[0060] In the disclosed embodiment, the initial white screen detection result can be determined according to the hierarchical information of each target DOM node traversed in the DOM tree. Exemplarily, in one implementation, the initial white screen detection result can be determined according to the distribution of each target DOM node in each hierarchy.
[0061] Then, according to the initial white screen detection result and the occurrence of the preset interactive behavior corresponding to the target page, the final white screen detection result can be determined. That is, the initial white screen detection result is further determined by the occurrence of the preset interactive behavior corresponding to the target page. Therefore, the occurrence of the preset interactive behavior corresponding to the target page can be obtained after completing the traversal task of the target DOM node. Here, it is mainly to obtain whether the user has a preset interactive behavior.
[0062] In an embodiment of the present disclosure, the preset interactive behavior may refer to the preset interactive behavior that occurs on the target page by the user after completing the task of traversing the target DOM node. Among them, the preset interactive behavior may include, for example, switching pages, reloading, sending requests and other behaviors. If a white screen occurs on the target page, the browser cannot respond normally when the user performs any of the above preset interactive behaviors. If a white screen does not occur on the target page, after the user performs any of the above preset interactive behaviors, the browser may generate a JavaScript script error, a static resource error, or callback information corresponding to interactive behaviors such as switching pages, reloading, and sending requests. Therefore, by determining whether a white screen actually occurs on the target page, the preset interactive behavior can be used.
[0063] In a specific implementation, if the initial white screen detection result indicates that the target page does not have a white screen, the DOM tree is waited for to change, and the process of traversing the target DOM node in the DOM tree during the target idle period is repeated in response to the change of the DOM tree of the target page.
[0064] If the initial white screen detection result indicates that a white screen appears on the target page, the occurrence of a preset interactive behavior corresponding to the target page is obtained.
[0065] When the target page has a preset interactive behavior, it means that the initial white screen detection result (white screen appears on the target page) is an inaccurate result, that is, the initial white screen detection result is a misjudgment result, and the final white screen detection result is determined to be that the target page does not have a white screen. The reason for this may be that the target page contains many content elements, and the rendering takes a long time. The browser has not yet fully rendered all the content elements. Therefore, the target DOM nodes traversed at this time are not comprehensive; it may also be that during the page switching process, the DOM tree of the previous page is unloaded, and the target DOM nodes traversed at this time are also incomplete.
[0066] When the target page does not have a preset interactive behavior, it indicates that the initial white screen detection result (white screen appears on the target page) is an accurate result, and the final white screen detection result is determined to be that a white screen appears on the target page.
[0067] In order to more accurately determine whether a white screen appears on the target page, in one embodiment, the initial white screen detection result can be determined by scoring, that is: according to the hierarchical information of each target DOM node traversed in the DOM tree, the target DOM node is scored to obtain the score result corresponding to the target DOM node.
[0068] Specifically, the total node score of the target DOM node may be determined based on the level information of each target DOM node in the DOM tree and the preset score corresponding to each level.
[0069] As mentioned above, the deeper the DOM node in the DOM tree is, the less influence it has on the white screen detection result. Here, a smaller score can be set for a deeper level. For example, the formula Determine the preset scores corresponding to each level. Among them, depth represents the level where the target DOM node is located. When depth is 1, it means that the level where the target DOM node is located is the first level, and the score of the first level is 1; when depth is 2, it means that the level where the target DOM node is located is the second level, and the score of the second level is 0.5; when depth is 3, it means that the level where the target DOM node is located is the third level, and the score of the third level is 0.25. And so on, the preset scores corresponding to each level can be obtained. In this way, the node scores of each target DOM node can be calculated, and finally the total node score of the target DOM node can be determined.
[0070] In a specific implementation, a score threshold may be set, such as 1.5. When the total node score is less than the preset score threshold, the initial white screen detection result may be determined as a white screen appears on the target page; when the total node score is greater than or equal to the preset score threshold, the initial white screen detection result may be determined as a white screen does not appear on the target page.
[0071] In combination with the above process, when the total node score is less than the preset score threshold and the target page does not have a preset interactive behavior, it can be determined that a white screen appears on the target page.
[0072] In order to promptly determine whether a white screen appears on the target page and avoid wasting resources, in one implementation, after determining that the total node score is less than a preset score threshold, it can be determined whether a preset interactive behavior occurs on the target page within the target duration. If it is determined that no preset interactive behavior occurs, it is determined that a white screen appears on the target page.
[0073] The target duration may be a preset duration with the current time as the start time. In one embodiment, the target duration may be determined based on the target time interval from the current time to the start of loading the target page.
[0074] Specifically, after determining that the total node score is less than a preset score threshold, a comparison result between the current target time interval from the start of loading the target page and the preset time interval is determined.
[0075] The preset time interval may be determined based on the target page loading time under normal circumstances. For example, under normal circumstances, the average loading time of the target page is 6 to 8 seconds. In order to ensure that the target page can be loaded, the preset time interval here may be slightly longer than the average loading time of the target page, for example, it may be set to 10 seconds.
[0076] If the target time interval is less than the preset time interval, the first preset time length is used as the target time length; if the target time interval is greater than or equal to the preset time interval, the second preset time length is used as the target time length; the first preset time length is greater than the second preset time length.
[0077] If the target time interval is less than the preset time interval, the current target page may not have been loaded. In this case, a longer first preset time length can be used as the target time length. The first preset time length can be, for example, 10 seconds. This can ensure to a certain extent that the target page is loaded, thereby more accurately obtaining the occurrence of the preset interactive behavior corresponding to the target page. If the target time interval is greater than or equal to the preset time interval, the current target page is likely to have been loaded. In this case, a shorter second preset time length can be used as the target time length. The second preset time length can be, for example, 2 seconds.
[0078] Taking into account that the DOM tree may change multiple times after the target page is loaded, after the DOM tree changes this time, in the process of determining whether a white screen appears on the target page, according to the hierarchical information of each target DOM node traversed in the DOM tree and the occurrence of the preset interactive behavior corresponding to the target page, if the DOM tree changes again, in one embodiment, in response to the DOM tree changing again within the target duration and the total node score corresponding to the change of the DOM tree being greater than or equal to the preset score threshold, the determination of whether the preset interactive behavior occurs on the target page within the target duration is stopped.
[0079] That is, when the total node score corresponding to the change in the DOM tree is greater than or equal to the preset score threshold, it indicates that the target page does not have a white screen. At this time, it is no longer determined whether the target page has a preset interactive behavior within the target duration. When the DOM tree changes again, the steps of changing the DOM tree of the target page, traversing the target DOM nodes in the DOM tree during the target idle period, and determining the hierarchical information of each traversed target DOM node in the DOM tree are repeated.
[0080] In order to further ensure the accuracy of the final white screen detection result, after determining the total node score of the target DOM node, it is also possible to determine whether a white screen appears on the target page by reporting screenshot data. In one embodiment, when the total node score is less than a preset score threshold and the target page has a preset interactive behavior, the current target page can be screenshotted, and the screenshot result and the feedback result corresponding to the preset interactive behavior occurring on the target page can be reported.
[0081] Among them, the operation of taking a screenshot of the current target page can be set by the user. After the automatic screenshot operation is set, the screenshot operation of the current target page can be automatically performed. After the screenshot, a picture in a preset format can be generated, and the picture in the preset format can be used as the screenshot result. Next, the screenshot result can be reported in an asynchronous reporting manner. The asynchrony mentioned here refers to the feedback result corresponding to the preset interactive behavior occurring with the target page. Among them, the feedback result corresponding to the preset interactive behavior occurring with the target page may refer to the result of determining whether the target page is a white screen based on the occurrence of the preset interactive behavior.
[0082] During the asynchronous reporting process, if the screenshot operation is not completed when the user closes the target page, only the feedback results corresponding to the preset interactive behavior with the target page are reported; if the screenshot operation is completed, the screenshot result and the feedback results corresponding to the preset interactive behavior with the target page are reported.
[0083] In the embodiment of the present disclosure, in addition to reporting the feedback results corresponding to the preset interactive behavior occurring with the target page during the asynchronous reporting process, any abnormal data can also be reported during any process of page loading, so that the background server can determine the cause of the white screen based on the reported abnormal data.
[0084] In order to more clearly explain the above white screen detection process, the present disclosure also provides a white screen detection method. Figure 2 Schematic diagram of another white screen detection method shown in FIG.
[0085] Step 1: In the first idle period after the target page is loaded, start using MutationObserver to obtain the change events of the DOM tree.
[0086] Here, after the target page is loaded, the Mutation Observer can be used to obtain the change event of the DOM tree during the first idle period after the browser request animation frame is received and the request idle callback is received.
[0087] Step 2: After the DOM tree is changed, determine whether there is an unfinished historical traversal task or a user initiates a network request in the first idle period after the DOM tree is changed; if so, execute step 3; if not, execute step 4;
[0088] Step 3, in the first idle period after the DOM tree is changed, traverse the target DOM node in the DOM tree until the preset level is reached, and score the traversed target DOM node to determine the total node score of the target DOM node; the target DOM node is the DOM node whose corresponding content element has been displayed on the target page.
[0089] Here, each time a target DOM node is traversed, the score is calculated based on the level of the target DOM node in the DOM tree and the preset score formula corresponding to each level. Calculate the node score corresponding to the target DOM node. Where depth indicates the level of the target DOM node.
[0090] Then, the node scores of each traversed target DOM node are summed to obtain the total node score of the target DOM node.
[0091] Step 4: In the next idle period of the first idle period after the DOM tree is changed, traverse the target DOM node in the DOM tree.
[0092] Step 5: Determine whether the total node score of the target DOM node is less than a preset score threshold. If so, execute step 6; if greater than or equal to, execute step 2.
[0093] Step 6: Determine whether the target page has a preset interactive behavior within the target duration; if so, execute step 7; if not, execute step 2.
[0094] Step 7: Take a screenshot of the current target page. If the screenshot is not taken when the user closes the target page, a white screen event is reported. If the screenshot is taken successfully, a picture in a preset format is generated, and the picture in the preset format and the white screen event are reported.
[0095] Step 8: If the DOM tree changes within the target duration and the total node score corresponding to the change in the DOM tree is greater than or equal to the preset score threshold, execute step 2.
[0096] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0097] Based on the same inventive concept, a white screen detection device corresponding to the white screen detection method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned white screen detection method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0098] Reference Figure 3 , which is a schematic diagram of the architecture of a white screen detection device provided by an embodiment of the present disclosure, the device comprises: a first determination module 301, a second determination module 302; wherein,
[0099] The first determination module 301 is used for, after the target page is loaded, in response to a change in the document object model DOM tree of the target page, traversing the target DOM nodes in the DOM tree within a target idle period, and determining the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM node is a DOM node whose corresponding content element has been displayed on the target page;
[0100] The second determination module 302 is used to determine whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page.
[0101] In an optional implementation manner, the second determining module 302 is specifically configured to:
[0102] Determine the total node score of the target DOM node based on the level information of each target DOM node in the DOM tree and the preset scores corresponding to each level;
[0103] When the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior, it is determined that a white screen appears on the target page.
[0104] In an optional implementation manner, the second determining module 302 is specifically configured to:
[0105] After determining that the total node score is less than a preset score threshold, determining whether a preset interactive behavior occurs on the target page within a target duration, and if determining that the preset interactive behavior does not occur, determining that a white screen appears on the target page.
[0106] In an optional implementation, the device further includes a third determination module, which is configured to determine the target duration by executing the following steps:
[0107] After determining that the total node score is less than the preset score threshold, determining a comparison result between the current target time interval from the start of loading the target page and the preset time interval;
[0108] If the target time interval is less than the preset time interval, the first preset duration is used as the target duration; if the target time interval is greater than or equal to the preset time interval, the second preset duration is used as the target duration; the first preset duration is greater than the second preset duration.
[0109] In an optional implementation manner, after the second determining module 302 executes the step of determining the total node score of the target DOM node, the device further includes:
[0110] The screenshot module is used to take a screenshot of the current target page when the total node score is less than the preset score threshold and the preset interactive behavior occurs on the target page, and report the screenshot result and the feedback result corresponding to the preset interactive behavior occurring on the target page.
[0111] In an optional implementation manner, the first determining module 301 is specifically configured to:
[0112] In response to a change in the document object model DOM tree of the target page, determining whether there is an uncompleted historical traversal task in an idle period closest to the time when the DOM tree is changed;
[0113] If it does not exist, the idle time period closest to the time when the DOM tree is changed is used as the target idle time period, and the target DOM nodes in the DOM tree are traversed within the target idle time period;
[0114] If it exists, the first idle period that appears after the idle period is taken as the target idle period, and the target DOM nodes in the DOM tree are traversed within the target idle period.
[0115] In an optional implementation, the device further includes:
[0116] A stopping module is used to stop determining whether the target page has the preset interactive behavior within the target duration in response to the DOM tree changing again within the target duration and the total node score corresponding to the change of the DOM tree occurring again being greater than or equal to the preset score threshold.
[0117] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0118] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 4 As shown, it is a schematic diagram of the structure of a computer device 400 provided in an embodiment of the present disclosure, including a processor 401, a memory 402, and a bus 403. Among them, the memory 402 is used to store execution instructions, including a memory 4021 and an external memory 4022; the memory 4021 here is also called an internal memory, which is used to temporarily store the operation data in the processor 401, and the data exchanged with the external memory 4022 such as a hard disk. The processor 401 exchanges data with the external memory 4022 through the memory 4021. When the computer device 400 is running, the processor 401 communicates with the memory 402 through the bus 403, so that the processor 401 executes the following instructions:
[0119] After the target page is loaded, in response to a change in the document object model DOM tree of the target page, traverse the target DOM nodes in the DOM tree during the target idle period to determine the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM nodes are DOM nodes whose corresponding content elements have been displayed on the target page;
[0120] Whether a white screen appears on the target page is determined based on the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page.
[0121] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the white screen detection method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0122] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the white screen detection method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0123] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0124] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0127] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0128] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A white screen detection method, characterized in that: include: After the target page is loaded, in response to a change in the document object model DOM tree of the target page, traverse the target DOM nodes in the DOM tree during the target idle period to determine the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM nodes are DOM nodes whose corresponding content elements have been displayed on the target page; Determine whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page; Wherein, determining whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page includes: Determine the total node score of the target DOM node based on the level information of each target DOM node in the DOM tree and the preset score corresponding to each level; When the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior, it is determined that a white screen appears on the target page.
2. The method according to claim 1, characterized in that The step of determining that a white screen appears on the target page when the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior includes: After determining that the total node score is less than a preset score threshold, determining whether a preset interactive behavior occurs on the target page within a target duration, and if determining that the preset interactive behavior does not occur, determining that a white screen appears on the target page.
3. The method according to claim 2, characterized in that The target duration is determined according to the following steps: After determining that the total node score is less than the preset score threshold, determining a comparison result between the current target time interval from the start of loading the target page and the preset time interval; If the target time interval is less than the preset time interval, the first preset time length is used as the target time length; If the target time interval is greater than or equal to the preset time interval, the second preset time length is used as the target time length; and the first preset time length is greater than the second preset time length.
4. The method according to claim 1, characterized in that After determining the total node score of the target DOM node, the method further includes: When the total node score is less than the preset score threshold and the preset interactive behavior occurs on the target page, a screenshot of the current target page is taken, and the screenshot result and a feedback result corresponding to the preset interactive behavior occurring on the target page are reported.
5. The method according to claim 1, characterized in that In response to a change in a document object model DOM tree of the target page, traversing a target DOM node in the DOM tree during a target idle period includes: In response to a change in the document object model DOM tree of the target page, determining whether there is an uncompleted historical traversal task in an idle period closest to the time when the DOM tree is changed; If it does not exist, the idle time period closest to the time when the DOM tree is changed is used as the target idle time period, and the target DOM nodes in the DOM tree are traversed within the target idle time period; If it exists, the first idle period that appears after the idle period is taken as the target idle period, and the target DOM nodes in the DOM tree are traversed within the target idle period.
6. The method according to claim 2, characterized in that The method further comprises: In response to the DOM tree changing again within the target duration and the total node score corresponding to the change in the DOM tree being greater than or equal to the preset score threshold, stopping determining whether the target page has the preset interactive behavior within the target duration.
7. A white screen detection device, characterized in that: include: A first determination module is used for, after the target page is loaded, in response to a change in the document object model DOM tree of the target page, traversing the target DOM nodes in the DOM tree within a target idle period, and determining the hierarchical information of each of the traversed target DOM nodes in the DOM tree; wherein the target DOM node is a DOM node whose corresponding content element has been displayed on the target page; A second determination module is used to determine whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page; Wherein, determining whether a white screen appears on the target page according to the hierarchical information of each of the traversed target DOM nodes in the DOM tree and the occurrence of a preset interactive behavior corresponding to the target page includes: Determine the total node score of the target DOM node based on the level information of each target DOM node in the DOM tree and the preset score corresponding to each level; When the total node score is less than a preset score threshold and the target page does not have a preset interactive behavior, it is determined that a white screen appears on the target page.
8. A computer device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the white screen detection method according to any one of claims 1 to 6 are performed.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the white screen detection method according to any one of claims 1 to 6 are executed.
Citation Information
Patent Citations
Webpage interface white screen monitoring method and device
CN110851350A
Browser front-end architecture system capable of being developed separately from rear-end architecture
CN111428168A