Interactive page testing method and element template generation method and device

By querying the element template library and the target detection model to generate test scripts for interactive pages, the problem of high cost of interactive page testing is solved and an efficient and automated testing method is implemented.

CN114528215BActive Publication Date: 2025-10-03BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210154465.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2025-10-03
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

The cost of generating and maintaining test scripts for interactive pages continues to increase. As applications iterate and upgrade, existing technologies make it difficult to efficiently test interactive pages.

Method used

By querying the element template library, determining the target element template, generating and running the test script, using the target detection model to detect the operable elements and their attribute information of the interactive page, generating an element template for each operable element, and generating a test script based on the attribute information.

Benefits of technology

It reduces the cost of generating test scripts, improves the efficiency of generating test scripts, and improves the automation and accuracy of interactive page testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114528215B_ABST
    Figure CN114528215B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method for testing an interactive page, a method for generating a section template, an apparatus, an electronic device, and a storage medium, and relates to the field of computer technology, and specifically to the field of code testing and deep learning. The specific implementation scheme of the method for testing an interactive page is as follows: querying an element template library according to the interactive page to be tested, determining a target element template for the interactive page to be tested; determining the measurable elements and attribute information of the measurable elements included in the interactive page to be tested according to the target element template; generating a test script for the interactive page to be tested according to the attribute information; and running the test script to test the interactive page to be tested, wherein each element template in the element template library targets an operable element, and each element template includes attribute information of the targeted operable element.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of computer technology, specifically to the fields of code testing technology and deep learning technology, and in particular to a method for testing an interactive page and a method, device, equipment, and medium for generating an element template. Background Art

[0002] To ensure a consistent interactive experience, interactive pages typically need to be tested before they're released. As the business involved in an application evolves and upgrades, the cost of generating and maintaining scripts to test interactive pages continues to increase. Summary of the Invention

[0003] The present disclosure aims to provide a method for testing interactive pages and a method, apparatus, device, and medium for generating element templates that reduce testing costs.

[0004] According to one aspect of the present disclosure, a testing method for an interactive page is provided, comprising: querying an element template library based on the interactive page to be tested to determine a target element template for the interactive page to be tested; determining, based on the target element template, measurable elements included in the interactive page to be tested and attribute information of the measurable elements; generating a test script for the interactive page to be tested based on the attribute information; and running the test script to test the interactive page to be tested, wherein each element template in the element template library targets an operable element, and each element template includes attribute information of the targeted operable element.

[0005] According to another aspect of the present disclosure, a method for generating an element template is provided, including: detecting a first image for an interactive page, determining the operable elements included in the interactive page and the attribute information of the operable elements; and for each operable element, generating an element template for each operable element according to the attribute information of each operable element.

[0006] According to another aspect of the present disclosure, a testing device for an interactive page is provided, including: a target determination module, used to query an element template library based on the interactive page to be tested, and determine a target element template for the interactive page to be tested; an element determination module, used to determine, based on the target element template, the measurable elements included in the interactive page to be tested and the attribute information of the measurable elements; a script generation module, used to generate a test script for the interactive page to be tested based on the attribute information; and a test module, used to run the test script to test the interactive page to be tested, wherein each element template in the element template library targets an operable element, and each element template includes the attribute information of the targeted operable element.

[0007] According to another aspect of the present disclosure, a device for generating an element template is provided, including: an image detection module for detecting a first image for an interactive page, determining the operable elements included in the interactive page and the attribute information of the operable elements; and a template generation module for generating an element template for each operable element according to the attribute information of each operable element.

[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the interactive page testing method and / or element template generation method provided by the present disclosure.

[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the interactive page testing method and / or element template generation method provided by the present disclosure.

[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the interactive page testing method and / or element template generation method provided by the present disclosure.

[0011] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0013] Figure 1 Schematic diagram of an application scenario of an interactive page testing method and an element template generation method and device according to an embodiment of the present disclosure;

[0014] Figure 2 is a flowchart of a method for generating an element template according to an embodiment of the present disclosure;

[0015] Figure 3 is a schematic diagram of the principle of a method for generating an element template according to an embodiment of the present disclosure;

[0016] Figure 4 is a schematic diagram of the principle of a method for generating an element template according to another embodiment of the present disclosure;

[0017] Figure 5is a flowchart of a method for testing an interactive page according to an embodiment of the present disclosure;

[0018] Figure 6 is a schematic diagram of the principle of determining a target element template according to an embodiment of the present disclosure;

[0019] Figure 7 Schematic diagram of the principle of the testing method of the interactive page according to the embodiment of the present disclosure;

[0020] Figure 8 is a structural block diagram of a device for generating an element template according to an embodiment of the present disclosure;

[0021] Figure 9 is a structural block diagram of a testing device for an interactive page according to an embodiment of the present disclosure; and

[0022] Figure 10 It is a block diagram of an electronic device used to implement the method for generating element templates and / or the method for testing interactive pages according to the embodiments of the present disclosure. DETAILED DESCRIPTION

[0023] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0024] The present disclosure provides a testing method for an interactive page, which includes a target template determination phase, an element determination phase, a script generation phase, and a testing phase. In the target template determination phase, an element template library is queried based on the interactive page to be tested to determine the target element template for the interactive page to be tested. In the element determination phase, the measurable elements and the attribute information of the measurable elements included in the interactive page to be tested are determined based on the target element template. In the script generation phase, a test script for the interactive page to be tested is generated based on the attribute information. In the testing phase, the test script is run to test the interactive page to be tested. Each element template in the element template library targets an operable element, and each element template includes the attribute information of the targeted operable element.

[0025] The following will be combined Figure 1 The application scenarios of the method and device provided by the present disclosure are described.

[0026] Figure 1 It is a schematic diagram of an application scenario of the interactive page testing method and element template generation method and device according to the embodiment of the present disclosure.

[0027] like Figure 1 As shown, the application scenario 100 of this embodiment may include an electronic device 110, which may be various electronic devices with processing functions, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, servers, etc.

[0028] For example, the electronic device 110 may test the interactive page 120 that can be provided by the application to be launched to determine whether each operable element in the interactive page 120 can respond normally.

[0029] For example, the electronic device 110 may be provided with an automated testing tool, and a tester may code a test script and run the test script by means of the automated testing tool, thereby implementing testing of the operable elements in the interactive page 120 .

[0030] For example, the electronic device 110 can display the interactive page 120, and use the recording plug-in to record the tester's interactive operations on the interactive page 120, and generate an executable test script based on the recorded interactive operations. The test script is then run by the automated testing tool to test the operable elements in the interactive page 120.

[0031] In one embodiment, the operational elements of interactive pages provided by an already launched application can be analyzed, and an element template generated based on the analysis results can be used as a basis for testing the interactive pages provided by the upcoming application. In this way, during the iterative application update process, by generating test scripts for the interactive pages of the new version of the application based on the element template, the efficiency of generating the test scripts can be improved and the cost of generating the test scripts can be reduced.

[0032] like Figure 1 As shown, the application scenario 100 may also include a server 140, which can analyze the interactive pages in the online application to generate and maintain an element template library. Each element template in the element template library defines the attribute information of an operable element. When the electronic device 110 tests the interactive page 120, for example, it can search and obtain a matching element template from the element template library as the target element template 130. In this way, the electronic device 110 can generate a test script for the interactive page 120 based on the target element template 130 to facilitate testing of the interactive page 120.

[0033] It should be noted that the interactive page testing method provided in the present disclosure can be executed by the electronic device 110 or by the server 140. Accordingly, the interactive page testing device provided in the present disclosure can be set in the electronic device 110 or by the server 140. The element template generation method provided in the present disclosure can be executed by the server 140. Accordingly, the element template generation device provided in the present disclosure can be set in the server 140.

[0034] It should be understood that Figure 1 The number and type of the electronic devices 110 and the server 140 in FIG. 1 are merely illustrative. Any number and type of electronic devices 110 and servers 140 may be provided as required.

[0035] The following will be combined Figure 1 , by the following Figures 2 to 4 The method for generating the element template provided by the present disclosure is described in detail.

[0036] Figure 2 It is a flowchart of a method for generating an element template according to an embodiment of the present disclosure.

[0037] like Figure 2 As shown, the method 200 for generating an element template in this embodiment may include operations S210 to S220.

[0038] In operation S210 , a first image of an interactive page is detected, and operable elements included in the interactive page and attribute information of the operable elements are determined.

[0039] According to an embodiment of the present disclosure, an interactive page can be opened according to a uniform resource locator (URL), and a first image of the interactive page can be obtained by taking a screenshot. This embodiment can associate the URL with the first image and store it. Alternatively, a large number of pre-captured images of interactive pages can be stored in a storage space, and this embodiment can obtain any image from this storage space for detection.

[0040] According to an embodiment of the present disclosure, a target detection model with operable elements as detection targets can be used to detect the first image. The training sample of the target detection model can be an image with operable elements labeled. The target detection model can take the first image as input, and output the bounding box of the operable element in the first image and the probability that the operable element in the first image belongs to each category in multiple predetermined categories. Each bounding box output represents an operable element. This embodiment can determine the attribute information that the category corresponding to the maximum probability among the probabilities belonging to multiple predetermined categories is an operable element. The bounding box of the operable element can be represented by the position information of the bounding box in the first image, and the position information can include the position of the center point of the bounding box in the first image.

[0041] The operable element may be any element that can change the displayed content of a page in response to a user operation. For example, the operable element may include an input box, a page jump button, etc. In one embodiment, the attribute information may include the type of the operable element. The multiple predetermined categories may include input box type, jump type, etc., which is not limited in this disclosure.

[0042] In operation S220 , for each operable element, an element template for each operable element is generated according to attribute information of each operable element.

[0043] According to an embodiment of the present disclosure, an element template can be generated for each operable element. The element template contains attribute information of each operable element, and the element template can be indexed by the identification information of the element group to which each operable element belongs. The type of the operable element can be part of the attribute information of the operable element.

[0044] In one embodiment, validation rules can also be set for each operational element based on its type. For example, for a jump-type operational element, the validation rule can be that after the interactive operation is performed, the interactive page where the operational element is located jumps to another page. Alternatively, the URL address of the other page to which the jump-type operational element jumps can be entered, etc., which is not limited in this disclosure. By setting validation rules in the element template, more abundant basis information can be provided for testing interactive pages.

[0045] In one embodiment, the element template may further include position information of the operable element, which may be part of the attribute information of the operable element. Based on this position information, it is convenient to perform simulated operations on the operable element. This position information may be the center position of the enclosing box described above.

[0046] In summary, the method for generating element templates of the embodiment of the present disclosure can generate element templates based on the detection results obtained by performing target detection on an image without manual participation, which can improve the generation cost of element templates. Furthermore, since the element template is generated for each element rather than for the entire interactive page, the element template can be adapted to all business lines that have set up the operable elements targeted by the element template, and can improve the coverage of the scenarios to which the element module is applicable. In addition, since the element is generated based on the attribute information of the operable element, the attribute information of the operable element can be provided as reference information for the test of the interactive page, which helps to reduce the workload required to generate the test script.

[0047] According to an embodiment of the present disclosure, before generating an element template, the operable elements may be divided into at least one element group.

[0048] For example, if the interactive page includes multiple operable elements, this embodiment can divide the operable elements with similar positions into an element group based on the position information of the enclosing boxes of the operable elements. For example, for any operable element, the operable element and the operable elements that are spaced apart from the operable element by a distance greater than a predetermined distance are divided into two element groups.

[0049] In one embodiment, the operational elements included in the interactive page can be divided according to class. For example, based on the DOM tree of the interactive page, multiple classes involved in the interactive page and the relationships between the multiple classes can be determined. The operational elements are then divided according to the relationships, thereby obtaining at least one element group.

[0050] For example, the DOM tree corresponding to the page source of the interactive page can reflect the relationship between the elements in the interactive page. Each operable element corresponds to a node in the DOM tree, and the node corresponding to the operable element has a class, and the class of the node is the class of each operable element. Usually, in the DOM tree, the node corresponding to each operable element has a parent node, and the parent node also has a class. This embodiment can divide the operable elements corresponding to multiple nodes with the same parent node into an element group, and use the class of the parent node as the class of the element group obtained by the division. In this way, the multiple classes involved in the interactive page include the class of the operable element and the class of at least one element group. And the class of each element group is the parent class of the class of the operable element included in each element group.

[0051] Accordingly, this embodiment can use the class name of the class of the operable element as the identification information of each element plate. In this way, when the interactive page needs to be tested, the target element template for the interactive page can be determined according to the class name involved in the interactive page.

[0052] In one embodiment, when generating an element template, the attribute information of the operable element and the subordinate relationship between the operable element and the element group can also be considered at the same time. For example, the attribute information of the operable element is used as the content of the element template, the class name of the class of the operable element is used as the identification information of the element template, and an association relationship is established between the element template and the class name of the class of the element group to which the operable element belongs. By dividing the operable elements according to the parent-child relationship of the class, when the same operable element is set in different business segments, the operable elements in different business segments can be effectively distinguished, which is beneficial to providing more accurate reference information for the testing of the interactive page and improving the testing accuracy of the interactive page.

[0053] It is understood that before generating the element template, for example, the area where each operational element in the interactive page is located can be pre-marked in the first image. Subsequently, based on the positional relationship between the position information of the bounding box obtained by detecting the first image and the area where each operational element is located, the detected operational elements are associated with the operational elements corresponding to the nodes in the DOM tree.

[0054] Figure 3 It is a schematic diagram of the principle of the method for generating an element template according to an embodiment of the present disclosure.

[0055] According to an embodiment of the present disclosure, the attribute information obtained through the aforementioned detection includes the type of the operable element. After determining that the type of the operable element is a jump type by detecting the first image, this embodiment can also verify the type of the operable element through simulated operation, thereby improving the accuracy of the determined operable element type, thereby improving the accuracy of the generated section template and the accuracy of the interactive page tested based on the section template.

[0056] Exemplarily, for the first element of the jump type determined by detecting the first image, the first predetermined script can be run according to the position information of the first element. By running the first predetermined script, a simulation operation can be performed on the first element in the interactive page. According to whether the URL address of the page displayed after the simulation operation (i.e., the page obtained after running the first predetermined script) is consistent with the URL address of the interactive page, it can be determined whether the interactive page has jumped after the simulation operation is performed on the first element. If the URL address of the page displayed after the simulation operation is inconsistent with the URL address of the interactive page before the simulation operation, it means that the interactive page has jumped, and the type of the first element is further determined to be a jump type. Otherwise, it is determined that the type of the first element is not a jump type. Among them, the simulation operation performed on the first element can be, for example, a click operation, etc., and the first predetermined script can be written in a language such as python, which is not limited in this disclosure.

[0057] For example, whether a redirect occurs can also be determined based on the difference between the page displayed after the simulated operation and the interactive page displayed before the simulated operation. For example, if the difference ratio between the two pages exceeds a predetermined ratio, a redirect can be determined to have occurred. The predetermined ratio can be 60%, 80%, 90%, etc., and this disclosure is not limited to this.

[0058] like Figure 3As shown, when generating an element template for an interactive page 310, the embodiment 300 can first take a screenshot of the interactive page 310 to obtain a first image 311 of the interactive page 310. At the same time, the page source code of the interactive page 310 can be crawled. Subsequently, the target detection model 320 can be used to perform target detection on the first image 311 to obtain the location information and type of the operable elements included in the interactive page 310. The page source code can be analyzed to generate a DOM tree 312, and based on the association relationship between the nodes in the DOM tree 312, the operable elements with the same parent class among the detected operable elements can be determined, thereby dividing them into at least one element group 330. Finally, based on the at least one element group 330, the location information and type of the operable elements can be used to generate an element template 340 for each operable element, and the generated element template 340 can be stored in a relational database 350.

[0059] It should be noted that for the jump-type operable element detected by the object detection model 320, the first predetermined script is run according to the position information of the operable element to verify the type of the operable element. After the verification is completed, the element template is generated.

[0060] Figure 4 It is a schematic diagram of the principle of a method for generating a plate template according to another embodiment of the present disclosure.

[0061] According to an embodiment of the present disclosure, when generating a section template, a random value can be assigned to a second element of the input box type within the operable element, and the page changes after the second element is assigned can be determined. Since the second element is an element within an interactive page of an already-launched application, the page changes after the assignment can reflect the response to the interactive operation performed on the second element. This embodiment can determine the test criteria based on the value assigned to the second element and the page after the assignment.

[0062] For example, this embodiment can determine the second element based on the detection results obtained from the aforementioned detection of the first page. Input information can be randomly generated for the second element. The type of the input information can include, for example, numbers, letters, text, special symbols, or numbers plus letters, etc., which is not limited in this disclosure. For example, this embodiment can use any method to randomly generate input information, which is not limited in this disclosure.

[0063] After obtaining the input information, this embodiment can execute a second predetermined script according to the input information to assign the input information to the second element. Among them, running the second predetermined script, for example, can perform a simulation operation on the second element in the interactive page, and the input information can be input into the second element through the simulation operation. The second predetermined script can be written in a language such as python, and the present disclosure does not limit this. After the second predetermined script is run, the input information is assigned to the second element, specifically, the second element is filled with the input information. At this time, this embodiment can take a screenshot of the interactive page after running the second predetermined script, so as to obtain a second image of the interactive page.

[0064] After obtaining the second image, this embodiment can determine the test standard for the second element and the test interaction information for the second element based on the input information and the second image. Among them, the input information can be used as the test interaction information, and the second image can be used as the test standard that matches the test interaction information. For example, if the input information that matches the second element is of a digital type, and the input information randomly generated for the second element is of a digital type, then compared with the first image, the second element of the second image contains randomly generated input information, and the surrounding area of ​​the second element has an identification indicating that the input is correct, then the test interaction information can be input information of a digital type input in the second element, and for the test interaction information, the test standard is to display an identification indicating that the input is correct. Among them, the identification indicating that the input is correct can be, for example, a "check mark" symbol, etc., and the present disclosure does not limit this. Alternatively, if the input information matching the second element is of a digital type, but the input information randomly generated for the second element is of a letter type, then compared to the first image, the second element of the second image contains randomly generated input information, and the surrounding area of ​​the second element has an identifier indicating an input error, then the test interaction information can be input information of a digital type entered in the second element, and for the test interaction information, the test standard is to display an identifier indicating an input error.

[0065] In one embodiment, an association relationship can be established between the element template of the second element and the test standard, and an association relationship can be established between the element template of the second element and the test interaction information. In this way, when generating a test script for the interactive page to be tested, the test interaction information and test standard can be found based on the target element template. The test interaction information can be used as the basis for generating the test script, and the test standard can be used as the basis for determining the test results. This helps to improve the automation level of testing interactive pages and further reduce testing costs.

[0066] In one embodiment, the second element may be found by traversing the DOM tree, and the test standard and test interaction information for the second element may be obtained.

[0067] like Figure 4 As shown, in the process of generating the element template, the embodiment 400 can perform operation S410 to open the interactive page according to the URL address of the interactive page. Operation S420 can then be performed to parse the page source code of the interactive page to obtain a DOM tree for the interactive page. Subsequently, operation S430 can be performed to traverse the DOM tree to obtain the operable elements in the interactive page. Operation S440 can be used to determine whether the operable element is an input box. If so, continue to perform operation S450, otherwise return to perform operation S430 to traverse and obtain other operable elements. Among them, operation S440 can locate the traversed operable element to the operable element detected by the target, and determine whether the traversed operable element is an input box based on the type of the detected operable element. For example, the detected operable element can be located based on whether the center of the enclosing box of the operable element detected by the target falls into the area where the traversed operable element is located.

[0068] Then, input information is randomly generated for the operable element belonging to the input box through operation S450. After the input information is generated, a second predetermined script is executed through operation S460 to assign the input information to the operable element and obtain a second image of the interactive page.

[0069] In one embodiment, after obtaining the second image, the second image may be processed to extract a region image from the second image. The region image may reflect the response result of the interactive page after the input information is assigned to the second element.

[0070] Subsequently, the embodiment 400 may analyze the difference between the second image and the first image in operation S470 and determine a test criterion for the operable element based on the difference. For example, the difference between the region image captured from the second image and the corresponding region image in the first image may be used as the test criterion.

[0071] After executing operation S470 , it can be determined through operation S480 whether the DOM tree has been completely traversed. If not, the process returns to execute operation S430 . If it has been completely traversed, the process of determining the test standard for the input box is completed.

[0072] According to an embodiment of the present disclosure, after completing the process of determining the test standard and test interaction information of the second element, the embodiment can establish an association relationship between the generated element template of the second element and the test standard and test interaction information to complete the element template generation process.

[0073] According to an embodiment of the present disclosure, after executing the element template generation process of the embodiment of the present disclosure for a large number of interactive pages, multiple element templates can be obtained, and the multiple element templates can be stored in a relational database in the form of a table, thereby obtaining an element template library.

[0074] Based on the element template library generated by the embodiment of the present disclosure, the present disclosure also provides a testing method for interactive pages. Figures 5 to 7 Describe the testing method for this interactive page in detail.

[0075] Figure 5 It is a flowchart of a method for testing an interactive page according to an embodiment of the present disclosure.

[0076] like Figure 5 As shown, the interactive page testing method 500 of this embodiment may include operations S510 to S510 to S540.

[0077] In operation S510 , an element template library is queried according to the interactive page to be tested to determine a target element template for the interactive page to be tested.

[0078] According to an embodiment of the present disclosure, the DOM tree of the interactive page to be tested can be traversed to obtain the class involved in the interactive page to be tested. Subsequently, an element template with the class name of the class involved in the interactive page to be tested as identification information is used as the target element template.

[0079] According to the aforementioned method for generating element templates, each element template in the element template library targets an operable element, and each element template includes attribute information of the operable element it targets.

[0080] In operation S520 , measurable elements and attribute information of the measurable elements included in the interactive page to be tested are determined according to the target element template.

[0081] According to an embodiment of the present disclosure, the class name based on which the target element template is queried can be determined first. The element with the class name in the interactive page to be tested is the measurable element, and the attribute information included in the target element template is the attribute information of the measurable element. This is because elements with the same class name in different interactive pages generally have the same attribute information. Therefore, the attribute information in the target element template can be directly used as the attribute information of the measurable element.

[0082] In operation S530 , a test script for the interactive page to be tested is generated according to the attribute information.

[0083] According to an embodiment of the present disclosure, the attribute information may include, for example, the type of operable element, and different types of operable elements may correspond to different simulation operations. This embodiment may first determine the simulation operation corresponding to the target element template based on the attribute information, and then use the pre-generated script for the simulation operation as the test script for the interactive page to be tested. In particular, in the case where the interactive page to be tested includes multiple operable elements, this embodiment may obtain multiple simulation operation scripts for the multiple operable elements, and then connect the multiple simulation operation scripts in sequence to obtain a test script for the interactive page to be tested.

[0084] In one embodiment, the attribute information may further include position information of the operable element. In this embodiment, the position information may be used as the value of a variable in a script for simulating the operation, thereby obtaining a test script.

[0085] In one embodiment, associated test interaction information may be obtained from an element template library based on the target element template. This test interaction information may include input information. For an actionable element of the input box type, this embodiment may use the position information and input information as the values ​​of variables in a script for simulating the operation, thereby generating a test script.

[0086] In operation S540 , the test script is run to test the interactive page to be tested.

[0087] This embodiment can run the test script via an automated testing platform, and determine the test result of the interactive page to be tested by analyzing the page obtained after running the test script.

[0088] For example, the associated test standard can be obtained from the element template library based on the target element template. Based on the test standard, the expected changes of the page obtained after running the test script relative to the interactive page to be tested can be determined. If the actual changes of the page obtained after running the test script relative to the interactive page to be tested are the same as the expected changes, it can be determined that the interactive page to be tested has passed the test. If the actual changes are different from the expected changes, it can be determined that the interactive page to be tested has failed the test.

[0089] In one embodiment, the interactive page testing method of this embodiment can be executed through a pre-configured API interface. For example, a DOM API can be provided to analyze the page source code of the interactive page to be tested, generate a DOM tree based on the page source code, analyze the DOM tree to obtain the classes involved in the interactive page to be tested, and query the element template library based on the involved classes to obtain the target element template and the attribute information of the testable element. For example, an ACTION API can be provided to generate a test script for implementing a simulated operation based on the attribute information of the testable element.

[0090] In summary, the test method of the embodiment of the present disclosure can generate a test script based on the attribute information in the element template. That is, for the middle platform, it is only necessary to maintain the element template to realize the automatic generation of the test script, thereby improving the generation efficiency of the test script and reducing the generation cost. And because the template in the element template library is for a single operable element, the test method of this embodiment can be applied to a variety of scenarios, and the test method is highly robust.

[0091] Figure 6 It is a schematic diagram of the principle of determining the target element template according to an embodiment of the present disclosure.

[0092] According to an embodiment of the present disclosure, when an element template in an element template library is associated with the class name of the element group to which the operable element belongs, the elements in the interactive page to be tested can also be filtered according to the class of the element group, thereby obtaining testable elements. This can avoid the situation where the business segment corresponding to the determined target element template is different from the business segment to which the interactive page to be tested belongs, thereby improving the accuracy of the generated test script and the testing accuracy of the interactive page.

[0093] like Figure 6 As shown, when determining the target element template, this embodiment 600 can first determine the classes involved in the interactive page under test based on the first DOM tree 610 for the interactive page under test. The classes involved in the interactive page under test can include, for example, classes 620_1 to 620_n, totaling n classes. For example, this embodiment can traverse the first DOM tree 610 and use the classes of all nodes in the first DOM tree 610 as the classes involved in the interactive page under test.

[0094] Subsequently, this embodiment can query the element template library 630 based on classes 620_1 through 620_n to determine candidate element templates 640 within the element template library. Specifically, the query conditions can be used to retrieve element templates from the element template library that use the query conditions as identification information. Specifically, the candidate element templates target operable elements whose classes belong to the classes involved in the interactive page being tested.

[0095] Subsequently, the element group to which the operable element targeted by the alternative element template 640 belongs can be determined. That is, the element group having a subordinate relationship with the alternative element template 640 is determined. It is then determined whether the class of the element group belongs to the class involved in the interactive page to be tested. The element group whose class belongs to the class involved in the interactive page to be tested can be used as the target element group 650, and the template of the operable element in the alternative element template 640 that belongs to the target element group can be used as the target element template 660. In this way, the class of the element group having a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

[0096] According to embodiments of the present disclosure, when there are multiple measurable elements, a portion of the measurable elements can be screened for testing based on the test objective. For example, if the measurable elements include elements provided by multiple business functions, and the test objective is to test only the target business function, then the elements provided by the target business function can be screened from the measurable elements as the elements to be tested.

[0097] In one embodiment, the test objective can also be to test only specific types of operable elements. In this embodiment, the element to be tested from among multiple testable elements can be determined based on the test objective and element type. This allows the interactive page testing method to better align with the test objective, improving test accuracy and the refinement of the test method design.

[0098] In one embodiment, when there are multiple elements to be tested, a test order can also be set for the elements to be tested according to the element type, so as to avoid the situation where the interactive page to be tested has jumped to other pages when a certain element to be tested has not been tested, and thus ensure that all elements to be tested are tested.

[0099] For example, when generating a test script, this embodiment may first determine the element to be tested from multiple testable elements based on the test objective and element type. Then, based on the target element template, test interaction information for the element to be tested is determined. Simultaneously, the test order for the elements to be tested is determined based on the element type. Finally, based on the test interaction information and the test order, a test script is generated for testing the element to be tested.

[0100] Specifically, after obtaining the test interaction information of the element to be tested, this embodiment can generate a test script for each element to be tested based on the test interaction information and the aforementioned simulation operation template. Subsequently, according to the test order of the elements to be tested, the test scripts for multiple elements to be tested are sequentially connected to obtain a test script for the interactive page to be tested.

[0101] When determining that the information is interaction information, the element template of the element to be tested in the target element template can be first determined, and the test interaction information associated with the element template of the element to be tested in the element template library can be used as the test interaction information for the element to be tested. When determining the test order, the elements to be tested with a jump type can be sorted last, and the elements to be tested of other types can be sorted randomly. Alternatively, the elements to be tested of other types can be sorted according to the order of the nodes corresponding to the elements to be tested in the first DOM tree from left to right, which is not limited in this disclosure.

[0102] According to an embodiment of the present disclosure, when testing an interactive page, the embodiment can also determine the test criteria for the element to be tested based on the target element template. Specifically, the test criteria associated with the target element template are queried from the element template library. After running the test script, a post-test page of the interactive page to be tested can be obtained after the test script is completed. In this way, the test results of the interactive page to be tested can be determined based on the post-test page and the test criteria.

[0103] It can be understood that, when there are multiple elements to be tested, this embodiment can obtain the test standard for each element to be tested. After running the test script for each element to be tested, a post-test page can be obtained, and the post-test page is compared with the page before running the test script for each element to be tested to determine whether the difference between the two pages obtained by comparison meets the test standard for each element to be tested. If so, the test result of each element to be tested is determined to have passed the test. In the case where multiple elements to be tested have passed the test, the test result of the interactive page to be tested is determined to have passed the test. In this way, when the interactive page to be tested fails the test, the operable element that cannot respond accurately can be quickly located.

[0104] This embodiment determines the test results by determining the test criteria, which can further improve the test automation level of the interactive page.

[0105] Figure 7 It is a schematic diagram of the principle of the testing method of the interactive page according to the embodiment of the present disclosure.

[0106] According to the embodiments of the present disclosure, when testing an interactive page to be tested, if the interactive page to be tested includes subordinate pages, it is generally necessary to test all of its subordinate pages to ensure the integrity of the test. If the interactive page to be tested has sub-pages, it is generally necessary to test the sub-pages as well.

[0107] For example, it is possible to determine whether the interactive page to be tested has subordinate pages or sub-pages based on whether the DOM tree of the post-test page has changed compared to the DOM tree of the interactive page to be tested. Specifically, when determining the test results for the interactive page to be tested, this embodiment can first determine whether the post-test page meets the test criteria, specifically whether the difference between the post-test page and the interactive page to be tested meets the test criteria. If the test criteria are met, the page source code of the post-test page is obtained, and a second DOM tree is generated based on the page source code of the post-test page. The second DOM tree is the DOM tree for the post-test page. It is then determined whether the second DOM tree is the same as the first DOM tree for the interactive page to be tested. If the two DOM trees are the same, it can be determined that the test has passed. If the two DOM trees are different, the post-test page can be used as the interactive page to be tested, and the element template library can be returned and re-queried to test the post-test page until the DOM tree of the post-test page obtained after the test is performed on the interactive page to be tested is consistent with the DOM tree of the interactive page to be tested. Through this embodiment, a complete test of the interactive page to be tested can be achieved, which is conducive to improving the degree of test automation.

[0108] In one embodiment, when the second DOM tree is consistent with the first DOM tree, this embodiment can determine whether new test information exists based on the test objective, element type, and target element template. If new test information exists, a new test script is generated based on the new test information to retest the interactive page under test until no new test information is found. This is because a test may have multiple test objectives. Even if there is a single test objective, it may involve multiple jump-type elements. To avoid incomplete test objective implementation or situations where testing one jump-type element causes the page to jump and other jump-type elements cannot be tested, this embodiment can determine whether new test information exists. The test information can correspond to a test combination, which is a combination of test elements determined based on the test objective. For example, if there are two test objectives, the test elements involved in each test objective can be combined into a test combination. For example, if there are two jump-type elements, the two jump-type elements can be divided into two test combinations.

[0109] When generating a new test script based on new test information, attribute information can be determined based on the elements to be tested included in the new test information, and a template for the elements to be tested in the candidate element template can be determined, and a test script can be generated based on the attribute information.

[0110] Through the testing method of this embodiment, the testing integrity of the interactive page to be tested can be improved, thereby achieving the testing purpose.

[0111] In one embodiment, a CONTENT API may be pre-configured and called to generate test information. For example, the DOM API described above may be called to generate a DOM tree for the interactive page to be tested and obtain the target element template and attribute information of the testable elements. The ACTION API described above may also be called to generate a test script.

[0112] Accordingly, if Figure 7 As shown, when testing an interactive page to be tested, this embodiment 700 can first perform operation S710 to open and render the interactive page to be tested according to the URL address to open the interactive page to be tested. DOM API 711 can then be called to determine the testable elements and their attribute information. CONTENT API 712 can then be called to generate test information, i.e., to determine the elements to be tested. ACTION API 713 can then be called to generate a test script for the elements to be tested, thereby testing the interactive page to be tested. After the test, operation S720 can be used to determine whether the DOM tree of the post-test page is consistent with the DOM tree of the interactive page to be tested. If not, the post-test page is used as the interactive page to be tested, and DOM APIs 711 to ACTION APIs 713 are called again to test the post-test page. If they are consistent, CONTENT API 712 is called to obtain new test information. Operation S730 is then used to determine whether the new test information has been obtained. If the result is obtained, the ACTION API 713 is called again to generate a new test script, and the interactive page to be tested is tested according to the new test script until there is no new test information, and the test of the interactive page to be tested is completed.

[0113] Based on the method for generating an element template provided by the present disclosure, the present disclosure also provides a device for generating an element template. Figure 8 The device is described in detail.

[0114] Figure 8 It is a structural block diagram of a device for generating an element template according to an embodiment of the present disclosure.

[0115] like Figure 8 As shown, the element template generation device 800 of this embodiment may include an image detection module 810 and a template generation module 820.

[0116] The image detection module 810 is used to detect the first image for the interactive page and determine the operable elements and attribute information of the operable elements included in the interactive page. In one embodiment, the image detection module 810 can be used to perform the operation S210 described above, which will not be repeated here.

[0117] The template generation module 820 is used to generate an element template for each operable element according to the attribute information of each operable element. In one embodiment, the template generation module 820 can be used to perform the operation S220 described above, which will not be repeated here.

[0118] According to an embodiment of the present disclosure, the apparatus 800 may further include an element division module for dividing the operable elements into at least one element group. The template generation module 820 is configured to generate an element template for each operable element based on the attribute information of each operable element and the subordinate relationship between each operable element and the element group.

[0119] According to an embodiment of the present disclosure, the element division module may include a class determination submodule and a division submodule. The class determination submodule is used to determine, based on the DOM tree for the interactive page, multiple classes involved in the interactive page and the association relationships between the multiple classes. The division submodule is used to divide the operable elements based on the association relationships to obtain at least one element group. The multiple classes include a class of operable elements and a class of at least one element group; the class of each element group is the parent class of the class of the operable elements included in each element group.

[0120] According to an embodiment of the present disclosure, the attribute information includes the element type, and the device 800 may further include a simulation operation execution module and a type determination module. The simulation operation execution module is configured to execute a first predetermined script based on the location information of a first element of a jump type among the operable elements to perform a simulation operation on the interactive page. The type determination module is configured to determine that the type of the first element is a jump type in response to a URL address of a page obtained after executing the first predetermined script being inconsistent with the URL address of the interactive page.

[0121] According to an embodiment of the present disclosure, the attribute information includes the element type. The device 800 may also include an information generation module, an element assignment module, an image acquisition module and an information determination module. The information generation module is used to randomly generate input information for the second element of the input box type in the operable element. The element assignment module is used to execute a second predetermined script according to the input information to assign the input information to the second element. The image acquisition module is used to obtain the second image of the interactive page after the second predetermined script is run. The information determination module is used to determine the test standard for the second element and the test interaction information for the second element based on the input information and the second image. Among them, the element template for the second element is associated with the test standard and the test interaction information.

[0122] Based on the test method of the interactive page provided by the present disclosure, the present disclosure also provides a test device for the interactive page. Figure 9 The device is described in detail.

[0123] Figure 9 4 is a structural block diagram of a testing device for an interactive page according to an embodiment of the present disclosure.

[0124] like Figure 9 As shown, the interactive page testing device 900 of this embodiment may include a target determination module 910 , an element determination module 920 , a script generation module 930 and a testing module 940 .

[0125] The target determination module 910 is used to query the element template library based on the interactive page to be tested and determine the target element template for the interactive page to be tested. Each element template in the element template library targets an operational element, and each element template includes attribute information of the operational element. In one embodiment, the target determination module 910 can be used to perform operation S510 described above, and will not be repeated here.

[0126] The element determination module 920 is used to determine the measurable elements and attribute information of the measurable elements included in the interactive page to be tested according to the target element template. In one embodiment, the element determination module 920 can be used to perform the operation S520 described above, which will not be repeated here.

[0127] The script generation module 930 is used to generate a test script for the interactive page to be tested based on the attribute information. In one embodiment, the script generation module 930 can be used to perform the operation S530 described above, which will not be repeated here.

[0128] The test module 940 is used to run the test script to test the interactive page to be tested. In one embodiment, the test module 940 can be used to perform the operation S540 described above, which will not be repeated here.

[0129] According to an embodiment of the present disclosure, the above-mentioned target determination module 910 may include a class determination submodule, an alternative determination submodule and a target determination submodule. The class determination submodule is used to determine the class involved in the interactive page to be tested based on the first DOM tree for the interactive page to be tested. The alternative determination submodule is used to determine the alternative element template in the element template library, and the class of the operable element targeted by the alternative element template belongs to the class involved in the interactive page to be tested. The target determination submodule is used to determine the target element template in the alternative element template based on the class of the element group that has a subordinate relationship with the operable element targeted by the alternative element template. Among them, the class of the element group that has a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

[0130] According to an embodiment of the present disclosure, the number of measurable elements is multiple, and the attribute information includes the element type. The above-mentioned script generation module 930 may include a submodule for determining the element to be tested, a submodule for determining the interaction information, a submodule for determining the sequence, and a script generation submodule. The submodule for determining the element to be tested is used to determine the element to be tested among multiple measurable elements based on the test purpose and the element type. The submodule for determining the interaction information is used to determine the test interaction information for the element to be tested based on the target element template. The submodule for determining the sequence is used to determine the test sequence of the element to be tested based on the element type. The script generation submodule is used to generate a test script for testing the element to be tested based on the test interaction information and the test sequence.

[0131] According to an embodiment of the present disclosure, the device 900 may further include a standard determination module for determining the test standard for the element to be tested based on the target element template. The above-mentioned test module 940 may include a running submodule, a page acquisition submodule and a result determination submodule. The running submodule is used to run the test script. The page acquisition submodule is used to obtain a post-test page for the interactive page to be tested in response to the test script being run. The result determination submodule is used to determine the test result for the interactive page to be tested based on the post-test page and the test standard.

[0132] According to an embodiment of the present disclosure, the result determination submodule may include a sameness determination unit and a page determination unit. The sameness determination unit is configured to determine whether a second DOM tree for the post-test page is the same as a first DOM tree for the interactive page to be tested, in response to the post-test page meeting the test criteria. The page determination unit is configured to determine a test result by using the post-test page as the interactive page to be tested, in response to the second DOM tree being different from the first DOM tree.

[0133] According to an embodiment of the present disclosure, the result determination submodule may further include a new information determination unit, a test unit, and a result determination unit. The new information determination unit is configured to determine whether new test information exists based on the test purpose, element type, and target element template in response to the second DOM tree being the same as the first DOM tree. The test unit is configured to generate a new test script based on the new test information in response to the existence of new test information to test the interactive page to be tested. The result determination unit is configured to determine that the test result is a pass in response to the absence of new test information.

[0134] It should be noted that the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information in the technical solutions disclosed herein comply with relevant laws and regulations, employ necessary confidentiality measures, and do not violate public order and good morals. In the technical solutions disclosed herein, user authorization or consent is obtained before obtaining or collecting user personal information.

[0135] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0136] Figure 10 A schematic block diagram of an example electronic device 1000 that can be used to implement a method for testing interactive pages and / or a method for generating element templates of an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0137] like Figure 10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. Various programs and data required for the operation of the device 1000 can also be stored in the RAM 1003. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0138] Various components in device 1000 are connected to I / O interface 1005, including an input unit 1006, such as a keyboard, mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a magnetic disk, optical disk, etc.; and a communication unit 1009, such as a network card, modem, wireless communication transceiver, etc. The communication unit 1009 allows device 1000 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0139] The computing unit 1001 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as the interactive page testing method and / or the element template generation method. For example, in some embodiments, the interactive page testing method and / or the element template generation method can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the interactive page testing method and / or the element template generation method described above can be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the interactive page testing method and / or the element template generation method in any other appropriate manner (eg, by means of firmware).

[0140] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0141] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0142] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0143] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0144] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0145] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship is established by computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system. It solves the problems of difficult management and poor business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server in a distributed system, or a server integrated with blockchain.

[0146] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0147] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A method for testing an interactive page, comprising: Querying an element template library according to the interactive page to be tested to determine a target element template for the interactive page to be tested; Determining, according to the target element template, the measurable elements included in the interactive page to be tested and the attribute information of the measurable elements; Generating a test script for the interactive page to be tested according to the attribute information; as well as Run the test script to test the interactive page to be tested. Wherein, each element template in the element template library is for an operable element, and each element template includes attribute information of the operable element; The step of querying an element template library according to the interactive page to be tested and determining a target element template for the interactive page to be tested includes: Determining the classes involved in the interactive page to be tested according to the first DOM tree for the interactive page to be tested; Determining a candidate element template in the element template library, wherein the class of the operable element targeted by the candidate element template belongs to the class involved in the interactive page to be tested; and Determine the target element template in the candidate element template according to the class of the element group having a subordinate relationship with the operable element targeted by the candidate element template, The class of the element group having a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

2. The method according to claim 1, wherein The number of the testable elements is multiple; the attribute information includes the element type; and generating a test script for the interactive page to be tested according to the attribute information includes: Determining an element to be measured from among the plurality of measurable elements according to a test purpose and the element type; Determining test interaction information for the element to be tested according to the target element template; Determining the test order of the elements to be tested according to the element types; and A test script for testing the element to be tested is generated according to the test interaction information and the test sequence.

3. The method according to claim 2, wherein: The method further includes: determining a test standard for the element to be tested based on the target element template; The running of the test script to test the interactive page to be tested includes: Running the test script; In response to the test script being executed, obtaining a post-test page for the interactive page to be tested; and A test result for the interactive page to be tested is determined according to the post-test page and the test standard.

4. The method according to claim 3, wherein: Determining the test result for the interactive page to be tested according to the post-test page and the test standard includes: In response to the post-test page satisfying the test criteria, determining whether a second DOM tree for the post-test page is identical to a first DOM tree for the interactive page to be tested; and In response to the second DOM tree being different from the first DOM tree, the post-test page is used as the interactive page to be tested to determine the test result.

5. The method according to claim 4, wherein Determining the test result for the interactive page to be tested based on the post-test page and the test standard further includes: In response to the second DOM tree being identical to the first DOM tree, determining whether new test information exists according to the test purpose, the element type, and the target element template; In response to the existence of new test information, generating a new test script according to the new test information to test the interactive page to be tested; and In response to the absence of new test information, the test result is determined to be a pass.

6. A method for generating an element template, comprising: Detecting a first image for an interactive page, and determining operable elements included in the interactive page and attribute information of the operable elements; as well as For each of the operable elements, generating an element template for each of the operable elements according to the attribute information of each of the operable elements; The method further comprises: Querying an element template library according to the interactive page to be tested to determine a target element template for the interactive page to be tested; Determining, according to the target element template, the measurable elements included in the interactive page to be tested and the attribute information of the measurable elements; Generating a test script for the interactive page to be tested according to the attribute information; The step of querying an element template library according to the interactive page to be tested and determining a target element template for the interactive page to be tested includes: Determining the classes involved in the interactive page to be tested according to the first DOM tree for the interactive page to be tested; Determining a candidate element template in the element template library, wherein the class of the operable element targeted by the candidate element template belongs to the class involved in the interactive page to be tested; and Determine the target element template in the candidate element template according to the class of the element group having a subordinate relationship with the operable element targeted by the candidate element template, The class of the element group having a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

7. The method according to claim 6, further comprising: Dividing the operable elements to obtain at least one element group; The step of generating an element template for each operable element according to the attribute information of each operable element includes: An element template for each of the operable elements is generated according to the attribute information of each of the operable elements and the subordinate relationship between each of the operable elements and the element group.

8. The method according to claim 7, wherein: Dividing the operable elements to obtain at least one element group includes: Determining, based on the DOM tree for the interactive page, a plurality of classes involved in the interactive page and association relationships between the plurality of classes; and Divide the operable elements according to the association relationship to obtain the at least one element group, The multiple classes include the class of the operable elements and the class of the at least one element group; the class of each element group is a parent class of the class of the operable elements included in each element group.

9. The method according to claim 6, wherein: The attribute information includes an element type; and the method further includes: For a first jump type element among the operable elements, running a first predetermined script according to position information of the first element to perform a simulation operation on the interactive page; and In response to the fact that the URL address of the page obtained after the first predetermined script is executed is inconsistent with the URL address of the interactive page, the type of the first element is determined to be the jump type.

10. The method according to claim 6, wherein: The attribute information includes an element type; and the method further includes: For a second element of the input box type in the operable element, randomly generating input information for the second element; executing a second predetermined script according to the input information to assign the input information to the second element; Acquire a second image of the interactive page after the second predetermined script is executed; and determining, according to the input information and the second image, a test standard for the second element and test interaction information for the second element, The element template for the second element is associated with the test standard and the test interaction information.

11. A testing device for an interactive page, comprising: A target determination module is used to query an element template library according to the interactive page to be tested, and determine a target element template for the interactive page to be tested; An element determination module, configured to determine the measurable elements included in the interactive page to be tested and attribute information of the measurable elements according to the target element template; A script generation module, configured to generate a test script for the interactive page to be tested according to the attribute information; as well as A test module is used to run the test script to test the interactive page to be tested. Wherein, each element template in the element template library is for an operable element, and each element template includes attribute information of the operable element; Wherein, the target determination module includes: A class determination submodule, configured to determine the class involved in the interactive page to be tested based on the first DOM tree for the interactive page to be tested; an alternative determination submodule, configured to determine an alternative element template in the element template library, wherein the class of the operable element targeted by the alternative element template belongs to the class involved in the interactive page to be tested; and a target determination submodule, configured to determine a target element template in the candidate element template according to a class of an element group having a subordinate relationship with the operable element targeted by the candidate element template, The class of the element group having a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

12. The device according to claim 11, wherein The number of the measurable elements is multiple; the attribute information includes the element type; The script generation module includes: A to-be-tested determination submodule, configured to determine an element to be tested from among the plurality of testable elements according to a test purpose and the element type; An interaction information determination submodule, configured to determine test interaction information for the element to be tested based on the target element template; A sequence determination submodule, configured to determine the test sequence of the elements to be tested according to the element type; and The script generation submodule is used to generate a test script for testing the element to be tested according to the test interaction information and the test sequence.

13. The apparatus according to claim 12, wherein: The device further includes a standard determination module for determining a test standard for the element to be tested based on the target element template; The test module includes: A running submodule, used to run the test script; a page obtaining submodule, configured to obtain a post-test page for the interactive page to be tested in response to completion of the test script execution; and The result determination submodule is used to determine the test result for the interactive page to be tested according to the post-test page and the test standard.

14. The device according to claim 13, wherein The result determination submodule includes: an identical determining unit, configured to determine, in response to the post-test page satisfying the test criteria, whether the second DOM tree for the post-test page is identical to the first DOM tree for the interactive page to be tested; and The page determining unit is configured to, in response to the second DOM tree being different from the first DOM tree, use the post-test page as the interactive page to be tested to determine the test result.

15. The device according to claim 14, wherein The result determination submodule further includes: a new information determining unit, configured to, in response to the second DOM tree being identical to the first DOM tree, determine whether new test information exists according to the test purpose, the element type, and the target element template; A testing unit, configured to generate a new test script according to the new test information in response to the existence of new test information, so as to test the interactive page to be tested; and The result determination unit is configured to determine, in response to the absence of new test information, that the test result is a pass.

16. A device for generating an element template, comprising: An image detection module, configured to detect a first image of an interactive page, and determine operable elements included in the interactive page and attribute information of the operable elements; as well as A template generating module, configured to generate an element template for each operable element according to attribute information of each operable element; The device further comprises: A target determination module is used to query an element template library according to the interactive page to be tested, and determine a target element template for the interactive page to be tested; An element determination module, configured to determine the measurable elements included in the interactive page to be tested and attribute information of the measurable elements according to the target element template; A script generation module, configured to generate a test script for the interactive page to be tested according to the attribute information; Wherein, the target determination module includes: A class determination submodule, configured to determine the class involved in the interactive page to be tested based on the first DOM tree for the interactive page to be tested; an alternative determination submodule, configured to determine an alternative element template in the element template library, wherein the class of the operable element targeted by the alternative element template belongs to the class involved in the interactive page to be tested; and a target determination submodule, configured to determine a target element template in the candidate element template according to a class of an element group having a subordinate relationship with the operable element targeted by the candidate element template, The class of the element group having a subordinate relationship with the operable element targeted by the target element template belongs to the class involved in the interactive page to be tested.

17. The apparatus according to claim 16, further comprising: an element division module, configured to divide the operable elements into at least one element group; The template generation module is configured to generate an element template for each operable element according to the attribute information of each operable element and the subordinate relationship between each operable element and an element group.

18. The device according to claim 17, wherein The element division module includes: a class determination submodule, configured to determine, based on the DOM tree for the interactive page, a plurality of classes involved in the interactive page and association relationships between the plurality of classes; and a division submodule, configured to divide the operable elements according to the association relationship to obtain the at least one element group, The multiple classes include the class of the operable elements and the class of the at least one element group; the class of each element group is a parent class of the class of the operable elements included in each element group.

19. The device according to claim 16, wherein The attribute information includes an element type; the apparatus further includes: a simulation operation execution module, configured to run a first predetermined script according to position information of a first element of a jump type among the operable elements, so as to perform a simulation operation on the interactive page; and The type determination module is configured to determine that the type of the first element is the jump type in response to the URL address of the page obtained after the first predetermined script is executed being inconsistent with the URL address of the interactive page.

20. The apparatus according to claim 16, wherein The attribute information includes an element type; the apparatus further includes: an information generating module, configured to randomly generate input information for a second element of an input box type in the operable element; an element assignment module, configured to execute a second predetermined script according to the input information to assign the input information to the second element; An image acquisition module is configured to acquire a second image of the interactive page after the second predetermined script is executed; and an information determination module, configured to determine a test standard for the second element and test interaction information for the second element based on the input information and the second image, The element template for the second element is associated with the test standard and the test interaction information.

21. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.

22. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 10.

23. A computer program product comprising a computer program / instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Method and device for generating interface test program, and electronic device

    CN107015903A

  • An automatic test method and a terminal

    CN109783356A

  • Test script automatic generation method, device, computer equipment and storage medium

    CN112685311A