Page view control detection method and device
Parallel detection of the page structure tree in dual-thread mode solves the problem of long detection time of view controls in UI automated testing, improves detection efficiency, avoids test interruption, and enables timely processing of pages with complex UI structures.
Patent Information
- Application Number
- CN202110333030.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-29
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-03-29
AI Technical Summary
In UI automated testing, the detection time of view controls is long, resulting in pages with complex UI structures unable to be processed in time, affecting the running progress of the test script.
Use dual-thread mode to detect the page structure tree in parallel, traverse the page structure tree simultaneously through the view control detection thread and the operation control detection thread, obtain the target view control and operation control, and generate driver instructions to process the target operation control after obtaining the view control detection result .
This greatly saves time in detecting controls, improves detection efficiency, and avoids interruption of the automated testing process due to sudden appearance of view controls.
Smart Images

Figure CN113032264B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of user interface design (UI) automated testing, and provides a method and device for detecting a page view control. Background Art
[0002] In the UI automation testing technology in the related art, Python, Java and other scripting languages are usually used to write test scripts, and then open source APIs are called to perform UI automation testing. However, in the process of running the test script, the sudden appearance of view controls (such as pop-up windows, prompt boxes, etc.) will hinder the UI automation testing process and interrupt the running of the test script. Therefore, in order to ensure that the UI automation testing process can run smoothly and orderly, image recognition or polling page structure can be used to determine whether view controls appear.
[0003] However, for pages with complex UI structures, the detection time using the above two methods is relatively long, resulting in the view controls not being processed in a timely manner, which in turn affects the running progress of the test script.
[0004] In view of this, the embodiments of the present disclosure provide a new method and device for detecting a page view control. Summary of the invention
[0005] The embodiments of the present disclosure provide a method and device for detecting a page view control to solve the problem of a long detection time for a view control.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for detecting a page view control, including:
[0007] In response to the control query request sent by the test script, obtain the first page structure tree of the current page of the test object;
[0008] Calling a view control detection thread to traverse the first page structure tree to detect whether a target view control exists in the first page structure tree, and in parallel calling an operation control detection thread to traverse the first page structure tree to obtain a target operation control;
[0009] After obtaining the view control detection result, a driving instruction for the target operation control is generated to perform a corresponding operation on the target operation control.
[0010] Optionally, the calling view control detection thread traverses the first page structure tree to detect whether a target view control exists in the first page structure tree, including:
[0011] Traversing each control in the first page structure tree through the view control detection thread;
[0012] For each traversed control, if the first control retrieval information of the corresponding control is matched with the preset second control retrieval information set and a corresponding matching item is obtained, a corresponding view control detection result is generated, and the view control detection result indicates that the control that obtains the matching item is the target view control;
[0013] The target view control is closed based on the view control detection result.
[0014] Optionally, the calling view control detection thread traverses the first page structure tree to detect whether a target view control exists in the first page structure tree, including:
[0015] Traversing each control in the first page structure tree through the view control detection thread;
[0016] For each traversed control, if the first control retrieval information of the corresponding control does not obtain a corresponding match after matching with the preset second control retrieval information set, a corresponding view control detection result is generated, and the view control detection result indicates that the target view control does not exist in the first page structure tree.
[0017] Optionally, the second control retrieval information set includes at least one second control retrieval information, and the second control retrieval information is obtained in the following manner:
[0018] Acquire a second page structure tree of a history page based on the history detection record, the history page including a history view control, the second page structure tree including a first control identifier of the history view control;
[0019] Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier;
[0020] Acquire a control title of the history view control and text information of the history view control according to the substructure tree;
[0021] The first control identifier, the control title of the history view control, and the text information of the history view control are encapsulated as the second control retrieval information.
[0022] Optionally, the target view control is any one of the following:
[0023] Pop-up windows, floating layers, prompt boxes, and bubble boxes.
[0024] Optionally, the parallel calling of the operation control detection thread to traverse the first page structure tree to obtain the target operation control includes:
[0025] Traversing each control in the first page structure tree through the operation control detection thread;
[0026] For each traversed control, if the first control retrieval information of the corresponding control matches the second control identifier, the control is determined as the target operation control;
[0027] The second control identifier is obtained based on a control query request sent by a test script.
[0028] Optionally, after obtaining the view control detection result, generating a driving instruction for the target operation control includes:
[0029] Before obtaining the view control detection result, if the operation control detection thread has completed the traversal and obtained the target operation control, the operation control detection thread is temporarily blocked;
[0030] After the traversal of the view control detection thread is completed, the operation control detection thread is re-awakened, and based on the obtained view control detection result, a driving instruction for the target operation control is generated.
[0031] Optionally, generating a driving instruction for the target operation control includes:
[0032] Sending the driving information and driving event of the target operation control to the control driving thread through the operation control detection thread, wherein the driving information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page, and the driving event is a behavior event that is expected to be triggered by the driving instruction for the target operation control, and the driving event is obtained based on the control query request sent by the test script;
[0033] The control driving thread is called to encapsulate the driving information and the driving event to generate the driving instruction.
[0034] In a second aspect, the embodiment of the present disclosure further provides a detection device for a page view control, including:
[0035] An acquisition unit, used to acquire a first page structure tree of a current page of a test object in response to a control query request sent by a test script;
[0036] A detection unit, configured to call a view control detection thread to traverse the first page structure tree to detect whether a target view control exists in the first page structure tree, and to call an operation control detection thread to traverse the first page structure tree in parallel to obtain a target operation control;
[0037] The processing unit is used to generate a driving instruction for the target operation control after obtaining the view control detection result, so as to perform a corresponding operation on the target operation control.
[0038] Optionally, the detection unit is used to:
[0039] Traversing each control in the first page structure tree through the view control detection thread;
[0040] For each traversed control, if the first control retrieval information of the corresponding control is matched with the preset second control retrieval information set and a corresponding matching item is obtained, a corresponding view control detection result is generated, and the view control detection result indicates that the control that obtains the matching item is the target view control;
[0041] The target view control is closed based on the view control detection result.
[0042] Optionally, the detection unit is used to:
[0043] Traversing each control in the first page structure tree through the view control detection thread;
[0044] For each traversed control, if the first control retrieval information of the corresponding control does not obtain a corresponding match after matching with the preset second control retrieval information set, a corresponding view control detection result is generated, and the view control detection result indicates that the target view control does not exist in the first page structure tree.
[0045] Optionally, the second control retrieval information set includes at least one second control retrieval information, and the device further includes a generating unit, and the generating unit obtains the second control retrieval information in the following manner:
[0046] Acquire a second page structure tree of a history page based on the history detection record, the history page including a history view control, the second page structure tree including a first control identifier of the history view control;
[0047] Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier;
[0048] Acquire a control title of the history view control and text information of the history view control according to the substructure tree;
[0049] The first control identifier, the control title of the history view control, and the text information of the history view control are encapsulated as the second control retrieval information.
[0050] Optionally, the target view control is any one of the following:
[0051] Pop-up windows, floating layers, prompt boxes, and bubble boxes.
[0052] Optionally, the detection unit is used to:
[0053] Traversing each control in the first page structure tree through the operation control detection thread;
[0054] For each traversed control, if the first control retrieval information of the corresponding control matches the second control identifier, the control is determined as the target operation control;
[0055] The second control identifier is obtained based on a control query request sent by a test script.
[0056] Optionally, the processing unit is used to:
[0057] Before obtaining the view control detection result, if the operation control detection thread has completed the traversal and obtained the target operation control, the operation control detection thread is temporarily blocked;
[0058] After the traversal of the view control detection thread is completed, the operation control detection thread is re-awakened, and based on the obtained view control detection result, a driving instruction for the target operation control is generated.
[0059] Optionally, the processing unit is used to:
[0060] Sending the driving information and driving event of the target operation control to the control driving thread through the operation control detection thread, wherein the driving information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page, and the driving event is a behavior event that is expected to be triggered by the driving instruction for the target operation control, and the driving event is obtained based on the control query request sent by the test script;
[0061] The control driving thread is called to encapsulate the driving information and the driving event to generate the driving instruction.
[0062] In a third aspect, an embodiment of the present disclosure further provides a computer device, comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of any one of the above-mentioned page view control detection methods.
[0063] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of any one of the above-mentioned page view control detection methods.
[0064] The beneficial effects of the present disclosure are as follows:
[0065] The disclosed embodiment provides a method and device for detecting a page view control, the method comprising: in response to a control query request sent by a test script, obtaining a first page structure tree of the current page of the test object, calling a view control detection thread to traverse the first page structure tree, detecting whether a target view control exists in the first page structure tree, and calling an operation control detection thread to traverse the first page structure tree in parallel to obtain a target operation control; after obtaining the view control detection result, generating a drive instruction for the target operation control to perform a corresponding operation on the target operation control. The strategy of parallel detection of the page structure tree in a dual-thread mode, especially for pages with complex UI structures, greatly saves the time spent on detecting controls, which is conducive to improving detection efficiency. By utilizing the characteristics of the waiting mechanism, after obtaining the view control detection result and ensuring that the target view control in the current page has been closed, or the target view control does not exist in the current page, a drive instruction for the target operation control is generated to avoid interruption of the automated test process due to a sudden pop-up target view control.
[0066] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or be understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0068] Figure 1 This is an optional schematic diagram of an application scenario in an embodiment of the present disclosure;
[0069] Figure 2a It is a flowchart of a detection method of a page view control in an embodiment of the present disclosure;
[0070] Figure 2b This is a schematic diagram of the home page of a music app;
[0071] Figure 2c It is a schematic diagram of the process of the view control detection thread traversing the first page structure tree in the embodiment of the present disclosure;
[0072] Figure 2d is a schematic diagram of a floating window in an embodiment of the present disclosure;
[0073] Figure 2e is a schematic diagram of a prompt box in an embodiment of the present disclosure;
[0074] Figure 2f is a schematic diagram of a bubble frame in an embodiment of the present disclosure;
[0075] Figure 3 It is a structural schematic diagram of a detection device for a page view control in an embodiment of the present disclosure;
[0076] Figure 4 It is a structural schematic diagram of a computer device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution 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 part of the embodiments of the technical solution of the present disclosure, rather than all the embodiments. Based on the embodiments recorded in the present disclosure document, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present disclosure.
[0078] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented using sequences other than those illustrated or described herein.
[0079] In the UI automation testing technology in the related art, Python, Java and other scripting languages are usually used to write test scripts, and then open source APIs are called to perform UI automation testing. However, in the process of running the test script, the sudden appearance of view controls (such as pop-up windows, prompt boxes, etc.) will hinder the UI automation testing process and interrupt the running of the test script. Therefore, in order to ensure that the UI automation testing process can run smoothly and orderly, image recognition or polling page structure can be used to determine whether a pop-up window appears.
[0080] However, for pages with complex UI structures, the detection time of the above two methods is relatively long, resulting in the view control not being processed in time, thereby affecting the running progress of the test script. In view of this, the embodiment of the present disclosure provides a new method and device for detecting page view controls.
[0081] See also Figure 1 The schematic diagram of the application scenario shown includes a test terminal 110 and a terminal under test 120. The test terminal 110 is a terminal for running a test script, such as a desktop computer, a laptop computer, or other electronic device with a test script running environment; the terminal under test 120 is a terminal installed with a tested application (Application, APP) and a UI automation test APP, such as a mobile phone, a tablet computer, or other portable electronic device. The API interface of the test terminal 110 is connected to the API interface of the terminal under test, and the UI automation test APP responds to the control query request sent by the test script to perform UI automation testing on the tested APP.
[0082] See also Figure 2a The flow chart shown introduces the detection method of the page view control provided by the embodiment of the present disclosure.
[0083] S201: In response to a control query request sent by a test script, a first page structure tree of a current page of a test object is obtained.
[0084] The test object refers to the APP under test installed on the terminal under test 120. When the UI automation test APP receives the control query request for the APP under test sent by the test script, the UI automation test APP obtains the first page structure tree of the current page of the APP under test, and parses the control query request to obtain the second control identifier of the target operation control and the drive event of the target operation control carried in the request, wherein the drive event refers to the behavior event triggered by the expected drive instruction for the target operation control. It should be pointed out that if the drive event is a multi-touch event, the test script can encapsulate the drive event and the second control identifiers of multiple target operation controls in the same control query request.
[0085] When obtaining the first page structure tree of the current page of the APP under test, the embodiment of the present disclosure also provides a preferred embodiment: the UI automation test APP adopts a non-polling strategy to obtain the first page structure tree of the current page, that is, if the UI automation test APP has previously obtained the first page structure tree of the page, there is no need to repeatedly obtain the first page structure tree, and the first page structure tree obtained before can be directly used, saving the time of obtaining the first page structure tree, simplifying the overall process, and improving work efficiency.
[0086] The first page structure tree includes at least a substructure tree of each control on the page, and each substructure tree includes the property information of the corresponding control. The property information includes at least the following properties and corresponding property values: control identification, control type, control coordinates (including the upper left corner coordinates and lower right corner coordinates of the control box), control title, control text information, subcontrols (subsidiary controls on the control, such as view close controls, etc.), subcontrol identification, and subcontrol coordinates. Among them, the control identification, control title, and control text information can be used as the first control retrieval information of the control to determine whether the control is a target view control.
[0087] For example, in Figure 2b There is a pop-up window on the homepage of the music APP shown, and the attribute information of the pop-up window is shown in Table 1.
[0088] Table 1
[0089] property Property Value Control Identification e2d96d56 Control Type View Controls Control coordinates (26,58)(56,27) Control title Get permissions Text information of the control "Do you want to allow the device's geographic location to be obtained?" Child Control 1 View Close Control Subcontrol 1 ID e2d96d5v Subcontrol 1 coordinates (50,57)(55,50) Child Control 2 Click Controls Subcontrol 2 ID e2d96d5c Text information of child control 2 "yes" Coordinates of child control 2 (28,30)(36,29) Child Control 3 Click Controls Subcontrol 3 ID e2d96d5d Text information of subcontrol 3 "no" Coordinates of child control 3 (45,30)(53,29)
[0090] S202: calling a view control detection thread to traverse the first page structure tree to detect whether a target view control exists in the first page structure tree, and calling an operation control detection thread to traverse the first page structure tree in parallel to obtain a target operation control.
[0091] Optional, see Figure 2c The flowchart shown in the figure introduces the process of the view control detection thread traversing the first page structure tree as follows:
[0092] S2021: Traverse each control in the first page structure tree through the view control detection thread.
[0093] When executing step 2021, the view control detection thread traverses each control in the first page structure tree in order from top to bottom.
[0094] However, before executing step 2021, the UI automation test APP obtains a second control retrieval information set from the local database of the tested terminal 120, and the second control retrieval information set includes at least one second control retrieval information. Some attribute information of the historical view control is added to the second control retrieval information set, so that the view control detection thread can quickly and accurately detect the target view control from the first page structure tree during the traversal process.
[0095] Specifically, the process of generating a second control to retrieve information is as follows:
[0096] Acquire a second page structure tree of a history page based on the history detection record, the history page includes a history view control, and the second page structure tree includes a first control identifier of the history view control;
[0097] Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier;
[0098] The control title of the history view control and the text information of the history view control are acquired according to the substructure tree, and the first control identifier, the control title of the history view control and the text information of the history view control are encapsulated as second control retrieval information.
[0099] The history page refers to a page where the history view control has appeared. For example, a click operation is performed on a social APP installed on the terminal 120 under test to enter the homepage of the social APP. When the homepage page has just been loaded, a prompt box for APP version update pops up in the center of the page.
[0100] S2022: For each traversed control, if the first control retrieval information of the corresponding control is matched with the second control retrieval information set to obtain a corresponding matching item, a corresponding view control detection result is generated, and the view control detection result indicates that the control that obtains the matching item is the target view control.
[0101] The first control retrieval information at least includes: the control identifier of the control, the control title of the control, and the text information of the control; a second control retrieval information in the second control retrieval information set at least includes: the first control identifier of the historical view control, the control title of the historical view control, and the text information of the historical view control. Therefore, the first control retrieval information is matched with each second control retrieval information respectively, and the historical view control that matches the control is taken as the matching item of the control, the control is determined as the target view control, and the view control detection result is generated.
[0102] S2023: Close the target view control based on the view control detection result.
[0103] According to the first control identifier of the historical view control in the view control detection result, the control closing information corresponding to the first control identifier is obtained from the local database, and the control closing information includes the sub-control identifier of the historical view closing sub-control and the position coordinates of the historical view closing sub-control in the historical view control.
[0104] Based on the sub-control identifier and the position coordinates of the historical view closing sub-control in the historical view control, the view closing sub-control on the control is obtained, and the target view control is closed by clicking the view closing sub-control, ensuring that when performing automated testing on the target operation control on the current page, the automated testing will not be interrupted by the target view control that suddenly pops up on the current page.
[0105] When the view control detection thread traverses each control in the first page structure tree, for each traversed control, if the first control retrieval information of the corresponding control is matched with the second control retrieval information set, and no corresponding matching item is obtained, then a corresponding view control detection result is generated, and the view control detection result indicates that the target view control does not exist in the first page structure tree. Since the target view control does not exist in the first page structure tree, when performing automated testing on the target operation control on the current page, the automated testing will not be interrupted by the target view control that suddenly pops up on the current page.
[0106] The target view control in the embodiment of the present disclosure may be any one of the following: a pop-up window, a floating layer, a prompt box, and a bubble box.
[0107] If the target view control is a pop-up window, if the pop-up window is not processed in time, the pop-up window may appear in the center of the page during the process of running the control driver thread. Figure 2b The pop-up window shown;
[0108] If the target view control is a floating window, if the floating window is not processed in time, a pop-up window of the form "<img src="https: / / mp.weixin.qq.com / s / 1.110.1 ... Figure 2d The floating window shown;
[0109] If the target view control is a prompt box, if the prompt box is not processed in time, a pop-up like Figure 2e The prompt box shown;
[0110] If the target view control is a bubble box, if the bubble box is not processed in time, a pop-up like Figure 2f The bubble box shown.
[0111] Optionally, the process of traversing the first page structure tree by the operation control detection thread is described as follows:
[0112] The control detection thread traverses each control in the first page structure tree, and for each traversed control, if the first control search information of the corresponding control matches the second control identifier, the control is determined as a target operation control, wherein the second control identifier is obtained based on the control query request sent by the test script.
[0113] The strategy of parallel detection of page structure tree in dual-thread mode is adopted, which greatly saves the time spent on detecting controls, especially for pages with complex UI structures, and is conducive to improving detection efficiency.
[0114] S203: After obtaining the view control detection result, a driving instruction for the target operation control is generated to perform a corresponding operation on the target operation control.
[0115] In the disclosed embodiment, a preset waiting mechanism is followed between the view control detection thread and the operation control detection thread, that is, before obtaining the view control detection result, if the operation control detection thread has completed the traversal and obtained the target operation control, the operation control detection thread is temporarily blocked; after the view control detection thread has completed the traversal, the operation control detection thread is re-awakened, and based on the obtained view control detection result, a driving instruction for the target operation control is generated. By utilizing the characteristics of the waiting mechanism, after obtaining the view control detection result and ensuring that the target view control in the current page is closed, or the target view control does not exist in the current page, a driving instruction for the target operation control is generated to avoid interruption of the automated test process due to the sudden pop-up of the target view control.
[0116] The drive information and drive events of the target operation control are sent to the control driving thread through the operation control detection thread, wherein the drive information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page; and then the control driving thread is called to encapsulate the drive information and drive events to generate a drive instruction.
[0117] For example, if the target operation control is a search bar, the position coordinates of the search bar in the current page are obtained, and for the driving event of the search bar "click the search bar", a driving instruction in the form of "click the search bar: the coordinates of the search bar" is generated. In addition to the click event, the embodiment of the present disclosure provides at least the following driving events: sliding events (such as pull-down menu, slide up to collapse the menu, slide to unlock), double-click events, multi-touch, specific gesture operations (such as drawing an "S" shape on the screen), and drag events.
[0118] See also Figure 3 The schematic diagram of the structure of the detection device of the page view control shown in FIG. 1 includes an acquisition unit 301, a detection unit 302 and a processing unit 303, wherein:
[0119] The acquisition unit 301 is used to acquire the first page structure tree of the current page of the test object in response to the control query request sent by the test script;
[0120] A detection unit 302 is used to call a view control detection thread to traverse the first page structure tree to detect whether a target view control exists in the first page structure tree, and to call an operation control detection thread to traverse the first page structure tree in parallel to obtain a target operation control;
[0121] The processing unit 303 is used to generate a driving instruction for the target operation control after obtaining the view control detection result, so as to perform a corresponding operation on the target operation control.
[0122] Optionally, the detection unit 302 is used to:
[0123] Traversing each control in the first page structure tree through the view control detection thread;
[0124] For each traversed control, if the first control retrieval information of the corresponding control is matched with the preset second control retrieval information set and a corresponding matching item is obtained, a corresponding view control detection result is generated, and the view control detection result indicates that the control that obtains the matching item is the target view control;
[0125] The target view control is closed based on the view control detection result.
[0126] Optionally, the detection unit 302 is used to:
[0127] Traversing each control in the first page structure tree through the view control detection thread;
[0128] For each traversed control, if the first control retrieval information of the corresponding control does not obtain a corresponding match after matching with the preset second control retrieval information set, a corresponding view control detection result is generated, and the view control detection result indicates that the target view control does not exist in the first page structure tree.
[0129] Optionally, the second control retrieval information set includes at least one second control retrieval information, and the device further includes a generating unit 304, and the generating unit 304 obtains the second control retrieval information in the following manner:
[0130] Acquire a second page structure tree of a history page based on the history detection record, the history page including a history view control, the second page structure tree including a first control identifier of the history view control;
[0131] Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier;
[0132] Acquire a control title of the history view control and text information of the history view control according to the substructure tree;
[0133] The first control identifier, the control title of the history view control, and the text information of the history view control are encapsulated as the second control retrieval information.
[0134] Optionally, the target view control is any one of the following:
[0135] Pop-up windows, floating layers, prompt boxes, and bubble boxes.
[0136] Optionally, the detection unit 302 is used to:
[0137] Traversing each control in the first page structure tree through the operation control detection thread;
[0138] For each traversed control, if the first control retrieval information of the corresponding control matches the second control identifier, the control is determined as the target operation control;
[0139] The second control identifier is obtained based on a control query request sent by a test script.
[0140] Optionally, the processing unit 303 is used to:
[0141] Before obtaining the view control detection result, if the operation control detection thread has completed the traversal and obtained the target operation control, the operation control detection thread is temporarily blocked;
[0142] After the traversal of the view control detection thread is completed, the operation control detection thread is re-awakened, and based on the obtained view control detection result, a driving instruction for the target operation control is generated.
[0143] Optionally, the processing unit 303 is used to:
[0144] Sending the driving information and driving event of the target operation control to the control driving thread through the operation control detection thread, wherein the driving information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page, and the driving event is a behavior event that is expected to be triggered by the driving instruction for the target operation control, and the driving event is obtained based on the control query request sent by the test script;
[0145] The control driving thread is called to encapsulate the driving information and the driving event to generate the driving instruction.
[0146] In some possible implementations, the present disclosure also provides a computer device, see Figure 4The structural diagram shown in FIG. 4 shows a computer device including at least one processor 401 and at least one memory 402. The memory 402 stores program codes. When the program codes are executed by the processor 401, the processor 401 executes the steps in the detection method of the page view control according to various exemplary embodiments of the present disclosure described above. For example, the processor 401 may execute the following steps: Figure 2a Follow the steps shown in .
[0147] In some possible implementations, various aspects of the detection method for a page view control provided by the present disclosure may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the detection method for a page view control according to various exemplary implementations of the present disclosure described above in this specification. For example, the computer device may execute the following steps: Figure 2a Follow the steps shown in .
[0148] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0149] The program product for business control of the embodiment of the present disclosure may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a computing device. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with a command execution system, device or device.
[0150] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.
[0151] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0152] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0153] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present disclosure.
[0154] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.
Claims
1. A method for detecting a page view control, characterized in that: include: In response to the control query request sent by the test script, obtain the first page structure tree of the current page of the test object; Traversing each control in the first page structure tree through a view control detection thread, for each traversed control, if the first control retrieval information of the corresponding control does not obtain a corresponding matching item after matching with a preset second control retrieval information set, then generating a corresponding view control detection result, the view control detection result indicating that the target view control does not exist in the first page structure tree; for each traversed control, if the first control retrieval information of the corresponding control obtains a corresponding matching item after matching with a preset second control retrieval information set, then generating a corresponding view control detection result, the view control detection result indicating that the control that obtains the matching item is the target view control, and closing the target view control based on the view control detection result; In parallel, the operation control detection thread is called to traverse the first page structure tree to obtain a target operation control; Before obtaining the view control detection result, if the operation control detection thread has completed the traversal and obtained the target operation control, the operation control detection thread is temporarily blocked; After the traversal of the view control detection thread is completed and the view control detection result is obtained, the operation control detection thread is re-awakened, and the drive information and drive event of the target operation control are sent to the control driving thread through the operation control detection thread, wherein the drive information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page, and the drive event is a behavior event triggered by the expected drive instruction for the target operation control, and the drive event is obtained based on the control query request sent by the test script; The control driving thread is called to encapsulate the driving information and the driving event to generate the driving instruction to perform a corresponding operation on the target operation control.
2. The method according to claim 1, characterized in that The second control retrieval information set includes at least one second control retrieval information, and the second control retrieval information is obtained in the following manner: Acquire a second page structure tree of a history page based on the history detection record, the history page including a history view control, the second page structure tree including a first control identifier of the history view control; Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier; Acquire a control title of the history view control and text information of the history view control according to the substructure tree; The first control identifier, the control title of the history view control, and the text information of the history view control are encapsulated as the second control retrieval information.
3. The method according to claim 1, characterized in that The target view control is any of the following: Pop-up windows, floating layers, prompt boxes, and bubble boxes.
4. The method according to claim 1, characterized in that The parallel calling operation control detection thread traverses the first page structure tree to obtain a target operation control, including: Traversing each control in the first page structure tree through the operation control detection thread; For each traversed control, if the first control retrieval information of the corresponding control matches the second control identifier, the control is determined as the target operation control; The second control identifier is obtained based on a control query request sent by a test script.
5. A detection device for a page view control, characterized in that: include: An acquisition unit, used to acquire a first page structure tree of a current page of a test object in response to a control query request sent by a test script; A detection unit, configured to traverse each control in the first page structure tree through a view control detection thread, and for each traversed control, if the first control retrieval information of the corresponding control does not obtain a corresponding matching item after matching with a preset second control retrieval information set, then generate a corresponding view control detection result, and the view control detection result indicates that the target view control does not exist in the first page structure tree; for each traversed control, if the first control retrieval information of the corresponding control obtains a corresponding matching item after matching with a preset second control retrieval information set, then generate a corresponding view control detection result, and the view control detection result indicates that the control that obtains the matching item is the target view control, and close the target view control based on the view control detection result; In parallel, the operation control detection thread is called to traverse the first page structure tree to obtain a target operation control; A processing unit, configured to temporarily block the operation control detection thread if the operation control detection thread has completed traversal and obtained the target operation control before obtaining the view control detection result; After the traversal of the view control detection thread is completed and the view control detection result is obtained, the operation control detection thread is re-awakened, and the drive information and drive event of the target operation control are sent to the control driving thread through the operation control detection thread, wherein the drive information includes the control identifier of the target operation control and / or the position coordinates of the target operation control in the current page, and the drive event is a behavior event triggered by the expected drive instruction for the target operation control, and the drive event is obtained based on the control query request sent by the test script; The control driving thread is called to encapsulate the driving information and the driving event to generate the driving instruction to perform a corresponding operation on the target operation control.
6. The device according to claim 5, characterized in that The second control retrieval information set includes at least one second control retrieval information, and the device further includes a generating unit, and the generating unit obtains the second control retrieval information in the following manner: Acquire a second page structure tree of a history page based on the history detection record, the history page including a history view control, the second page structure tree including a first control identifier of the history view control; Extracting a substructure tree of the history view control from the second page structure tree according to the first control identifier; Acquire a control title of the history view control and text information of the history view control according to the substructure tree; The first control identifier, the control title of the history view control, and the text information of the history view control are encapsulated as the second control retrieval information.
7. The device according to claim 5, characterized in that The target view control is any of the following: Pop-up windows, floating layers, prompt boxes, and bubble boxes.
8. The device according to claim 5, characterized in that The detection unit is used for: Traversing each control in the first page structure tree through the operation control detection thread; For each traversed control, if the first control retrieval information of the corresponding control matches the second control identifier, the control is determined as the target operation control; The second control identifier is obtained based on a control query request sent by a test script.
9. A computer device, characterized in that: It comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: It includes program codes. When the program product is run on a computer device, the program codes are used to make the computer device execute the steps of the method according to any one of claims 1 to 4.
