A method, apparatus, computer device, and readable storage medium for detecting web pages.
By monitoring and traversing changes in the application's interface content, obtaining interface information, and detecting page elements, the problem of static code scanning being unable to accurately identify elements is solved, achieving higher detection accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2026-03-06
AI Technical Summary
Existing technologies that detect application interfaces by statically scanning code cannot accurately identify whether page elements are still displayed on the interface, resulting in low detection accuracy.
By monitoring changes in the page display content of the target application, obtaining interface information, traversing the subviews of user interface controls, detecting whether there are preset page elements in the interface information, and reporting the results to the detection server.
It improves the accuracy of detecting target application interface information when using the APP, thus enhancing the accuracy of problem detection.
Smart Images

Figure CN115269093B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of automated testing technology, and more specifically, to a method, apparatus, computer device, and readable storage medium for detecting pages. Background Technology
[0002] In some cases, it is necessary to inspect the information displayed on the application (APP) interface. Currently, static code scanning is mostly used to inspect the information on the APP interface. However, static code scanning cannot accurately identify whether some page elements are still displayed on the APP interface, so the accuracy of page detection is not high. Summary of the Invention
[0003] This disclosure provides at least one method, apparatus, computer device, and readable storage medium for detecting pages.
[0004] In a first aspect, embodiments of this disclosure provide a method for detecting a page, including:
[0005] With the target application having preset functions enabled, monitor whether the page display content of the target application changes;
[0006] In response to a change in the page display content of the target application, the target user interface control located in the graphical user interface is obtained; each subview in the target user interface control is traversed to obtain the interface information corresponding to each subview;
[0007] Detect whether there are preset page elements in the interface information;
[0008] If the page element is found in the page information, the page element and the corresponding program statement are reported to the detection server.
[0009] In one optional implementation, it further includes:
[0010] After launching the target application, it is detected whether the target application's settings instruct the target application to enable a preset function;
[0011] In response to the setting information of the target application instructing the target application to enable a preset function, the pre-injected detection environment configuration information is obtained from the program code of the target application;
[0012] Based on the detection environment configuration information, a detection environment is configured, and under the detection environment, the page display content of the target application is monitored for changes.
[0013] In one optional implementation, detecting whether the page display content of the target application has changed includes:
[0014] Hook functions are used to monitor whether a preset operation is triggered on the target page currently being displayed by the target application;
[0015] In response to detecting a preset operation triggered on the target page, it is determined that the page display content of the target application has changed.
[0016] In one optional implementation, the step of traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview includes:
[0017] Iterate through the parent controls of the target user interface control and obtain the class name of the parent control;
[0018] The class name corresponding to the target user interface control and the class name of the parent control are concatenated to obtain a concatenated string; and
[0019] Number the target user interface control and its sibling controls;
[0020] Based on the concatenated string and the number, an identifier for the target user interface control is generated;
[0021] Based on the identifier, traverse each subview in the target user interface control to obtain the interface information corresponding to each subview.
[0022] In an optional implementation, the step of traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview further includes:
[0023] In response to traversing to any subview in the target user interface control, determine whether the subview is visible;
[0024] In response to the visibility of the subview, retrieve the interface information corresponding to the subview.
[0025] In an optional implementation, before traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview, the method further includes:
[0026] Determine whether the target user interface control belongs to the preset blocked controls;
[0027] If the target user interface control does not belong to the preset blocked controls, then traverse each subview in the target user interface control and obtain the interface information corresponding to each subview.
[0028] In one optional implementation, the blocking control includes: a keyboard control;
[0029] Determining whether the target user interface control belongs to a preset blocked control includes:
[0030] In response to traversing to any target user interface control, it checks whether the identifier corresponding to any target user interface control includes a preset field; wherein, the preset field is used to indicate that the target user interface control is a keyboard control;
[0031] If the identifier includes the preset field, then the detection of page elements for any target user interface control is blocked.
[0032] In one optional implementation, the step of determining whether a preset page element exists in the text information in response to the inclusion of the text information in the interface information includes:
[0033] Determine whether the interface information includes text information;
[0034] In response to the inclusion of the text information in the interface information, it is determined whether a preset page element exists in the text information.
[0035] In one optional implementation, the step of determining whether a preset page element exists in the text information in response to the inclusion of the text information in the interface information includes:
[0036] Using the page element as keywords, the words in the text information are filtered to determine whether the page element exists in the text information; or,
[0037] Based on a preset regular expression matching relationship, the text information is subjected to regular expression matching to determine whether the page element exists in the text information; wherein, the regular expression matching relationship is determined based on the page element.
[0038] Secondly, embodiments of this disclosure also provide a page detection device, comprising:
[0039] The monitoring module is used to monitor whether the page display content of the target application changes when the target application enables a preset function;
[0040] The first acquisition module is used to acquire the target user interface control located in the graphical user interface in response to a change in the page display content of the target application; and to traverse each subview in the target user interface control to acquire the interface information corresponding to each subview.
[0041] The first detection module is used to detect whether there are preset page elements in the interface information;
[0042] The reporting module is used to report the page element and the corresponding program statement to the detection server in response to the presence of the page element in the page information.
[0043] In one optional implementation, it further includes:
[0044] The second detection module is used to detect whether the setting information of the target application instructs the target application to enable a preset function after the target application is launched.
[0045] The second acquisition module is used to respond to the setting information of the target application instructing the target application to enable a preset function, and to acquire pre-injected detection environment configuration information from the program code of the target application;
[0046] The third detection module is used to configure the detection environment based on the detection environment configuration information, and to monitor whether the page display content of the target application changes under the detection environment.
[0047] In one optional implementation, the third detection module is specifically used for:
[0048] Hook functions are used to monitor whether a preset operation is triggered on the target page currently being displayed by the target application;
[0049] In response to detecting a preset operation triggered on the target page, it is determined that the page display content of the target application has changed.
[0050] In one optional implementation, the first acquisition module is specifically used for:
[0051] Iterate through the parent controls of the target user interface control and obtain the class name of the parent control;
[0052] The class name corresponding to the target user interface control and the class name of the parent control are concatenated to obtain a concatenated string; and
[0053] Number the target user interface control and its sibling controls;
[0054] Based on the concatenated string and the number, an identifier for the target user interface control is generated;
[0055] Based on the identifier, traverse each subview in the target user interface control to obtain the interface information corresponding to each subview.
[0056] In an optional implementation, the second acquisition unit is further configured to:
[0057] In response to traversing to any subview in the target user interface control, determine whether the subview is visible;
[0058] In response to the visibility of the subview, retrieve the interface information corresponding to the subview.
[0059] In an optional implementation, the first acquisition module further includes:
[0060] The first determining unit is used to determine whether the target user interface control belongs to a preset blocked control;
[0061] The third acquisition unit is used to, in response to the fact that the target user interface control does not belong to the preset blocked control, traverse each subview in the target user interface control and acquire the interface information corresponding to each subview.
[0062] In one optional implementation, the blocking control includes: a keyboard control;
[0063] The first determining unit is specifically used for:
[0064] In response to traversing to any target user interface control, it checks whether the identifier corresponding to any target user interface control includes a preset field; wherein, the preset field is used to indicate that the target user interface control is a keyboard control;
[0065] If the identifier includes the preset field, then the detection of page elements for any target user interface control is blocked.
[0066] In one optional implementation, the first detection module includes:
[0067] The second determining unit is used to determine whether the interface information includes text information;
[0068] The third determining unit is used to determine whether a preset page element exists in the text information in response to the inclusion of the text information in the interface information.
[0069] In one optional implementation, the third determining unit is specifically used for:
[0070] Using the page element as keywords, the words in the text information are filtered to determine whether the page element exists in the text information; or,
[0071] Based on a preset regular expression matching relationship, the text information is subjected to regular expression matching to determine whether the page element exists in the text information; wherein, the regular expression matching relationship is determined based on the page element.
[0072] Thirdly, embodiments of this disclosure also provide a computer device, including: 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 communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps of the first aspect above, or any possible implementation of the first aspect, are performed.
[0073] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the first aspect or any possible implementation of the first aspect.
[0074] This disclosure provides a page detection method, apparatus, computer device, and readable storage medium. It monitors whether the content displayed on a target application's page changes, obtains interface information when the page display state changes, traverses each sub-view in the target user interface control to obtain corresponding interface information, detects whether a preset page element exists in the interface information, and when a page element is found, reports the page element and its corresponding program statement to a detection server. This enables the detection of the target application's interface information while using an APP, improving the accuracy of problem detection.
[0075] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0076] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0077] Figure 1 A flowchart of a page detection method provided by an embodiment of this disclosure is shown;
[0078] Figure 2 A schematic diagram of a page detection device provided in an embodiment of this disclosure is shown;
[0079] Figure 3A schematic diagram of another page detection device provided in an embodiment of this disclosure is shown;
[0080] Figure 4 A schematic diagram of the first acquisition module in the page detection device provided in this embodiment of the present disclosure is shown.
[0081] Figure 5 A schematic diagram of the first detection module in the page detection device provided in this embodiment of the present disclosure is shown.
[0082] Figure 6 A schematic diagram of a computer device provided in an embodiment of this disclosure is shown. Detailed Implementation
[0083] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.
[0084] In some cases, it is necessary to inspect the information displayed on the app interface. Currently, static code scanning is often used to inspect this information. However, static code scanning cannot accurately identify whether some target words are still displayed on the app interface after some display conditions have been changed, so the accuracy of page inspection is not high.
[0085] Static scanning checks for vulnerabilities by scanning the source code without running the program. However, because the program is not running, static scanning has many problems that make it difficult to accurately identify targets. Therefore, other methods are needed to solve these problems.
[0086] Based on the above research, this disclosure provides a page detection method. This method monitors whether the content displayed on the target application's page changes and obtains the interface information of the target application when the page display state changes. By traversing each sub-view in the target user interface control, the corresponding interface information is obtained. Then, it detects whether a preset page element exists in the interface information. When it is determined that a page element exists in the page information, the page element and its corresponding program statement are reported to the detection server. This enables the detection of the target application's interface information while the APP is in use, improving the accuracy of problem detection.
[0087] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.
[0088] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0089] To facilitate understanding of this embodiment, a page detection method disclosed in this disclosure will first be described in detail. The execution entity of the page detection method provided in this disclosure is generally a computer device with certain computing capabilities. This computer device may include, for example, a terminal device, a server, or other processing devices. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, the page detection method can be implemented by a processor calling computer-readable instructions stored in memory.
[0090] This disclosure embodiment can also be used in rack servers, in which a terminal environment can be deployed. The rack server can use scripts to run an APP in the terminal environment and control the APP to perform various operations. Using the page detection method provided in this disclosure embodiment, the content in the page can be detected.
[0091] The following describes the page detection method provided in this embodiment of the present disclosure, taking the terminal device as the execution subject as an example.
[0092] See Figure 1The diagram shows a flowchart of a page detection method provided in an embodiment of this disclosure. The method includes steps S101 to S103, wherein:
[0093] S101: When the target application enables the preset function, monitor whether the page display content of the target application changes.
[0094] In this embodiment of the disclosure, the target application can be any application that has a display page.
[0095] The interface of the target application may include a main page and multiple sub-pages. The main page may be the page displayed when the application is launched, and the sub-pages may be the pages launched in response to trigger operations on controls or positions on the main page.
[0096] In one possible embodiment, a change in the page display state of the target application may refer to a change in the page display state during dynamic changes on the same page, and / or a change in the page display state in response to switching between different pages.
[0097] In one possible embodiment, the target application can be placed under conditions that allow for detection by configuring the detection environment, specifically:
[0098] After launching the target application, it is detected whether the target application's settings instruct the target application to enable a preset function;
[0099] In response to the setting information of the target application instructing the target application to enable a preset function, the pre-injected detection environment configuration information is obtained from the program code of the target application;
[0100] Based on the detection environment configuration information, a detection environment is configured, and under the detection environment, the page display content of the target application is monitored for changes.
[0101] For example, the preset functions may include the user enabling features such as "Do Not Disturb," "No Recommendations," and "Disable Personalization." After launching the target application, it can first detect whether the target application's settings indicate that the target application has enabled the corresponding functions. Once it is determined that the target application has enabled the preset functions, the pre-injected detection environment configuration information can be obtained from the target application's program code.
[0102] In this way, when the app starts and performs detection, preset functions can be automatically activated to form a detection environment. Within this environment, the app can detect whether the content displayed on the target application's page has changed. Specifically, the user can configure the app to disable personalized recommendations. When the app reads this configuration, it needs to disable personalized recommendations through program code logic, thus creating the detection environment.
[0103] For example, the ability to perform page inspection on an app, as well as the configuration information for the inspection environment, can be pre-injected into the target application's code using a repacking method. Repacking is a general method that injects dynamic libraries and the contents of common files (info.plist) in the project into the code through resigning. The interaction between the user and the app is controlled by pre-defined fields in the info.plist of the application code, which control whether to enable a special inspection environment, whether to enable the inspection, and which page elements need to be inspected. During this process, the inspection environment reads the user's configuration information when the app starts, registers and implements the corresponding configuration information. After obtaining the configuration information and enabling the corresponding configuration functions, it stores some target information in memory and then enters the specific inspection environment to perform automated testing on the target application.
[0104] In some possible implementations, changes in the page display content of the target application are detected by the following methods:
[0105] Hook functions are used to monitor whether a preset operation is triggered on the target page currently being displayed by the target application;
[0106] In response to detecting a preset operation triggered on the target page, it is determined that the page display content of the target application has changed.
[0107] The hook function can be a hook function. Preset operations on the target page can include interactive operations such as swiping, clicking, pulling down, and swiping up. These interactive operations can be controlled by the user and / or automated detection tools.
[0108] For example, when an app detects a preset operation, it passes the event to the correct response object through an event response chain. The application programming interface (API) for passing events includes, for example:
[0109] -(void)sendEvent:(UIEvent*)event;
[0110] In this way, by using hooks to detect the target program, changes in the page display state of the target application can be detected when the content displayed on the APP changes.
[0111] Following the above S101, the page detection method provided in this embodiment further includes:
[0112] S102: In response to a change in the page display content of the target application, obtain the target user interface control located in the graphical user interface; traverse each subview in the target user interface control and obtain the interface information corresponding to each subview.
[0113] The graphical user interface is Windows. When it is determined that the page display content of the target application has changed, the target user interface control in Windows is obtained, and each subview in the target user interface control is traversed to obtain the interface information corresponding to each subview.
[0114] For example, when the page display state changes, a graphical user interface can be obtained from the target page, such as the target user interface control displayed in the image. This target user interface control can navigate to different subviews in response to user or automated testing tool actions. Then, each subview within the target user interface control is traversed to obtain the interface information corresponding to each subview.
[0115] For example, all Windows controls (Views) within the app can be detected, and the following code retrieves all Windows-related program code for the app's current state:
[0116] [UI APplication shared APplication].windows
[0117] In this way, a recursive traversal logic can be used to sequentially examine the subviews or subcontrols of each target user interface control (UIView).
[0118] For example, there are two opportunities to traverse each subview in the target user interface control and obtain the interface information corresponding to each subview:
[0119] Timing (1): When the screen is touched;
[0120] Timing (2): When leaving the screen.
[0121] Among them, timing (2) will cause subsequent logic and event logic to run in parallel, resulting in inaccurate interface information. Therefore, it is possible to select a time (1) when the interface information is relatively stable to start traversing each subview in the target user interface control and obtain the interface information corresponding to each subview.
[0122] In one possible embodiment, traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview includes the following:
[0123] Iterate through the parent controls of the target user interface control and obtain the class name of the parent control;
[0124] The class name corresponding to the target user interface control and the class name of the parent control are concatenated to obtain a concatenated string; and
[0125] Number the target user interface control and its sibling controls;
[0126] Based on the concatenated string and the number, an identifier for the target user interface control is generated;
[0127] Based on the identifier, traverse each subview in the target user interface control to obtain the interface information corresponding to each subview.
[0128] For example, for an application on an Android terminal, a control with the category name bds_get Elem Text can be created for the target user interface control, and the bds_get Elem Text method can be implemented to obtain interface information. In other words, an interface is provided for all target user interface controls and controls that inherit from the target user interface control, so that the ability to obtain the interface information of each control can be obtained through this interface.
[0129] For example, for iOS applications, the inheritance chain (i.e., the element path of each control) can be obtained. Since the iOS system is different from the Android system, each target user interface control does not have a unique identifier, but the element path can uniquely represent the target user interface control, thus enabling reverse testing of the target user interface control.
[0130] Specifically, by iterating through the parent controls (self superview) of the target user interface control one by one, concatenating the class names of the parent controls, and numbering the sibling controls of the target user interface control, a unique identifier for the target user interface control can be generated.
[0131] In another possible embodiment, the step of traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview further includes:
[0132] In response to traversing to any subview in the target user interface control, determine whether the subview is visible;
[0133] In response to the visibility of the subview, retrieve the interface information corresponding to the subview.
[0134] For example, since the detection result is considered invalid when the subview is not visible, a method can be created during the detection process of the target user interface control to detect whether the current subview is visible. Once it is determined that the subview is visible, the interface information corresponding to the subview is obtained.
[0135] Specifically, visibility can be determined based on the hidden and alpha properties of the view. For subviews with width and height less than 1.0 and `[selfclipsToBounds]`, the portion of the subview that exceeds the bounds can be clipped. In addition to detecting the current subview, alignment with the superview needs to be handled: first, the coordinates of the subview within the superview need to be calculated using `CGRect frame = [superview convertRect: self.bounds? fromView: self]`; then, it needs to be checked whether the subview and superview overlap using `[CGRectIntersectsRect]` and whether the superview has `clipsToBounds` set.
[0136] In another possible embodiment, before traversing each subview in the target user interface control and obtaining the interface information corresponding to each subview, it can be determined whether the target user interface control belongs to a preset blocked control. In response to the target user interface control not belonging to the preset blocked control, each subview in the target user interface control is traversed and the interface information corresponding to each subview is obtained.
[0137] For example, if a user does not want certain controls to be detected, they can use an info.plist file to instruct the automated detection tool to block those controls. For instance, controls can be identified based on element paths.
[0138] In one possible embodiment, the blocking control may include a keyboard control; correspondingly, whether the target user interface control belongs to the preset blocking control is determined by the following method:
[0139] In response to traversing to any target user interface control, it checks whether the identifier corresponding to any target user interface control includes a preset field; wherein, the preset field is used to indicate that the target user interface control is a keyboard control;
[0140] If the identifier includes the preset field, then the detection of page elements for any target user interface control is blocked.
[0141] For example, controls, prompts, and emojis on the keyboard can be masked. Since the user interface controls of the keyboard inherit from UI Remote Keyboard Window, when traversing the user interface controls, checking whether their inheritance chain contains UI Remote Keyboard Window can identify the user interface control as a keyboard control and mask it.
[0142] Following S102 above, the page detection method provided in this embodiment further includes:
[0143] S103: Detect whether there are preset page elements in the interface information.
[0144] The page elements can be pre-defined keywords or target terms, phrases, or sentences with a specific structure or format. Additionally, they can be other page elements such as icons and links.
[0145] Specifically, the presence of preset page elements in the interface information is detected through the following steps:
[0146] Determine whether the interface information includes text information;
[0147] In response to the inclusion of the text information in the interface information, it is determined whether a preset page element exists in the text information.
[0148] For example, during the detection process, a method to determine whether the interface information includes text information can be to dynamically detect whether the target user interface control has a text attribute. If so, the text information corresponding to the text attribute is obtained, and operations such as checking for nullability and type determination are performed. If it is determined that the interface information does not include text information, no further operations are required.
[0149] In another possible embodiment, in response to the inclusion of the text information in the interface information, the presence of a preset page element in the text information is determined by the following steps:
[0150] Using the page element as keywords, the words in the text information are filtered to determine whether the page element exists in the text information; or,
[0151] Based on a preset regular expression matching relationship, the text information is subjected to regular expression matching to determine whether the page element exists in the text information; wherein, the regular expression matching relationship is determined based on the page element.
[0152] For example, one can directly filter whether the text information includes page elements, or determine whether the text information includes two or more preset words. These two or more preset words together serve as keywords. When a keyword composed of two or more preset words is detected, it is determined that a page element exists.
[0153] Following S103 above, the page detection method provided in this embodiment further includes:
[0154] S104: In response to the existence of the page element in the page information, the page element and the corresponding program statement are reported to the detection server.
[0155] In this embodiment, when it is determined that the page element exists in the page information, it can be determined that the target application has some preset problems. At this time, the problems corresponding to the page element and the program statements corresponding to the page element can be reported to the detection server so that the staff can make adjustments and corrections.
[0156] This embodiment of the disclosure monitors whether the page display content of the target application changes, and obtains the interface information of the target application when the page display state changes. By traversing each subview in the target user interface control, the corresponding interface information is obtained, and then the presence of preset page elements in the interface information is detected. When it is determined that there are page elements in the page information, the page elements and the corresponding program statements are reported to the detection server. This enables the detection of the interface information of the target application when using the APP, thereby improving the accuracy of problem detection.
[0157] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0158] Based on the same inventive concept, this disclosure also provides a page detection device corresponding to the page detection method. Since the principle of the device in this disclosure for solving the problem is similar to the page detection method described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0159] Reference Figure 2 The diagram shown is a schematic of a page detection device provided in an embodiment of this disclosure. The device includes: a monitoring module 210, a first acquisition module 220, a first detection module 230, and a reporting module 240; wherein,
[0160] The monitoring module 210 is used to monitor whether the page display content of the target application changes when the target application enables a preset function;
[0161] The first acquisition module 220 is used to monitor whether the page display content of the target application changes when the target application enables a preset function;
[0162] The first detection module 230 is used to detect whether there are preset page elements in the interface information;
[0163] The reporting module 240 is used to report the page element and the corresponding program statement to the detection server in response to the presence of the page element in the page information.
[0164] In one alternative implementation, refer to Figure 3 The diagram shown is a schematic of another page detection device provided in an embodiment of this disclosure; the device further includes:
[0165] The second detection module 250 is used to detect whether the setting information of the target application instructs the target application to enable a preset function after the target application is launched.
[0166] The second acquisition module 260 is used to, in response to the setting information of the target application instructing the target application to enable a preset function, acquire pre-injected detection environment configuration information from the program code of the target application.
[0167] The third detection module 270 is used to configure a detection environment based on the detection environment configuration information, and to monitor whether the page display content of the target application changes under the detection environment.
[0168] In one optional implementation, the third detection module 270 is specifically used for:
[0169] Hook functions are used to monitor whether a preset operation is triggered on the target page currently being displayed by the target application;
[0170] In response to detecting a preset operation triggered on the target page, it is determined that the page display content of the target application has changed.
[0171] In one optional implementation, the first acquisition module 220 is specifically used for:
[0172] Iterate through the parent controls of the target user interface control and obtain the class name of the parent control;
[0173] The class name corresponding to the target user interface control and the class name of the parent control are concatenated to obtain a concatenated string; and
[0174] Number the target user interface control and its sibling controls;
[0175] Based on the concatenated string and the number, an identifier for the target user interface control is generated;
[0176] Based on the identifier, traverse each subview in the target user interface control to obtain the interface information corresponding to each subview.
[0177] In an optional implementation, the first acquisition module 220 is further configured to:
[0178] In response to traversing to any subview in the target user interface control, determine whether the subview is visible;
[0179] In response to the visibility of the subview, retrieve the interface information corresponding to the subview.
[0180] In one alternative implementation, refer to Figure 4 The diagram shown is a schematic representation of the first acquisition module in the page detection device provided in this embodiment of the present disclosure; the first acquisition module 220 includes:
[0181] The first determining unit 221 is used to determine whether the target user interface control belongs to a preset blocked control;
[0182] The first acquisition unit 222 is used to, in response to the target user interface control not belonging to a preset blocked control, traverse each subview in the target user interface control and acquire the interface information corresponding to each subview.
[0183] In one optional implementation, the blocking control includes: a keyboard control;
[0184] The first determining unit 221 is specifically used for:
[0185] In response to traversing to any target user interface control, it checks whether the identifier corresponding to any target user interface control includes a preset field; wherein, the preset field is used to indicate that the target user interface control is a keyboard control;
[0186] If the identifier includes the preset field, then the detection of page elements for any target user interface control is blocked.
[0187] In one alternative implementation, refer to Figure 5 The diagram shown is a schematic representation of the first detection module in the page detection device provided in this embodiment of the present disclosure; the first detection module 230 includes:
[0188] The second determining unit 231 is used to determine whether the interface information includes text information;
[0189] The third determining unit 232 is used to determine whether a preset page element exists in the text information in response to the inclusion of the text information in the interface information.
[0190] In one optional implementation, the third determining unit 232 is specifically used for:
[0191] Using the page element as keywords, the words in the text information are filtered to determine whether the page element exists in the text information; or,
[0192] Based on a preset regular expression matching relationship, the text information is subjected to regular expression matching to determine whether the page element exists in the text information; wherein, the regular expression matching relationship is determined based on the page element.
[0193] This embodiment of the disclosure monitors whether the page display content of the target application changes, and obtains the interface information of the target application when the page display state changes. By traversing each subview in the target user interface control, the corresponding interface information is obtained, and then the presence of preset page elements in the interface information is detected. When it is determined that there are page elements in the page information, the page elements and the corresponding program statements are reported to the detection server. This enables the detection of the interface information of the target application when using the APP, thereby improving the accuracy of problem detection.
[0194] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0195] Based on the same technical concept, this disclosure also provides a computer device. (See also...) Figure 6The diagram shows the structure of a computer device provided in this embodiment, including a processor 601, a memory 602, and a bus 603. The memory 602 stores execution instructions and includes main memory 6021 and external memory 6022. The main memory 6021, also called internal memory, is used to temporarily store computational data in the processor 601 and data exchanged with external memory 6022 such as a hard disk. The processor 601 exchanges data with the external memory 6022 through the main memory 6021. When the computer device is running, the processor 601 and the memory 602 communicate through the bus 603, causing the processor 601 to execute the following instructions:
[0196] With the target application having preset functions enabled, monitor whether the page display content of the target application changes;
[0197] In response to a change in the page display content of the target application, the target user interface control located in the graphical user interface is obtained; each subview in the target user interface control is traversed to obtain the interface information corresponding to each subview;
[0198] Detect whether there are preset page elements in the interface information;
[0199] If the page element is found in the page information, the page element and the corresponding program statement are reported to the detection server.
[0200] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the page detection method described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0201] The computer program product of the page detection method provided in this disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the steps of the page detection method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0202] This disclosure also provides a computer program that, when executed by a processor, implements any of the methods described in the foregoing embodiments. The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0203] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0204] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0205] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0206] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0207] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A method of detecting a page, characterized by, The method comprises the following steps: monitoring whether the page display content of the target application program changes in the case that the target application program starts the preset function; obtaining the target user interface control located in the graphical interaction interface in response to the change of the page display content of the target application program; traversing each sub-view in the target user interface control to obtain the interface information corresponding to each sub-view; detecting whether the preset page element exists in the interface information; reporting the page element and the program statement corresponding to the page element to the detection server in response to the existence of the page element in the interface information, wherein the step of traversing each sub-view in the target user interface control to obtain the interface information corresponding to each sub-view comprises the following steps: traversing the parent control of the target user interface control to obtain the class name of the parent control; splicing the class name corresponding to the target user interface control and the class name of the parent control to obtain a spliced string; and numbering the target user interface control and the sibling control of the target user interface control; generating the identifier of the target user interface control based on the spliced string and the number; traversing each sub-view in the target user interface control based on the identifier to obtain the interface information corresponding to each sub-view.
2. The method of claim 1, wherein, The step of monitoring whether the page display content of the target application program changes in the case that the target application program starts the preset function comprises the following steps: detecting whether the setting information of the target application program indicates that the target application program starts the preset function after starting the target application program; obtaining the pre-injected detection environment configuration information from the program code of the target application program in response to the setting information of the target application program indicating that the target application program starts the preset function; configuring the detection environment based on the detection environment configuration information, and monitoring whether the page display content of the target application program changes in the detection environment.
3. The method of claim 2, wherein, The step of monitoring whether the page display content of the target application program changes comprises the following steps: monitoring whether the preset operation on the target page currently displayed by the target application program is triggered by using a hook function; determining that the page display content of the target application program changes in response to monitoring that the preset operation on the target page is triggered.
4. The method of claim 1, wherein, The step of traversing each sub-view in the target user interface control to obtain the interface information corresponding to each sub-view further comprises the following steps: determining whether any sub-view in the target user interface control is visible in response to traversing the sub-view; obtaining the interface information corresponding to the sub-view in response to the sub-view being visible.
5. The method of claim 1, wherein, The step of traversing each sub-view in the target user interface control to obtain the interface information corresponding to each sub-view further comprises the following steps: determining whether the target user interface control belongs to the preset shielding control; traversing each sub-view in the target user interface control to obtain the interface information corresponding to each sub-view in response to the target user interface control not belonging to the preset shielding control.
6. The method of claim 5, wherein, The shielding control comprises a keyboard control. The determining whether the target user interface control belongs to a preset shielding control comprises: In response to traversing any target user interface control, detecting whether a preset field is included in an identifier corresponding to the any target user interface control; wherein the preset field is used to indicate that the target user interface control is a keyboard control; In response to the preset field being included in the identifier, shielding detection of a page element on the any target user interface control.
7. The method of claim 1, wherein, The detecting whether a preset page element exists in the interface information comprises: Determining whether text information is included in the interface information; In response to the text information being included in the interface information, determining whether a preset page element exists in the text information.
8. The method of claim 7, wherein, The determining whether a preset page element exists in the text information in response to the text information being included in the interface information comprises: Filtering words in the text information with the page element as a keyword to determine whether the page element exists in the text information; or Based on a preset regular matching relationship, performing regular matching on the text information to determine whether the page element exists in the text information; wherein the regular matching relationship is determined based on the page element.
9. A page detection apparatus characterized by comprising: Comprise: The monitoring module is used for monitoring whether the page display content of the target application program changes in the case that the target application program starts a preset function; The first acquisition module is used for acquiring a target user interface control located in a graphical interaction interface in response to the page display content of the target application program changing; traversing each sub-view in the target user interface control to acquire interface information corresponding to each sub-view; The first detection module is used for detecting whether a preset page element exists in the interface information; The reporting module is used for reporting the page element and a program statement corresponding to the page element to a detection server in response to the page element existing in the interface information, Wherein, the traversing each sub-view in the target user interface control to acquire interface information corresponding to each sub-view comprises: Traversing a parent control of the target user interface control to acquire a class name of the parent control; Splicing the class name corresponding to the target user interface control and the class name of the parent control to obtain a spliced string; and Numbering the target user interface control and sibling controls of the target user interface control; Generating an identifier of the target user interface control based on the spliced string and the numbering; Based on the identifier, traversing each sub-view in the target user interface control to acquire interface information corresponding to each sub-view.
10. A computer device, comprising: Comprise: A processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the computer device runs, the processor and the memory communicate through the bus, the machine readable instructions are executed by the processor to execute the steps of the page detection method in any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program performs the steps of the page detection method according to any one of claims 1 to 8 when the computer program is run by the processor.
Citation Information
Patent Citations
Page element attribute viewing method and device
CN110399063A
Interactive behavior monitoring method and device and computer equipment
CN110674025A