Automated test script generation method, device, computer equipment and storage medium

By establishing a component tree of user interface controls and generating automated test scripts, the problem of low test script development efficiency caused by frequent changes in UI controls is solved, and efficient script updates and maintenance are achieved.

CN117931652BActive Publication Date: 2024-09-10镁佳(北京)科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410063998.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-16
Publication Date
2024-09-10
Estimated Expiration
2044-01-16

AI Technical Summary

Technical Problem

Existing automated test script development methods require frequent modifications and updates when UI controls change, resulting in low development efficiency.

Method used

By establishing a component tree of user interface controls, encapsulating the hierarchical relationship and attribute information between controls, an automated test script is generated. The test script can be updated only by modifications in the component tree, avoiding script modifications to all controls.

Benefits of technology

It greatly improves the development efficiency of test scripts when UI controls change, reduces maintenance costs and complexity, and ensures the stability and reliability of scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117931652B
    Figure CN117931652B
Patent Text Reader

Abstract

The present application relates to the field of automated testing technology, and discloses an automated test script generation method, device, computer equipment, and storage medium, wherein the method comprises determining all user interface controls on the software to be tested and the hierarchical relationship between each user interface control; taking the main page of the software to be tested as the root node, and establishing a component tree of the software to be tested based on the user interface controls and the hierarchical relationship between each user interface control; generating an automated test script based on the component tree, and the automated test script is used to test the user interface function of the software to be tested. The hierarchical relationship between each user interface control in the software to be tested, the node identification of each user interface control, and the attribute information are encapsulated in the component tree, and when the user interface control changes, only the component tree needs to be modified without large-scale modification of the automated test script, which improves the development efficiency of the test script.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing technology, and in particular to an automated testing script generation method, apparatus, computer equipment and storage medium. Background Art

[0002] At present, most software will provide UI (User Interface) functions, which requires testing the software's UI functions to ensure that the software can be put into use. In order to improve the testing efficiency of software UI functions and reduce testing costs, software UI functions are often tested based on automated testing.

[0003] The current automated test script development method is usually to find the corresponding UI control and all upper-level controls of the UI control based on the test steps in the test case, encode the UI control and all upper-level controls one by one to finally obtain the test script, and test the software based on the test script. However, with the enrichment of software functions and changes in requirements, UI controls will change frequently. The current method requires automated test engineers to constantly modify, update and debug the test scripts of all controls involved in the changes, which greatly reduces the development efficiency of test scripts.

[0004] Therefore, how to improve the development efficiency of test scripts when UI controls change has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] In view of this, the present application provides an automated test script generation method, apparatus, computer device and storage medium to solve the problem of how to improve the development efficiency of test scripts when the properties of UI controls change.

[0006] In a first aspect, the present application provides a method for generating an automated test script, the method comprising:

[0007] Determine all user interface controls on the software under test and the hierarchical relationship between each user interface control;

[0008] Taking the main page of the software to be tested as the root node, based on the user interface controls and the hierarchical relationship between the user interface controls, a component tree of the software to be tested is established, wherein each node in the component tree corresponds to a node identifier and attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls;

[0009] Generate automated test scripts based on the component tree, and the automated test scripts are used to test the user interface functions of the software under test.

[0010] In the above technical scheme, each node in the component tree of the software to be tested corresponds to a user interface control of the software to be tested, so that the hierarchical relationship between the user interface controls in the software to be tested, the node identification of each user interface control, the attribute information and other related information are encapsulated in the component tree, and then the automated test script can be quickly generated based on the information encapsulated in the component tree. When the attribute information of the user interface control changes, it is only necessary to modify the component tree encapsulating the information. The modification of the automated test script generated based on the component tree can be done without modification or with a small amount of modification. There is no need to modify the test scripts of all the controls involved in the changes as in the traditional method, which greatly improves the development efficiency of the test script when the UI controls change.

[0011] In some optional embodiments, taking the main page of the software to be tested as the root node, based on the user interface controls and the hierarchical relationship between the user interface controls, a component tree of the software to be tested is established, including:

[0012] With the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node, perform the following steps:

[0013] Traverse each control on the current page and obtain the property information of each control on the current page;

[0014] Add subnodes corresponding to the various controls on the current page under the current node, and the newly added subnodes have corresponding node identifiers;

[0015] Bind the property information of each control on the current page to its corresponding child node;

[0016] Trigger each control on the current page according to the preset trigger operation set;

[0017] If there is a control that can be triggered, the page after the triggering is determined as the next level page of the current page, and the control of the next level page is determined;

[0018] The node corresponding to the control of the next-level page obtained after being triggered in the current page is taken as the current node, the next-level page is taken as the current page, and the control of the next-level page is taken as the control of the current page, and the step of traversing each control of the current page and obtaining the attribute information of each control of the current page is returned;

[0019] If there is no control that can be triggered, the current component tree is the component tree of the software under test.

[0020] In the above technical scheme, starting from the main page, the various controls of the current page are traversed to add subnodes corresponding to the various controls of the current page under the current node, and bind the attribute information of each control to the subnode, and then trigger the various controls of the current page to obtain the page after each control is triggered by dynamic triggering, and obtain the next level page of the current page, so as to re-determine the current node and the current page in the component tree, so as to update the nodes in the component tree. In the process of building the component tree, it is realized that the controls are triggered dynamically one by one from the main page of the software to be tested to find the upper and lower controls of all controls, so as to ensure that the hierarchical structure between nodes in the final component tree is highly consistent with the hierarchical structure between user interface controls in each page of the software to be tested, and the reliability of the component tree is ensured.

[0021] In some optional embodiments, each node in the component tree of the software to be tested also corresponds to an activation condition of a user interface control. After the node corresponding to the control of the next-level page is triggered in the current page, it is used as the current node, the next-level page is used as the current page, and the control of the next-level page is used as the control of the current page. Before returning to execute the step of traversing each control of the current page and obtaining the attribute information of each control of the current page, the method further includes:

[0022] In the current component tree, the activation condition of the control that cannot be triggered is determined as being unable to be activated, and the determined activation condition is bound to the node corresponding to the control that cannot be triggered;

[0023] For a control that can be triggered, determining whether the number of triggering operations that trigger the control that can be triggered is equal to one;

[0024] If the number is equal to one, the triggering operation of the control that can be triggered is bound to the node corresponding to the control that can be triggered as the activation condition;

[0025] If the number is greater than one, then compare whether the user interface controls in each page after the control that can be triggered is the same;

[0026] If there are at least two pages with the same user interface controls, the trigger operation of the control that can be triggered first among the trigger operations corresponding to the at least two pages is bound as an activation condition to the node corresponding to the control that can be triggered;

[0027] If there are at least two pages with different user interface controls, the nodes corresponding to the controls that can be triggered are copied, and the triggering operations corresponding to the at least two pages are respectively bound to the nodes corresponding to the controls that can be triggered as activation conditions.

[0028] In the above technical scheme, the triggering operation that can trigger the corresponding control of each node is recorded in the current component tree, and when recording, for the controls with the same user interface controls in the page after triggering, the triggering operation that first triggers the control in the triggering operations corresponding to each page after triggering is bound to the node corresponding to the control as the activation condition, and for the controls with different user interface controls in the page after triggering, the node corresponding to the control in the current component tree is first copied, and then the triggering operations corresponding to each page after triggering are respectively bound to each node corresponding to the control, so as to realize the branch recording of the response results of the user interface control to different triggering operations in the component tree. The specific triggering operation flow between the main page corresponding to the root node and the user interface control corresponding to a certain node is recorded in the component tree, so that when the UI control changes, the user does not need to worry about the specific implementation process from the main page of the software to be tested to the user interface control to be tested to write the automated test script, which reduces the difficulty of the first automated test script development and improves the development efficiency of the automated test script.

[0029] In some optional embodiments, the method further comprises:

[0030] Take any child node under the root node in the component tree of the software to be tested as the current node to be tested, and perform the following steps until all nodes in the component tree of the software to be tested are traversed or it is determined that the self-test fails:

[0031] Determine the current page to be tested corresponding to the current node to be tested in the software to be tested;

[0032] Get the property information of all user interface controls in the current page to be inspected;

[0033] Find the attribute information bound to the current node to be inspected from all the acquired attribute information;

[0034] If the attribute information bound to the current node to be inspected is found, the next node of the current node to be inspected is determined as the current node to be inspected, and the process returns to the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested;

[0035] If the attribute information bound to the current node to be tested is not found, the self-test result of the component tree of the software to be tested is determined to be a self-test failure, and the self-test result is sent to a preset user terminal.

[0036] In the above technical scheme, it is automatically monitored whether the attribute information of the user interface control corresponding to each node in the component tree of the software to be tested is consistent with the attribute information of the corresponding user interface control in the software to be tested, so as to find the user interface control that has changed in the software to be tested but has not undergone corresponding changes in the component tree, and send the self-check result to the preset user terminal to facilitate the user who uses the preset user terminal to update the component tree. In this way, the purpose of automatically checking the component tree can be achieved, the reliability of the component tree can be improved to improve the reliability of subsequent automated test scripts, and changes in UI controls can be discovered in advance, reducing the test failure caused by changes in UI controls but failure to update the component tree in time and the need for manual troubleshooting of the test script and the component tree, thereby improving the development efficiency of automated test scripts when UI controls change.

[0037] In some optional embodiments, before determining the next node of the current node to be inspected as the current node to be inspected and returning to the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested, the method includes:

[0038] Determine whether there is a user interface control whose attribute information is not bound in the current page to be checked;

[0039] If there are unbound user interface controls, add a node at the same level as the current node to be tested in the component tree of the software to be tested;

[0040] Bind the property information of unbound controls to the newly added nodes.

[0041] In the above technical solution, when there are user interface controls whose attribute information is not bound in the current page to be tested, a node at the same level as the current node to be tested is added to the component tree of the software to be tested, and the attribute information of the unbound control is bound to the newly added node, so as to realize automatic updating of the component tree, reduce manual maintenance of the component tree, and reduce the maintenance cost of the component tree.

[0042] In some optional embodiments, after generating the automated test script based on the component tree, the method further includes:

[0043] An operation of modifying the property information of a target user interface control in an automated test script is received, and the property information bound to a node corresponding to the target user interface control in a component tree of the software to be tested is modified.

[0044] In the above technical solution, a user's modification operation on the attribute information of a target user interface control involved in the automated test script is received, and the attribute information bound to the corresponding node of the target user page control in the component tree is modified while modifying the attribute information of the target user interface control. When the attribute of the user interface control involved in the automated test script changes, it is only necessary to modify the attribute information bound to the corresponding node in the component tree to complete the update of the automated test script, without modifying the test code in the automated test script, and even more without modifying the test scripts of all the user interface controls involved in the change, thereby reducing the maintenance cost of the automated test script and greatly improving the development efficiency of the test script when the UI control changes.

[0045] In some optional embodiments, the automated test script includes a node identifier corresponding to the user interface control to be tested and a test operation on the user interface control to be tested. After the automated test script is generated based on the component tree, the method further includes:

[0046] Starting from the root node in the component tree of the software to be tested, searching for a target node whose node identifier is bound to the node identifier corresponding to the user interface control to be tested, and obtaining a path from the root node to the target node;

[0047] Based on the activation conditions and attribute information corresponding to each node in the path, the corresponding user page controls in each page of the software to be tested are triggered to reach the user interface controls to be tested from the main page;

[0048] Based on the test operation on the user interface control to be tested, the user interface control to be tested is tested.

[0049] In the above technical scheme, based on the node identification of the user interface control to be tested included in the automated test script, the path from the main page to the user interface control to be tested can be automatically found from the component tree, and based on the node identification, activation conditions and attribute information bound to the nodes in the path, the corresponding user page controls in each page of the software to be tested are triggered to automatically navigate to the user interface control to be tested, thereby testing the user interface control to be tested based on the test operation, achieving the purpose of automatically navigating to the user interface control to be tested based on the component tree without having to worry about the intermediate implementation process, and improving the stability of the automated test script. For the test script writer, not having to worry about the intermediate implementation process greatly reduces the complexity of automated test script writing and improves the efficiency of automated test script development.

[0050] In a second aspect, the present application provides an automated test script generation device, the device comprising:

[0051] A determination module, used to determine all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls;

[0052] An establishment module is used to establish a component tree of the software to be tested, taking the main page of the software to be tested as the root node, based on the user interface controls and the hierarchical relationship between the user interface controls, wherein each node in the component tree corresponds to a node identifier and attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls;

[0053] The generation module is used to generate an automated test script based on the component tree, and the automated test script is used to test the user interface function of the software under test.

[0054] In a third aspect, the present application provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the automated test script generation method of any embodiment of the first aspect above by executing the computer instructions.

[0055] In a fourth aspect, the present application provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the automated test script generation method of any embodiment of the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0057] Figure 1 It is a framework diagram of the traditional automated test script development method;

[0058] Figure 2 It is a flowchart of a method for generating an automated test script according to an embodiment of the present application;

[0059] Figure 3 is a schematic diagram of a first page involved in a method for generating an automated test script in an application scenario of an embodiment of the present application;

[0060] Figure 4 is a flowchart of another method for generating an automated test script according to an embodiment of the present application;

[0061] Figure 5 It is a schematic diagram of a framework of an automated test script development method in an application scenario of an embodiment of the present application;

[0062] Figure 6is a flowchart of another method for generating an automated test script according to an embodiment of the present application;

[0063] Figure 7 is a structural block diagram of an automated test script generation device according to an embodiment of the present application;

[0064] Figure 8 It is a schematic diagram of the hardware structure of the computer device of an embodiment of the present application. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.

[0066] The framework of traditional automated test script development method is as follows Figure 1 As shown, the test script needs to be written according to the test steps in the test case. Specifically, for the target UI controls involved in each test step, the hierarchical structure between the UI controls in the software to be tested should be combined. From the Home interface (i.e. the main page), all controls in the process of reaching the target UI control should be programmed one by one and written directly in the script, such as Figure 1 The test case shown includes n test steps from step 1 to step n, where step 1 is to slide control 5 and then double-click control 2 under control 5, where the target UI control is control 2. Combined with the hierarchical structure of UI controls of the software to be tested, the path from the Home interface to control 2 is to slide control 3 from the Home interface, reach control 5 after sliding, and then slide control 5 to reach control 2. The final test code is as follows:

[0067] (1) Click Home

[0068] (2), sliding control 3.

[0069] (3), sliding control 5.

[0070] (4) Double-click control 2. For other test steps, follow the same procedure as step 1 to find all controls or sub-controls that will reach the target UI control from the Home interface (i.e., the main page) to write test code to obtain an automated test script, i.e. Figure 1This means that when any UI control or its properties, such as resourceid (unique identifier of service resources), name and / or description, changes, all test scripts using the UI control need to be modified. This increases the waste of manpower costs, the complexity of automated testing, and reduces the efficiency of developing automated test scripts when UI controls change.

[0071] The present application provides an automated test script generation method for the above-mentioned problems. By encapsulating the hierarchical relationship between all UI controls on the software to be tested, the node identification of each UI control, and the attribute information and other related information in the component tree, the component tree records the route from the main page of the software to be tested to a certain UI control, and generates an automated test script based on the component tree, the traditional UI control-oriented programming method is changed to a component road tree-oriented programming method. In the process of writing scripts, there is no need to pay attention to the hierarchical structure between UI controls and the attribute information of specific UI controls. When the UI controls change, only the component tree needs to be modified without modifying the automated test script on a large scale, which greatly improves the development speed and script stability of the automated test script. The automated test script generation method of the present application is described in detail below.

[0072] According to an embodiment of the present application, an embodiment of an automated test script generation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0073] In an embodiment of the present application, a method for generating an automated test script is provided, which can be used in a computer device, such as a laptop computer, a desktop computer, or a tablet computer, Figure 2 is a flow chart of a method for generating an automated test script according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:

[0074] Step S201, determining all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls.

[0075] Starting from the main page of the software to be tested, trigger operations can be performed on each user interface control in the current page, and the attribute information of each triggered user interface control can be read until no user interface control can be triggered, so that all user interface controls on the software to be tested and the hierarchical relationship between each user interface control can be determined. Among them, the executed trigger operations include single-click, double-click, swipe up, swipe down and swipe left, etc., and the attribute information of the user interface control includes the resourceid of the user interface control, the name of the user interface control, the description of the user interface control and the operation attribute of the user interface control (that is, the trigger operation that the user interface control can respond to).

[0076] Step S202 , taking the main page of the software to be tested as a root node, and based on the user interface controls and the hierarchical relationship between the user interface controls, a component tree of the software to be tested is established.

[0077] Among them, each node in the component tree corresponds to a node identifier and the attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls. The node identifier is the identity identification number (id) of the node. The computer device takes the main page of the software to be tested as the root node, and starts from the root node to dump (dump) the UI control of the current page through the dump command. During the dump process, the computer device can obtain the attribute information of the UI control, and create all the dumped UI controls as UI components, that is, bind the attribute information of the dumped UI controls to the child node with the node identifier under the current node, and obtain the first-level leaf component (that is, the first-level leaf node).

[0078] Then traverse the first layer of leaf components, and perform trigger operations on the UI controls corresponding to each component in the first layer of leaf components. After each trigger operation, create UI components in the above-mentioned way to obtain the first leaf component, and add activation conditions for the first layer of leaf nodes. The specific process is introduced in the subsequent embodiments. For example, first click the UI control a corresponding to component a in the first layer of leaf components, dump the UI controls of the current page, and obtain the second layer of leaf components a-1, a-2 and a-3; then double-click UI control a. If the dumped UI control is inconsistent with the single-click UI control a, copy component a to component A (that is, copy the node corresponding to UI control a, and assign a new node identifier to the copied node), and add the activation condition of component A as "double-click", and add the second layer of leaf components A-1, A-2 and A-3; if the dump result is the same as the result after single-clicking UI control a, ignore this operation. Continue to traverse the second layer of leaf components to obtain the third layer of leaf components, and repeat this until the UI control after dumping does not change after the trigger operation is performed on the UI control corresponding to the leaf component, and obtain a component tree of the software to be tested formed from the root node.

[0079] In the process of creating the component tree, each node is assigned a corresponding activation condition (single click, double click, slide up, slide down, etc.) to indicate the trigger operation that the corresponding user interface control of each node can respond to. The specific process is introduced in the subsequent embodiments. Through the activation conditions corresponding to each node, the path from the main page of the software to be tested to a certain user interface control can be shielded in the subsequent automated test script, which can simplify the automated test script.

[0080] Step S203: Generate an automated test script based on the component tree.

[0081] Among them, the automated test script is used to test the user interface function of the software to be tested. In response to the user's display operation on the target page in the software to be tested, the target page, all user interface controls in the target page, and the component tree of the software to be tested are displayed in the first page; in response to the user's selection instruction for the target user interface control in the target page in the first page, the node bound with the attribute information of the target user interface control is searched from the root node in the component tree, and the node is identified in the first page, and the target user interface control is identified in the target page of the first page and each test operation option corresponding to the target user interface control is displayed; in response to the user's selection instruction for the target test operation option in each operation option, a test code for indicating the target test operation option is generated in the first page, and the target node whose corresponding activation condition is the target test operation option is searched in the node bound with the attribute information of the target user interface control, and the node identifier of the target node is added to the test code, and all the test codes constitute an automated test script. The activation condition corresponding to each node in the component tree is used to indicate the trigger operation that the corresponding user interface control of each node can respond to.

[0082] It should be noted that the specific implementation method of the computer device displaying the target page in the software to be tested and all the user interface controls in the target page is not specifically limited in the embodiment of the present application. It can be dumping and displaying related content in response to the user's dump command for the target page, or it can be dumping each page of the software to be tested and the user interface controls in each page in advance, and displaying related content in response to the user's selection instruction for the target page. The specific method of identifying the node bound to the attribute information of the target user interface control in the first page is not specifically limited in the embodiment of the present application, and it can be highlighted, bolded, or represented by a preset color. When responding to the user's selection instruction for the target user interface control in the target page in the first page, the target user interface control can also be identified on the target page. The specific identification method is not specifically limited in the embodiment of the present application, and it can be highlighted, bolded, or represented by a preset color.

[0083] In one application scenario, the first page displays content such as Figure 3As shown, the test step in a test case is to slide the sub-control 4 and then double-click the light control under the sub-control 4. Based on the test step, the user determines that the target user interface control of the final test is the light control. The computer device Figure 3 The first page shown displays the target page where the lighting control is located and all user interface controls on the target page. In addition to the lighting control, the target page also includes user interface controls such as return, headlights, comfort cabin, and energy management. Figure 3 The display content on the left side of the first page is the component tree. The root node of the component tree is Display0. The root node includes Launcher and multimedia nodes corresponding to certain user interface controls (not shown in the figure). The node corresponding to the light control is under the node located in the center of the vehicle under the root node and is marked in red, indicating that the user is in Figure 3 The target page of the first page shown has a light control selected (the control is marked with a green box after being selected in the target page, and the display color of the control is blue). After the user selects the light control, various operation options including double-clicking pop up. Since the user interface controls on each page of the software to be tested correspond one-to-one to the nodes on the component tree, when the user clicks the light control and double-clicks in each operation option, it will be automatically mapped to the corresponding node, generating the test code "Double-click component ("light", "1705382685858")" with the corresponding node id (that is, node identifier).

[0084] In an embodiment of the present application, each node in the component tree of the software to be tested corresponds to a user interface control of the software to be tested, so that the hierarchical relationship between each user interface control in the software to be tested, the node identification of each user interface control, and the attribute information and other related information are encapsulated in the component tree. Then, an automated test script can be quickly generated based on the information encapsulated in the component tree. When the attribute information of the user interface control changes, it is only necessary to modify the component tree encapsulating the information. The modification of the automated test script generated based on the component tree can be done without modification or with a small amount of modification. There is no need to modify the test scripts of all controls involved in the changes as in traditional methods, which greatly improves the development efficiency of the test script when the UI controls change.

[0085] In an embodiment of the present application, another method for generating an automated test script is provided, which can be used for a computer device, such as a laptop computer, a desktop computer or a tablet computer, Figure 4 is a flowchart of another method for generating an automated test script according to an embodiment of the present application. Figure 4 As shown, the process includes the following steps:

[0086] Step S401: determine all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls.

[0087] Step S402 , taking the main page of the software to be tested as the root node, and based on the user interface controls and the hierarchical relationship between the user interface controls, a component tree of the software to be tested is established.

[0088] For details of steps S401 to S402, see Figure 2 Steps S201 to S202 of the illustrated embodiment are not described in detail here.

[0089] Optionally, in order to ensure the reliability of the component tree, the above step S402 may include the following steps S4021 to S4027:

[0090] Step S4021, taking the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node, perform the following steps:

[0091] Traverse each control on the current page and obtain the property information of each control on the current page.

[0092] The computer device can dump the current page and each control in the current page based on the dump command, and then obtain the property information of each control.

[0093] Step S4022: Add subnodes corresponding to the various controls on the current page under the current node.

[0094] The newly added sub-node has a corresponding node identifier. The computer device creates several sub-nodes with unique node identifiers under the current node, and assigns the sub-nodes with different node identifiers to different controls in the current page.

[0095] Step S4023, binding the attribute information of each control of the current page to its corresponding child node.

[0096] For each control on the current page, the property information of the control will be bound to its corresponding child node.

[0097] Step S4024, triggering each control of the current page according to a preset trigger operation set.

[0098] The preset trigger operation set includes multiple trigger operations such as single click, double click, swipe up, swipe down, and swipe left. Traverse the child nodes bound to the current node, and for the traversed current child node, perform each trigger operation in the preset trigger operation set on the control corresponding to the current child node to determine whether the control corresponding to the current child node can respond to at least one trigger operation to update the current page, so as to determine whether there is a control that can be triggered among the controls on the current page.

[0099] Step S4025: If there is a control that can be triggered, the page after the triggering is determined as the next level page of the current page, and the control of the next level page is determined.

[0100] For the current child node traversed, if the control corresponding to the current child node can only respond to one trigger operation, the page after the control is triggered is determined as the next level page of the current child node in the current page, and the user interface controls in the page after triggering whose attribute information is different from the controls in the current page are determined as the controls of the next level page.

[0101] If the control corresponding to the current child node can respond to multiple trigger operations, then compare whether the user interface controls in the page after the control is triggered by each trigger operation are the same; if there are at least two pages with the same user interface controls, then determine any one of the same pages as the next-level page of the current child node in the current page, and determine the user interface controls in the next-level page whose attribute information is different from that of the controls in the current page as the controls in the next-level page; if there are at least two pages with different user interface controls, copy the current child node and modify the node identifier of the copied child node, determine one of the at least two pages with different user interface controls as the next-level page of the current child node in the current page, and determine the other pages of the at least two pages with different user interface controls as the next-level pages of the copied current child nodes in the current page; for each next-level page, determine the user interface controls in the next-level page with different attribute information from that of the controls in the current page as the controls in the next-level page.

[0102] It should be noted that if the control corresponding to the current child node fails to respond to each trigger operation in the preset trigger operation set, the next child node at the same level as the current child node (that is, at the same level as the current child node) in the current component tree will be determined as the current child node, and the steps of executing each trigger operation in the preset trigger operation set on the control corresponding to the current child node will be returned until all child nodes at the same level as the current child node in the current component tree have been traversed. In this way, the child nodes under the current node in the current component tree can be determined in the next level page of the current page.

[0103] Optionally, in order to improve the development efficiency of automated test scripts, each node in the component tree of the software to be tested also corresponds to an activation condition of a user interface control, so that the operations required for each user page control in the software to be tested to be transferred to its subordinate user page control, that is, the trigger operation that each user interface control can respond to, can be recorded in the component tree of the software to be tested, so that when developing automated test scripts, the user does not need to care about the specific implementation process from the main page of the software to be tested to the user interface control to be tested in each test step. Instead, the node identifier of the node corresponding to the user interface control to be tested can be recorded in the test code, and the user page control to be tested can be automatically navigated to in the component tree of the software to be tested according to the node identifier and the activation conditions of each node, which can improve the development efficiency of automated test scripts. Moreover, when the UI control changes, the trigger operation of the UI control can be updated by modifying the relevant information of each node in the component tree, without modifying the test code on a large scale, which improves the development efficiency of automated test scripts when the UI control changes. Before step S4026, the method can also include the following steps A1 to A6 to obtain a component tree with activation conditions corresponding to the node:

[0104] Step A1: in the current component tree, the activation condition of the control that cannot be triggered is determined as being unable to be activated, and the determined activation condition is bound to the node corresponding to the control that cannot be triggered.

[0105] When traversing the child nodes bound to the attribute information under the current node, for the traversed current child node, if the control corresponding to the current child node is a control that cannot be triggered, the activation condition of the control is determined to be unable to be activated, and the determined activation condition is bound to the current child node.

[0106] Step A2: for a control that can be triggered, determine whether the number of triggering operations that trigger the control that can be triggered is equal to one.

[0107] If the control corresponding to the current child node is a control that can be triggered, it is determined whether the number of trigger operations that the control responds to in the preset trigger operation set is equal to one.

[0108] Step A3: if the number is equal to one, the triggering operation of the control that can be triggered is bound to the node corresponding to the control that can be triggered as an activation condition.

[0109] If the number is equal to one, the trigger operation that can be responded to by the corresponding control of the current child node is bound to the current child node as the activation condition. It can be understood that at this time, the next level page of the current child node in the current page is the page after the corresponding control of the previous child node is triggered.

[0110] Step A4: if the number is greater than one, then compare whether the user interface controls in each page after the control that can be triggered is the same.

[0111] If the number is greater than one, it is compared whether the user interface controls in the page after the corresponding controls of the current child node respond to different trigger operations are the same.

[0112] Step A5: if there are at least two pages with the same user interface controls, the trigger operation of the at least two pages that first triggers the control that can be triggered is bound to the node corresponding to the control that can be triggered as an activation condition.

[0113] If there are at least two pages with the same user interface controls, the trigger operation that is first responded to by the control corresponding to the current child node among the trigger operations corresponding to the at least two pages is bound to the current child node as an activation condition. It can be understood that at this time, the next level page of the current child node in the current page is any one of the at least two pages.

[0114] Step A6: if there are at least two pages with different user interface controls, copy the nodes corresponding to the controls that can be triggered, and bind the triggering operations corresponding to the at least two pages as activation conditions to the nodes corresponding to the controls that can be triggered.

[0115] If there are at least two pages with different user interface controls, the current child node is copied and the node identifier of the copied child node is modified, and the trigger operations corresponding to at least two pages are bound to the current child node and the copied child node as activation conditions. It can be understood that at this time, the next level page of the current child node in the current page is the page corresponding to the bound activation condition, and the next level page of the copied child node in the current page is also the page corresponding to the respective bound activation conditions. The number of copied child nodes plus one is consistent with the number of trigger operations that the corresponding control of the current child node can respond to.

[0116] Optionally, you can also set a certain trigger operation in the preset default trigger operation set, such as single-click, as the default activation condition. When traversing the child nodes with bound attribute information under the current node, bind each traversed child node to the default activation condition. If the corresponding trigger operation of the current traversed child node on the next level page of the current page is inconsistent with the default activation condition, the default activation condition will be modified to the corresponding trigger operation of the next level page.

[0117] In one example, taking the Home interface of the node activation code indicating the activation condition, the user interface control being an Android (Android) control and the main page being the software to be tested as an example, the default activation condition of the user interface control can be set to a single click. When the activation condition of the user interface control is not a single click (i.e., the triggering operation that the user page control can respond to is not a single click), the activation condition is added to the node activation code corresponding to the user interface control (i.e., the default activation condition is modified to the activation condition). Therefore, the node activation code is also what triggering operation should be done when encountering the corresponding user interface control of the node, so as to encounter the action set of the next level user interface control of the corresponding user interface control of the node. The node with the node activation code in this example is called a component router. Through the component router, the implementation path from the Home interface to the target Android control can be shielded in the subsequent generated automated test script, and the target Android control can be automatically reached based on the hierarchical structure between each node in the component tree of the software to be tested and the node activation code of each node when performing UI testing.

[0118] The triggering operation that can trigger the corresponding control of each node is recorded in the current component tree, and when recording, for the controls with the same user interface controls in the page after triggering, the triggering operation of the first triggering control in the triggering operations corresponding to each page after triggering is bound to the node corresponding to the control as the activation condition. For the controls with different user interface controls in the page after triggering, the node corresponding to the control in the current component tree is first copied, and then the triggering operations corresponding to each page after triggering are respectively bound to the nodes corresponding to the control, so as to realize the branch recording of the response results of the user interface control to different triggering operations in the component tree. The component tree records the specific triggering operation process between the main page corresponding to the root node and the user interface control corresponding to a certain node, so that when the UI control changes, the user does not need to worry about the specific implementation process from the main page of the software to be tested to the user interface control to be tested to write the automated test script, which reduces the difficulty of the first automated test script development and improves the development efficiency of the automated test script.

[0119] Step S4026, take the node corresponding to the control of the next level page obtained after being triggered in the current page as the current node, take the next level page as the current page, and the control of the next level page as the control of the current page, and return to execute the step of traversing each control of the current page and obtaining the attribute information of each control of the current page.

[0120] For the current child node traversed, if the control corresponding to the current child node is a control that can be triggered, the current child node is used as the current node, the next level page of the current child node is used as the current page, and the control of the next level page is used as the control of the current page to return to execute step S4021.

[0121] Step S4027: If there is no control that can be triggered, the current component tree is the component tree of the software to be tested.

[0122] When traversing each child node with bound attribute information under the current node, if for each traversed current child node, the corresponding control of the current child node fails to respond to each trigger operation in the preset trigger operation set, and there is no child node that has not been traversed under the current node, then it is determined that all trigger operations in the preset trigger operation set cannot trigger the various controls of the current page, which means that the current page is already the bottom-level page among the pages of the software to be tested, then it is determined that the current component tree is the component tree of the software to be tested.

[0123] Starting from the main page, traverse the various controls of the current page to add subnodes corresponding to the various controls of the current page under the current node, bind the attribute information of each control to the subnode, and then trigger the various controls of the current page to obtain the page after each control is triggered through dynamic triggering, and obtain the next level page of the current page to reproduce the current node and the current page in the component tree to update the nodes in the component tree. In the process of building the component tree, it is realized to dynamically trigger the controls one by one from the main page of the software to be tested to find the upper and lower controls of all controls, ensuring that the hierarchical structure between nodes in the final component tree is highly consistent with the hierarchical structure between user interface controls in each page of the software to be tested, and ensuring the reliability of the component tree.

[0124] Step S403: Generate an automated test script based on the component tree.

[0125] Step S403 is described in detail in Figure 2 Step S203 of the illustrated embodiment is not described in detail here.

[0126] Step S404 , starting from the root node in the component tree of the software to be tested, searching for a target node whose node identifier is bound to the node identifier of the user interface control to be tested, and obtaining a path from the root node to the searched target node.

[0127] Among them, the automated test script includes the node identification corresponding to the user interface control to be tested and the test operation of the user interface control to be tested. When testing the UI function of the software to be tested based on the automated test script, the node identification of the node corresponding to the user interface control to be tested in the automated test script can be read for the test operation of the user interface control to be tested, and the target node bound to the node identification can be searched downward from the root node in the component tree of the software to be tested, so that the path between the root node and the searched target node in the component tree of the software to be tested is obtained, and the path is the path from the main page to the user interface control to be tested in the software to be tested.

[0128] Step S405 , based on the activation conditions and attribute information corresponding to each node in the path, trigger the corresponding user page controls in each page of the software to be tested, so as to reach the user interface control to be tested from the main page.

[0129] Search the software under test for user interface controls whose attribute information is the same as the attribute information corresponding to each node in the path, and execute the trigger operation indicated by the activation condition corresponding to the node on the found user interface control. In this way, the user interface control under test can be reached from the main page of the software under test.

[0130] Step S406: testing the user interface control to be tested based on the test operation on the user interface control to be tested.

[0131] Then, a test operation is performed on the user page control to test the user interface control to be tested, thereby completing the test of the UI function of the software to be tested.

[0132] Based on the node identification of the user interface control to be tested included in the automated test script, the path from the main page to the user interface control to be tested can be automatically found from the component tree, and based on the node identification, activation conditions and attribute information bound to the nodes in the path, the corresponding user page controls in each page of the software to be tested are triggered to automatically navigate to the user interface control to be tested, thereby testing the user interface control to be tested based on the test operation, achieving the purpose of automatically navigating to the user interface control to be tested based on the component tree without having to worry about the intermediate implementation process, and improving the stability of the automated test script. For the test script writer, not having to worry about the intermediate implementation process greatly reduces the complexity of automated test script writing and improves the efficiency of automated test script development.

[0133] Optionally, the method further includes receiving a modification operation on the property information of the target user interface control in the automated test script, and modifying the property information bound to the node corresponding to the target user interface control in the component tree of the software to be tested.

[0134] Receive the user's modification operation on the property information of a target user interface control involved in the automated test script, and modify the property information bound to the corresponding node of the target user page control in the component tree while modifying the property information of the target user interface control. When the property of the user interface control involved in the automated test script changes, it is only necessary to modify the property information bound to the corresponding node in the component tree to complete the update of the automated test script, without modifying the test code in the automated test script, and even more without modifying the test scripts of all the user interface controls involved in the change, thereby reducing the maintenance cost of the automated test script and greatly improving the development efficiency of the test script when the UI control changes.

[0135] In another application scenario, combined with Figure 1 ,like Figure 5 As shown, the controls and sub-controls shown in the figure indicate user interface controls in a software under test. The main page of the software under test includes control 1 and control 2. The subordinate controls of control 1 are sub-control 1 and sub-control 2, and the subordinate controls of control 2 are sub-control 3 and sub-control 4. Take the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node to start executing the following steps:

[0136] Get the property information of control 1 and control 2 in the current page, that is, the main page. Add two child nodes under the root node, that is, the current node, to bind the property information of control 1 and control 2 respectively. Figure 5 Component 1 and Component 2 in the component tree shown in the figure are Figure 5 The root node is not shown in the component tree in ). Then traverse the two child nodes under the root node, and assume that the current child node traversed corresponds to control 1, and control 1 can only respond to a single click. The page after the response includes sub-control 1 and sub-control 2. Then the next level page of the node corresponding to control 1 in the main page is the page after the response. The child node corresponding to control 1 is determined as the current node, and the next level page is determined as the current page. The attribute information of sub-control 1 and sub-control 2 in the current page is obtained, and two child nodes are added under the current node to bind the attribute information of sub-control 1 and sub-control 2 respectively, and the following is obtained. Figure 5 Subcomponent 1 and subcomponent 2 in the component tree shown. Then traverse the two subnodes under the current node. The subcontrol 1 and subcontrol 2 corresponding to these two subnodes cannot be triggered. However, there is still a node that has not been traversed in the current component tree (that is, the node corresponding to control 2). Then execute the same process for this node, and finally get the following Figure 5 Subcomponent 3 and subcomponent 4 in the component tree are shown. In this way, the component tree of the software under test is obtained, and the activation condition of component 1 and component 2 in the component tree is single click, so the node with activation condition is obtained, that is, Figure 5 Component routing as shown in .

[0137] Based on each test step 1 to n in the test case, the target control of each test step and the test operation on the target control can be analyzed. By selecting the relevant control in the first page, the test code with the node identifier of the node corresponding to the target control can be generated to obtain an automated test script, that is, Figure 5 A test script having node identifiers for indicating component routes 1 and 2, etc., is generated for each test step.

[0138] Compared to Figure 1The traditional automated script testing method shown in the automated test script generation method in the embodiment of the present application can change the traditional UI control-oriented programming method to a component router-oriented programming method to improve the efficiency and accuracy of cockpit software testing while reducing labor costs. The UI control is constructed as a component tree to form a component router. In the process of writing scripts, there is no need to pay attention to the hierarchical structure between UI controls and the specific attribute information of UI controls. You only need to automatically navigate to the target UI control through the component number, so the development speed and script stability of the automated test script are significantly improved.

[0139] In the embodiment of the present application, in the process of building the component tree, the controls are triggered one by one dynamically from the main page of the software to be tested to find the upper and lower controls of all controls, ensuring that the hierarchical structure between nodes in the final component tree is highly consistent with the hierarchical structure between the user interface controls in each page of the software to be tested, and at the same time, the trigger operation that can trigger the corresponding control of each node is recorded in the component tree in the form of activation conditions, so that when the UI control changes, the user does not need to care about the specific implementation process from the main page of the software to be tested to the user interface control to be tested to write the automated test script, thereby improving the development efficiency of the automated test script. In the case of changes in the UI control, modifying the component tree does not require large-scale modification of the developed automated test script, reducing the maintenance cost of the automated test script and improving the development cost of the automated test script. When testing the user interface function of the software to be tested, the node identifier corresponding to the user interface control to be tested recorded in the automated test script is automatically navigated to the user interface control to be tested based on the component tree for testing, without the need to implement the specific process between the main page and the user interface control to be tested in the automated test script, which greatly improves the stability of the automated test script.

[0140] In order to further speed up the development efficiency of automated test scripts when UI controls change, you can also check the created component tree to find the changed UI controls and update the component tree. In this way, you can apply automated test scripts based on the updated component tree, reducing the test failure caused by changes in UI controls but the component tree is not updated in time, and the need for manual troubleshooting of test scripts and component trees. For example, Figure 6 As shown, Figure 6 This is a flowchart of another method for generating an automated test script according to an embodiment of the present application. The method can be used in a computer device, such as a laptop computer, a desktop computer, or a tablet computer. The process includes the following steps:

[0141] Step S601, taking any child node under the root node in the component tree of the software to be tested as the current node to be tested, the following steps are performed until all nodes in the component tree of the software to be tested are traversed or it is determined that the self-test fails:

[0142] Determine the current page to be tested corresponding to the current node to be tested in the software to be tested.

[0143] The current page to be tested corresponding to the current node to be tested in the software to be tested is determined based on the number of levels of the current node to be tested from the root node in the component tree. For example, if the number of levels of the current node to be tested from the root node in the component tree is 0 or 1, the current page to be tested is the main page; if the number of levels of the current node to be tested from the root node in the component tree is 2, the current page to be tested is the next level page of each user interface control in the main page; if the number of levels is 3, each user interface control in the main page is the next two levels of pages in the main page; and so on and so forth, the current page to be tested corresponding to the current node to be tested in the software to be tested can be obtained.

[0144] Step S602: Acquire the property information of all user interface controls in the current page to be inspected.

[0145] Dump the property information of all user interface controls in the current page to be inspected based on the dump command.

[0146] Step S603: searching for attribute information bound to the current node to be inspected from all acquired attribute information.

[0147] The attribute information bound to the current node to be inspected is searched from the dumped attribute information of all user interface controls.

[0148] Step S604, if the attribute information bound to the current node to be inspected is found, the next node of the current node to be inspected is determined as the current node to be inspected, and the process returns to the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested.

[0149] If the attribute information bound to the current node to be tested is found, the next node at the same level as the current node to be tested in the component tree of the software to be tested is determined as the current node to be tested. If the current node to be tested is the last node traversed to the same level as the current node to be tested in the component tree, any node in the component tree located at the next level below the current node to be tested is determined as the current node to be tested, and the step of determining the current page to be tested corresponding to the current node to be tested in the software to be tested is returned.

[0150] Step S605: if the attribute information bound to the current node to be tested is not found, the self-test result of the component tree of the software to be tested is determined to be a self-test failure, and the self-test result is sent to a preset user terminal.

[0151] If the attribute information bound to the current node to be tested is not found, it means that the user interface control corresponding to the current node to be tested has changed in the software to be tested, and the administrator needs to be actively notified to make modifications. Therefore, the self-test result of the component tree of the software to be tested will be determined as self-test failure, and the self-test result will be sent to the preset user terminal.

[0152] It can be understood that the above steps S601 to S605 can be executed once at fixed time intervals to regularly check the component tree of the software under test, or can be executed in response to the user's component tree self-check instruction to check the component tree of the software under test.

[0153] Optionally, in the process of checking the component tree, a newly added user interface control may be bound to the component tree to reduce manual maintenance of the component tree and reduce the maintenance cost of the component tree. After determining the next node of the current node to be checked as the current node to be checked, and returning to the step of determining the current page to be checked corresponding to the current node to be checked in the software to be tested, the method may further include the following steps B1 to B3:

[0154] Step B1, determining whether there is a user interface control whose attribute information is not bound in the current page to be checked.

[0155] The attribute information of all user interface controls of the current page to be inspected can be searched and dumped from the attribute information bound to all nodes in the component tree. If the attribute information of a user interface control in the current page to be inspected is not found in the attribute information bound to all nodes, it is determined that the user interface control is a user interface control whose attribute information is not bound.

[0156] Step B2: If there are any unbound user interface controls, then a node at the same level as the current node to be tested is added to the component tree of the software to be tested.

[0157] Among them, the newly added node has a node identifier. It can be determined that the unbound user interface control is the parent user interface control in the software to be tested, and a node with a node identifier is added under the corresponding node of the parent user interface control. It can be understood that the node and the current node to be detected are at the same level in the component tree of the software to be tested.

[0158] Step B3: Bind the property information of the unbound controls to the newly added nodes.

[0159] When there are user interface controls whose attribute information is not bound in the current page to be tested, a new node at the same level as the current node to be tested is added to the component tree of the software to be tested, and the attribute information of the unbound control is bound to the newly added node, so as to realize automatic update of the component tree, reduce manual maintenance of the component tree, and reduce the maintenance cost of the component tree.

[0160] In an embodiment of the present application, the attribute information of the user interface control corresponding to each node in the component tree of the software to be tested is automatically monitored to see whether it is consistent with the attribute information of the corresponding user interface control in the software to be tested, so as to find the user interface control that has changed in the software to be tested but has not undergone corresponding changes in the component tree, and send the self-check result to the preset user terminal to facilitate the user who uses the preset user terminal to update the component tree. In this way, the purpose of automatically checking the component tree can be achieved, the reliability of the component tree can be improved to improve the reliability of subsequent automated test scripts, and changes in UI controls can be discovered in advance, reducing the test failure caused by changes in UI controls but failure to update the component tree in time and the need for manual troubleshooting of the test script and the component tree, thereby improving the development efficiency of automated test scripts when UI controls change.

[0161] In the embodiments of the present application, an automated test script generation device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0162] The present application embodiment provides an automated test script generation device, such as Figure 7 As shown, including:

[0163] A determination module 710 is used to determine all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls;

[0164] Establishing module 720, for establishing a component tree of the software to be tested with the main page of the software to be tested as the root node, based on the user interface controls and the hierarchical relationship between the user interface controls, wherein each node in the component tree corresponds to a node identifier and attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls;

[0165] The generation module 730 is used to generate an automated test script based on the component tree, where the automated test script is used to test the user interface function of the software under test.

[0166] In some optional embodiments, establishing a module includes:

[0167] Create a unit for taking the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node, and perform the following steps:

[0168] Traverse each control on the current page and obtain the property information of each control on the current page;

[0169] Add subnodes corresponding to the various controls on the current page under the current node, and the newly added subnodes have corresponding node identifiers;

[0170] Bind the property information of each control on the current page to its corresponding child node;

[0171] Trigger each control on the current page according to the preset trigger operation set;

[0172] If there is a control that can be triggered, the page after the triggering is determined as the next level page of the current page, and the control of the next level page is determined;

[0173] The node corresponding to the control of the next-level page obtained after being triggered in the current page is taken as the current node, the next-level page is taken as the current page, and the control of the next-level page is taken as the control of the current page, and the step of traversing each control of the current page and obtaining the attribute information of each control of the current page is returned;

[0174] If there is no control that can be triggered, the current component tree is the component tree of the software under test.

[0175] In some optional embodiments, the device further comprises:

[0176] A binding module, used for determining the activation condition of the control that cannot be triggered as being unable to be activated in the current component tree, and binding the determined activation condition to the node corresponding to the control that cannot be triggered;

[0177] A first judgment module is used to judge, for a control that can be triggered, whether the number of triggering operations that trigger the control that can be triggered is equal to one;

[0178] The binding module is further used to bind the triggering operation of the control that can be triggered to the node corresponding to the control that can be triggered as an activation condition if the number is equal to one;

[0179] A comparison module, used for comparing whether the user interface controls in each page after the control that can be triggered is the same if the number is greater than one;

[0180] The binding module is further used to bind the triggering operation of the control that can be triggered first among the triggering operations corresponding to the at least two pages as an activation condition to the node corresponding to the control that can be triggered if there are the same user interface controls in at least two pages;

[0181] The binding module is also used to copy the nodes corresponding to the controls that can be triggered if there are different user interface controls in at least two pages, and bind the triggering operations corresponding to at least two pages as activation conditions to each node corresponding to the controls that can be triggered.

[0182] In some optional embodiments, the device further comprises:

[0183] The self-check module is used to take any child node under the root node in the component tree of the software to be tested as the current node to be tested, and execute the following steps until all nodes in the component tree of the software to be tested are traversed or it is determined that the self-check fails:

[0184] Determine the current page to be tested corresponding to the current node to be tested in the software to be tested;

[0185] Get the property information of all user interface controls in the current page to be inspected;

[0186] Find the attribute information bound to the current node to be inspected from all the acquired attribute information;

[0187] If the attribute information bound to the current node to be inspected is found, the next node of the current node to be inspected is determined as the current node to be inspected, and the process returns to the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested;

[0188] If the attribute information bound to the current node to be tested is not found, the self-test result of the component tree of the software to be tested is determined to be a self-test failure, and the self-test result is sent to a preset user terminal.

[0189] In some optional embodiments, the device further comprises:

[0190] The second judgment module is used to determine whether there is a user interface control whose attribute information is not bound in the current page to be checked;

[0191] A new module is added, which is used to add a node at the same level as the current node to be tested in the component tree of the software to be tested if there is an unbound user interface control;

[0192] The binding module is also used to bind the property information of unbound controls to the newly added nodes.

[0193] In some optional embodiments, the device further comprises:

[0194] The modification module is used to receive a modification operation on the property information of the target user interface control in the automated test script, and to modify the property information bound to the node corresponding to the target user interface control in the component tree of the software to be tested.

[0195] In some optional embodiments, the device further comprises:

[0196] A search module is used to search for a target node whose node identifier is bound to the node identifier corresponding to the user interface control to be tested, starting from the root node in the component tree of the software to be tested, and obtain a path from the root node to the target node;

[0197] A trigger module, for triggering corresponding user page controls in each page of the software to be tested based on the activation conditions and attribute information corresponding to each node in the path, so as to reach the user interface control to be tested from the main page;

[0198] The test module is used to test the user interface control to be tested based on the test operation on the user interface control to be tested.

[0199] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0200] The automated test script generation device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0201] The present application also provides a computer device having the above Figure 7 The automated test script generating device shown.

[0202] See also Figure 8 , Figure 8 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present application, such as Figure 8 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 10 is taken as an example.

[0203] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0204] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0205] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0206] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0207] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0208] The embodiment of the present application also provides a computer-readable storage medium. The above method according to the embodiment of the present application can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0209] Although the embodiments of the present application are described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present application, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for generating an automated test script, characterized in that: The method comprises: Determine all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls; Taking the main page of the software to be tested as the root node, based on the user interface controls and the hierarchical relationship between the user interface controls, a component tree of the software to be tested is established, wherein each node in the component tree corresponds to a node identifier and attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls; Generate an automated test script based on the component tree, where the automated test script is used to test the user interface function of the software to be tested; The method of establishing a component tree of the software to be tested with the main page of the software to be tested as a root node based on the user interface controls and the hierarchical relationship between the user interface controls includes: With the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node, perform the following steps: Traverse each control of the current page to obtain the property information of each control of the current page; Adding subnodes corresponding to the respective controls of the current page under the current node, the newly added subnodes corresponding to the node identifiers; Binding the attribute information of each control of the current page to its corresponding child node; Triggering each control of the current page according to a preset trigger operation set; If there is a control that can be triggered, the page after the triggering is determined as the next level page of the current page, and the control of the next level page is determined; The node corresponding to the control of the next-level page obtained after being triggered in the current page is taken as the current node, the next-level page is taken as the current page, and the control of the next-level page is taken as the control of the current page, and the step of traversing each control of the current page and obtaining the attribute information of each control of the current page is returned; If there is no control that can be triggered, the current component tree is the component tree of the software to be tested; Each node in the component tree of the software to be tested also corresponds to an activation condition of a user interface control. Before the step of returning to execute traversing each control of the current page and obtaining the attribute information of each control of the current page, the method further includes: In the current component tree, the activation condition of the control that cannot be triggered is determined as being unable to be activated, and the determined activation condition is bound to the node corresponding to the control that cannot be triggered; For the control that can be triggered, determining whether the number of triggering operations that trigger the control that can be triggered is equal to one; If the number is equal to one, the triggering operation of triggering the control that can be triggered is bound to the node corresponding to the control that can be triggered as an activation condition; If the number is greater than one, comparing whether the user interface controls in each page after triggering the control that can be triggered are the same; If there are at least two pages with the same user interface controls, the trigger operation that first triggers the control that can be triggered among the trigger operations corresponding to the at least two pages is bound as an activation condition to the node corresponding to the control that can be triggered; If there are at least two pages with different user interface controls, the nodes corresponding to the controls that can be triggered are copied, and the triggering operations corresponding to the at least two pages are respectively bound to the nodes corresponding to the controls that can be triggered as activation conditions.

2. The method according to claim 1, characterized in that The method further comprises: Taking any child node under the root node in the component tree of the software to be tested as the current node to be tested, the following steps are performed until all nodes in the component tree of the software to be tested are traversed or it is determined that the self-test fails: Determine the current page to be tested corresponding to the current node to be tested in the software to be tested; Obtaining the property information of all user interface controls in the current page to be inspected; Searching for the attribute information bound to the current node to be inspected from all the acquired attribute information; If the attribute information bound to the current node to be inspected is found, the next node of the current node to be inspected is determined as the current node to be inspected, and the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested is returned to be executed; If the attribute information bound to the current node to be tested is not found, the self-test result of the component tree of the software to be tested is determined to be a self-test failure, and the self-test result is sent to a preset user terminal.

3. The method according to claim 2, characterized in that Before determining the next node of the current node to be inspected as the current node to be inspected and returning to the step of determining the current page to be inspected corresponding to the current node to be inspected in the software to be tested, the method includes: Determine whether there is a user interface control whose attribute information is not bound in the current page to be inspected; If there is an unbound user interface control, then adding a node at the same level as the current node to be tested in the component tree of the software to be tested; Bind the attribute information of the unbound control to the newly added node.

4. The method according to claim 1, characterized in that After generating an automated test script based on the component tree, the method further includes: An operation of modifying the property information of a target user interface control in the automated test script is received, and the property information bound to a node corresponding to the target user interface control in the component tree of the software to be tested is modified.

5. The method according to claim 4, characterized in that The automated test script includes a node identifier corresponding to the user interface control to be tested and a test operation on the user interface control to be tested. After the automated test script is generated based on the component tree, the method further includes: Starting from the root node in the component tree of the software to be tested, searching for a target node whose node identifier is bound to the node identifier corresponding to the user interface control to be tested, and obtaining a path from the root node to the target node; Based on the activation condition and attribute information corresponding to each node in the path, trigger the corresponding user page control in each page of the software to be tested, so as to reach the user interface control to be tested from the main page; Based on the test operation on the user interface control to be tested, the user interface control to be tested is tested.

6. An automated test script generation device, characterized in that: The device comprises: A determination module, used to determine all user interface controls on the software to be tested and the hierarchical relationship between the user interface controls; An establishment module is used to establish a component tree of the software to be tested, taking the main page of the software to be tested as a root node, based on the user interface controls and the hierarchical relationship between the user interface controls, wherein each node in the component tree corresponds to a node identifier and attribute information of a user interface control, and the hierarchical relationship between the nodes corresponds to the hierarchical relationship between the user interface controls; A generating module, used for generating an automated test script based on the component tree, wherein the automated test script is used for testing the user interface function of the software to be tested; The establishment module includes: The establishing unit is used to use the main page as the current page, the user interface controls in the main page as the controls of the current page, and the root node as the current node, and perform the following steps: Traverse each control of the current page to obtain the property information of each control of the current page; Adding subnodes corresponding to the respective controls of the current page under the current node, the newly added subnodes corresponding to the node identifiers; Binding the attribute information of each control of the current page to its corresponding child node; Triggering each control of the current page according to a preset trigger operation set; If there is a control that can be triggered, the page after the triggering is determined as the next level page of the current page, and the control of the next level page is determined; The node corresponding to the control of the next-level page obtained after being triggered in the current page is taken as the current node, the next-level page is taken as the current page, and the control of the next-level page is taken as the control of the current page, and the step of traversing each control of the current page and obtaining the attribute information of each control of the current page is returned; If there is no control that can be triggered, the current component tree is the component tree of the software to be tested; Each node in the component tree of the software to be tested also corresponds to an activation condition of a user interface control, and the device further includes: A binding module, used for determining the activation condition of the control that cannot be triggered as being unable to be activated in the current component tree, and binding the determined activation condition to the node corresponding to the control that cannot be triggered; A first judgment module is used to judge, for the control that can be triggered, whether the number of triggering operations that trigger the control that can be triggered is equal to one; The binding module is further used to bind the triggering operation of triggering the control that can be triggered to the node corresponding to the control that can be triggered as an activation condition if the number is equal to one; A comparison module, configured to compare whether the user interface controls in each page after triggering the control that can be triggered are the same if the number is greater than one; The binding module is further used to bind the triggering operation that first triggers the control that can be triggered among the triggering operations corresponding to the at least two pages as an activation condition to the node corresponding to the control that can be triggered if there are the same user interface controls in at least two pages; The binding module is also used to copy the nodes corresponding to the controls that can be triggered if there are different user interface controls in at least two pages, and bind the triggering operations corresponding to at least two pages as activation conditions to the nodes corresponding to the controls that can be triggered.

7. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the automated test script generation method according to any one of claims 1 to 5 by executing the computer instructions.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are loaded and executed by a processor to implement the automated test script generation method according to any one of claims 1 to 5.