CN114528215A - Interactive page testing method and element template generating method and device - Google Patents

Interactive page testing method and element template generating method and device Download PDF

Info

Publication number
CN114528215A
CN114528215A CN202210154465.7A CN202210154465A CN114528215A CN 114528215 A CN114528215 A CN 114528215A CN 202210154465 A CN202210154465 A CN 202210154465A CN 114528215 A CN114528215 A CN 114528215A
Authority
CN
China
Prior art keywords
test
tested
page
interactive page
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210154465.7A
Other languages
Chinese (zh)
Inventor
陈敏
任彦伟
王亚楠
尹飞
韩照光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202210154465.7A priority Critical patent/CN114528215A/en
Publication of CN114528215A publication Critical patent/CN114528215A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/14Tree-structured documents
    • G06F40/143Markup, e.g. Standard Generalized Markup Language [SGML] or Document Type Definition [DTD]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Abstract

The disclosure provides a testing method of an interactive page, a generating method and device of a plate template, electronic equipment and a storage medium, and relates to the technical field of computers, in particular to the field of code testing and the field of deep learning. The specific implementation scheme of the interactive page testing method is as follows: inquiring an element template library according to the interactive page to be detected, and determining a target element template aiming at the interactive page to be detected; according to the target element template, determining measurable elements and attribute information of the measurable elements included in the interactive page to be detected; generating a test script aiming at the interactive page to be tested according to the attribute information; and running a test script to test the interactive page to be tested, wherein each element template in the element template library is specific to one operable element, and each element template comprises attribute information of the specific operable element.

Description

Interactive page testing method and element template generating method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to the field of code testing technologies and deep learning technologies, and in particular, to a method and an apparatus for testing an interactive page, and a method, an apparatus, a device, and a medium for generating an element template.
Background
In order to guarantee the interactive experience, before the application of the interactive page is provided to be online, the interactive page is generally required to be tested. The cost of generating and maintaining scripts for testing interactive pages will continue to increase as the services involved in the application are iterated and upgraded.
Disclosure of Invention
The present disclosure is directed to a method and apparatus for testing an interactive page with reduced testing cost, and a method, apparatus, device, and medium for generating an element template.
According to one aspect of the present disclosure, a method for testing an interactive page is provided, including: inquiring an element template library according to the interactive page to be detected, and determining a target element template aiming at the interactive page to be detected; according to the target element template, determining measurable elements and attribute information of the measurable elements included in the interactive page to be measured; generating a test script aiming at the interactive page to be tested according to the attribute information; and running a test script to test the interactive page to be tested, wherein each element template in the element template library is specific to one operable element, and each element template comprises attribute information of the specific operable element.
According to another aspect of the present disclosure, there is provided a method for generating an element template, including: detecting a first image aiming at an interactive page, and determining an operable element and attribute information of the operable element included in the interactive page; and generating an element template for each operable element according to the attribute information of each operable element.
According to another aspect of the present disclosure, there is provided a test apparatus for an interactive page, including: the target determining module is used for inquiring the element template library according to the interactive page to be detected and determining a target element template aiming at the interactive page to be detected; the element determining module is used for determining measurable elements and attribute information of the measurable elements included in the interactive page to be detected according to the target element template; the script generation module is used for generating a test script aiming at the interactive page to be tested according to the attribute information; and the test module is used for running a test script to test the interactive page to be tested, wherein each element template in the element template library aims at one operable element, and each element template comprises attribute information of the aimed operable element.
According to another aspect of the present disclosure, there is provided an element template generation apparatus including: the image detection module is used for detecting a first image aiming at the interactive page and determining an operable element and attribute information of the operable element included in the interactive page; and the template generating module is used for generating an element template for each operable element according to the attribute information of each operable element.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method for testing interactive pages and/or the method for generating element templates provided by the present disclosure.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute a method of testing an interactive page and/or a method of generating an element template provided by the present disclosure.
According to another aspect of the present disclosure, there is provided a computer program product comprising computer programs/instructions which, when executed by a processor, implement the method of testing interactive pages and/or the method of generating element templates provided by the present disclosure.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic diagram of an application scenario of a method and an apparatus for testing an interactive page and a method and an apparatus for generating an element template according to an embodiment of the present disclosure;
FIG. 2 is a flow diagram of a method of generating an element template according to an embodiment of the disclosure;
FIG. 3 is a schematic diagram of a method of generating an element template according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a method of generating an element template according to another embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for testing an interactive page according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of determining a target element template according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a method of testing an interaction page according to an embodiment of the present disclosure;
fig. 8 is a block diagram of a structure of an element template generation apparatus according to an embodiment of the present disclosure;
FIG. 9 is a block diagram of a testing apparatus for interactive pages according to an embodiment of the present disclosure; and
fig. 10 is a block diagram of an electronic device for implementing a method for generating an element template and/or a method for testing an interactive page according to an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The present disclosure provides a testing method of an interactive page, which includes a target template determining stage, an element determining stage, a script generating stage and a testing stage. In the stage of determining the target template, the element template library is inquired according to the interactive page to be detected, and the target element template aiming at the interactive page to be detected is determined. In the element determining stage, according to the target element template, the measurable elements and the attribute information of the measurable elements included in the interactive page to be measured are determined. And in the script generation stage, generating a test script aiming at the interactive page to be tested according to the attribute information. And in the test stage, running a test script to test the interactive page to be tested. Wherein each element template in the element template library is directed to one operable element, and each element template comprises attribute information of the directed operable element.
An application scenario of the method and apparatus provided by the present disclosure will be described below with reference to fig. 1.
Fig. 1 is a schematic view of an application scenario of a method for testing an interactive page and a method and an apparatus for generating an element template according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario 100 of this embodiment may include an electronic device 110, and the electronic device 110 may be various electronic devices with processing functionality, including but not limited to a smartphone, a tablet, a laptop, a desktop computer, a server, and so on.
For example, the electronic device 110 may test the interactive page 120 that can be provided by the application to be brought online to determine whether each operable element in the interactive page 120 can respond normally.
For example, the electronic device 110 may be provided with an automated testing tool, and a tester may encode a testing script and run the testing script via the automated testing tool, thereby implementing testing of the operable elements in the interactive page 120.
For example, the electronic device 110 may display the interactive page 120, record interaction operations of the tester on the interactive page 120 through the recording plug-in, and generate an executable test script according to the recorded interaction operations. Testing of the operable elements in the interaction page 120 is then accomplished by running a test script via an automated testing tool.
In an embodiment, the operable elements in the interactive page provided by the on-line application can be analyzed, and an element template can be generated according to the analysis result, and the element template can be used as a basis for testing the interactive page provided by the on-line application. Therefore, in the process of application iterative updating, the test script aiming at the interactive page of the new version application is generated according to the element template, so that the generation efficiency of the test script can be improved, and the generation cost of the test script is reduced.
As shown in fig. 1, the application scenario 100 may further include a server 140, and the server 140 may analyze an interactive page in an online application to generate and maintain an element template library. Each element template in the element template library is defined with attribute information of an operable element. When the electronic device 110 tests the interactive page 120, for example, a matching element template can be searched and obtained from the element template library to serve as the target element template 130. In this way, the electronic device 110 may generate a test script for the interactive page 120 according to the target element template 130 to facilitate testing the interactive page 120.
It should be noted that the method for testing the interactive page provided by the present disclosure may be executed by the electronic device 110, and may also be executed by the server 140. Accordingly, the testing device of the interactive page provided by the present disclosure may be disposed in the electronic device 110, and may also be disposed in the server 140. The generation method of the element template provided by the present disclosure may be performed by the server 140. Accordingly, the generation apparatus of the element template provided by the present disclosure may be provided in the server 140.
It should be understood that the number and type of electronic devices 110 and servers 140 in fig. 1 are merely illustrative. There may be any number and type of electronic devices 110 and servers 140, as desired for an implementation.
The method for generating the element template provided by the present disclosure will be described in detail below with reference to fig. 1 through fig. 2 to 4 below.
Fig. 2 is a flow chart diagram of a method of generating an element template according to an embodiment of the present disclosure.
As shown in fig. 2, the generation method 200 of the element template of this embodiment may include operations S210 to S220.
In operation S210, a first image for an interactive page is detected, and an operable element included in the interactive page and attribute information of the operable element are determined.
According to the embodiment of the disclosure, the interactive page can be opened according to the uniform resource locator URL, and the first image aiming at the interactive page is obtained in a screenshot mode. This embodiment may store the URL in association with the first image. Alternatively, a large number of pre-captured images of the interactive page may be stored in the storage space, and the embodiment may acquire any one of the images from the storage space for detection.
According to an embodiment of the present disclosure, the first image may be detected using an object detection model in which an operable element is a detection target. The training sample of the target detection model may be an image labeled with operable elements. The object detection model may take the first image as input and output a bounding box of operable elements in the first image and a probability that an operable element in the first image belongs to each of a plurality of predetermined classes. Each bounding box of the output represents an actionable element. The embodiment can determine attribute information that a category corresponding to a maximum probability among probabilities of belonging to a plurality of predetermined categories is an operable element. Wherein the bounding box of the actionable element may be represented by position information of the bounding box in the first image, the position information may include a position of a center point of the bounding box in the first image.
The operable element may be any element capable of changing the display content of the page in response to a user operation. For example, the operable elements may include an input box, a page jump button, and the like. In one embodiment, the attribute information may include a type of the operable element, and the plurality of predetermined categories may include an input box type, a jump type, and the like, which are not limited by the present disclosure.
In operation S220, for each actionable element, an element template for each actionable element is generated according to the attribute information of each actionable element.
According to the embodiment of the present disclosure, an element template may be generated for each operable element, attribute information and the like of each operable element are set in the element template, and the element template may use identification information of an element group to which each operable element belongs as an index. Wherein the type of the actionable element may be part of attribute information of the actionable element.
In an embodiment, a check rule or the like may also be set for each operable element according to the type of each operable element. For example, for an operable element of the jump type, the check rule may be that after the interactive operation is performed, the interactive page where the operable element is located jumps to other pages. Alternatively, the URL address of the other page to which the jump is made may be input for the operable element of the jump type, and the like, which is not limited by the present disclosure. By setting the check rule in the element template, richer basis information can be provided for the test of the interactive page.
In an embodiment, the element template may further have position information of the operable element set therein, and the position information may be a part of attribute information of the operable element. Based on the position information, it is convenient to perform a simulation operation on the operable element. The location information may be the center location of the bounding box described earlier.
In summary, the method for generating the element template according to the embodiment of the present disclosure may generate the element template according to a detection result obtained by performing object detection on an image, without manual intervention, and may increase the generation cost of the element template. Furthermore, because the element template is generated for each element, not for the whole interactive page, the element template can be adapted to all the service lines in which the operable elements to which the element template is set, and the coverage of the scene to which the element module is applied can be improved. In addition, because the element is generated according to the attribute information of the operable element, the attribute information of the operable element as reference information can be provided for the test of the interactive page, which is beneficial to reducing the workload required for generating the test script.
According to an embodiment of the present disclosure, before generating the element template, the operable elements may be further divided into at least one element group.
For example, if the number of the operable elements included in the interactive page is multiple. The embodiment can divide the operable elements with close positions into one element group according to the position information of the surrounding frame of the operable elements. For example, for any one operable element, the any one operable element and operable elements having a distance larger than a predetermined distance from the any one operable element are divided into two element groups.
In an embodiment, the actionable elements that an interaction page includes may be divided by class (class). For example, a plurality of classes related to the interactive page and an association relationship between the classes can be determined according to a DOM tree for the interactive page. The actionable elements are then partitioned according to the incidence relation, resulting in at least one element group.
For example, a DOM tree corresponding to a page code source (page source) of an interactive page may embody relationships between elements in the interactive page. Each actionable element corresponds to a node in the DOM tree, the node corresponding to the actionable element having a class, the class that the node has being the class of each actionable element. In general, in the DOM tree, a node corresponding to each operable element has a parent node, and the parent node also has a class, and this embodiment may divide operable elements corresponding to a plurality of nodes having the same parent node into one element group, and use the class that the parent node has as the class of the divided element group. As such, the plurality of classes referred to by the interaction page includes a class of actionable elements and a class of at least one element group. And the class of each element group is a parent class of the actionable element that each element group includes.
Accordingly, this embodiment can use the class name of the class of the operable element as the identification information of each element plate. Thus, when the interactive page needs to be tested, the target element template for the interactive page can be determined according to the class name related to the interactive page.
In one embodiment, when generating the element template, the attribute information of the operable elements and the dependency relationship between the operable elements and the element groups can also be considered at the same time. For example, attribute information of an operable element is taken as content of an element template, a class name of a class of the operable element is taken as identification information of the element template, and an association relationship between the element template and the class name of the class of an element group to which the operable element belongs is established. By dividing the operable elements according to the parent-child relationship of the class, the operable elements in different service plates can be effectively distinguished under the condition that the same operable elements are arranged in different service plates, so that more accurate reference information can be provided for the test of the interactive page, and the test precision of the interactive page can be improved.
It is to be understood that, before generating the element template, for example, the area of the interactive page where each operation element is located may be marked in the first image in advance. And then, associating the detected operable elements with the operable elements corresponding to the nodes in the DOM tree according to the position relationship between the position information of the bounding box obtained by detecting the first image and the area where each operating element is positioned.
FIG. 3 is a schematic diagram of a method of generating an element template according to an embodiment of the present disclosure.
According to the embodiment of the present disclosure, the detected attribute information includes a type of the operable element. In the embodiment, after the type of the operable element is determined to be the skip type by detecting the first image, the type of the operable element can be verified by simulation operation, so that the accuracy of the determined type of the operable element is improved, and the accuracy of the generated plate template and the accuracy of the interactive page tested according to the plate template are improved.
Illustratively, for a first element of the jump type determined by detecting the first image, a first predetermined script may be executed according to position information of the first element. By executing the first predetermined script, a simulation operation may be performed on a first element in the interactive page. According to whether the URL address of the page displayed after the simulation operation (namely the page obtained after the first preset script is operated) is consistent with the URL address of the interactive page, whether the interactive page jumps after the simulation operation is performed on the first element can be determined. 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, the interactive page is 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. The simulation operation performed on the first element may be, for example, a click operation, and the first predetermined script may be written in a language such as python, which is not limited in this disclosure.
Illustratively, whether or not jumping occurs may also be determined according to a difference between a page displayed after the simulation operation and an interactive page displayed before the simulation operation. For example, if the difference ratio between two pages exceeds a predetermined ratio, it may be determined that jumping has occurred. Wherein the predetermined ratio may be 60%, 80%, 90%, etc., which is not limited by the present disclosure.
As shown in fig. 3, when generating an element template for an interactive page 310, the embodiment 300 may first perform screenshot on 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 interaction page 310 may be crawled. Subsequently, the object detection model 320 may be used to perform object detection on the first image 311, so as to obtain the position information and the type of the operable element included in the interactive page 310. The page source code may be analyzed to generate a DOM tree 312, and according to the association relationship between the nodes in the DOM tree 312, determine the operable elements with the same parent class in the detected operable elements, so as to obtain at least one element group 330 through division, and finally, generate an element template 340 for each operable element according to the at least one element group 330, the position information and the type of the operable element, and store the generated element template 340 in the relational database 350.
It should be noted that, for an operable element of the jump type detected by the target detection model 320, the first predetermined script is executed according to the position information of the operable element, so as to verify the type of the operable element. After the verification is completed, the element template is regenerated.
Fig. 4 is a schematic view of a method of generating a plate template according to another embodiment of the present disclosure.
According to the embodiment of the disclosure, when the plate template is generated, the value can be randomly assigned according to the second element of the input box type in the operable element, and the change of the page after the value is assigned to the second element is determined. Since the second element is an element in the interactive page of the online application, the change of the page after assignment can reflect the response brought by the interactive operation performed on the second element. The embodiment may determine the test criteria based on the assigned value for the second element and the assigned page.
For example, the embodiment may determine the second element according to the detection result obtained by the detection of the first page. The input information may be randomly generated for the second element, and the type of the input information may include, for example, a numeric type, an alphabetical type, a literal type, a special symbol type, or a numeric plus alphabetical type, which is not limited in this disclosure. For example, the embodiment may employ any method to randomly generate the input information, which is not limited by the present disclosure.
Upon obtaining the input information, the embodiment may execute a second predetermined script based on the input information to assign the input information to the second element. When the second predetermined script is executed, for example, a simulation operation may be performed on a second element in the interactive page, and the input information may be input into the second element through the simulation operation. The second predetermined script may be written in a language such as python, which is not limited by this disclosure. After the second predefined script is run, the input information is assigned to the second element, and in particular the second element is filled in with the input information. At this time, the embodiment may perform screenshot on the interactive page after the second predetermined script is run, so as to obtain a second image of the interactive page.
After obtaining the second image, the embodiment may determine the test criteria for the second element and the test interaction information for the second element according to the input information and the second image. The input information may be used as test interaction information, and the second image may be used as a test standard matched with the test interaction information. For example, if the input information matched with the second element is a number type and the input information randomly generated for the second element is a number type, the second element of the second image includes the randomly generated input information, and the peripheral area of the second element has a mark indicating correct input, compared with the first image, the test interaction information may be the input information of the number type in the second element, and the test criterion for the test interaction information is to display the mark indicating correct input. The indication indicating that the input is correct may be, for example, a "check" symbol, and the like, which is not limited in this disclosure. Alternatively, if the input information matched with the second element is a numeric type but the input information randomly generated for the second element is an alphabetic type, the second element of the second image includes the randomly generated input information compared to the first image, and the peripheral area of the second element has a flag indicating an input error, the test interaction information may be the input information of the numeric type in the second element, and the test criterion for the test interaction information is to display the flag indicating the input error.
In an embodiment, an association relationship between the element template of the second element and the test standard may be established, and an association relationship between the element template of the second element and the test interaction information may be established. Therefore, when the test script aiming at the interactive page to be tested is generated, the test interaction information and the test standard can be searched according to the target element template, the test interaction information can be used as a basis for generating the test script, and the test standard can be used as a basis for determining the test result. Therefore, the automation degree of the test interaction page is improved, and the test cost is further reduced.
In an embodiment, the second element may be further searched by traversing the DOM tree, and the test standard and the test interaction information for the second element are obtained.
As shown in fig. 4, in the process of generating the element template, the embodiment 400 may perform operation S410 to open the interactive page according to the URL address of the interactive page. Operation S420 may then be performed to parse the page source of the interaction page, thereby obtaining a DOM tree for the interaction page. Subsequently, operation S430 can be performed to traverse the DOM tree, resulting in operable elements in the interaction page. It may be determined whether the operable element is an input box through operation S440. If so, the operation S450 is continued, otherwise, the operation S430 is returned to, so as to traverse the other operable elements. In operation S440, the traversed operable element may be located to the detected operable element, and determine whether the traversed operable element is the input box according to the type of the located detected operable element. The detected operable element may be located, for example, according to whether the center of the bounding box of the operable element detected by the target falls within the region in which the traversed operable element is located.
The input information is then randomly generated for the operable elements belonging to the input box through operation S450. After the input information is generated, a second predetermined script is executed to assign the input information to the actionable element and acquire a second image of the interactive page through operation S460.
In an embodiment, after the second image is obtained, the second image may be further processed to intercept an area image from the second image, where the area image is capable of reflecting a response result of the interactive page after the second element is assigned with the input information.
Subsequently, the embodiment 400 may analyze a difference between the second image and the first image and determine a test criterion for the operable element according to the difference through operation S470. For example, the difference between the region image cut out from the second image and the corresponding region image in the first image may be used as a test criterion.
After the operation S470 is performed, it may be determined whether the DOM tree is traversed through the operation S480, if not, the operation S430 is returned to be performed, and if so, the determination process of the test standard of the input box is completed.
According to the embodiment of the disclosure, after the process of determining the test standard and the test interaction information of the second element is completed, the embodiment may establish an association relationship between the generated element template of the second element and the test standard and the test interaction information, and complete the generation process of the element template.
According to the embodiment of the disclosure, after the generation process of the element template of the embodiment of the disclosure is executed for a large number of interactive pages, a plurality of element templates can be obtained, and the element templates can be stored in a relational database in a table form, so as to obtain an element template library.
Based on the element template library generated by the embodiment of the present disclosure, the present disclosure also provides a method for testing an interactive page, which will be described in detail below with reference to fig. 5 to 7.
Fig. 5 is a flowchart illustrating a method for testing an interactive page according to an embodiment of the present disclosure.
As shown in fig. 5, the method 500 for testing an interactive page of this embodiment may include operations S510 to S540.
In operation S510, the element template library is queried according to the interactive page to be tested, and a target element template for the interactive page to be tested is determined.
According to the embodiment of the disclosure, the DOM tree of the interactive page to be tested can be traversed to obtain the class related to the interactive page to be tested. And then, taking the element template with the class name of the class related to the interactive page to be tested as the identification information as a target element template.
According to the foregoing element template generation method, each element template in the element template library is directed to one operable element, and each element template includes attribute information of the operable element to which it is directed.
In operation S520, according to the target element template, measurable elements and attribute information of the measurable elements included in the interactive page to be tested are determined.
According to the embodiment of the disclosure, the class name according to which the target element template is queried can be determined, the element of which the class is the class name in the interactive page to be tested is a measurable element, and the attribute information included in the target element template is the attribute information of the measurable element. This is because in different interactive pages, elements with the same class name usually have the same attribute information, and the attribute information in the target element template can be directly used as the attribute information of the measurable element.
In operation S530, a test script for the interactive page to be tested is generated according to the attribute information.
According to an embodiment of the present disclosure, the attribute information may include, for example, types of operable elements, for which different types of operable elements correspond to different simulation operations. According to the embodiment, the simulation operation of the corresponding target element template can be determined according to the attribute information, and then the pre-generated script aiming at the simulation operation is used as the test script of the interactive page to be tested. In the embodiment, under the condition that the interactive page to be tested includes a plurality of operable elements, a plurality of scripts for simulation operation can be obtained for the plurality of operable elements, and then the plurality of scripts for simulation operation are sequentially connected to obtain a test script for the interactive page to be tested.
In an embodiment, the attribute information may further include position information of the operable element, and the embodiment may use the position information as a value of a variable in the script for simulating the operation, so as to obtain the test script.
In an embodiment, associated test interaction information may also be obtained from the element template library according to the target element template, and the test interaction information may include input information. For the operable elements of the input box type, the embodiment can take the position information and the input information as values of variables in the script for simulating the operation, so as to obtain the test script.
In operation S540, a test script is executed to test the interactive page to be tested.
According to the embodiment, the test script can be operated by the automatic test platform, and the test result of the interactive page to be tested is determined by analyzing the page obtained after the test script is operated.
For example, the associated test criteria may be retrieved from a library of element templates based on the target element template. And determining the due change of the page obtained after the test script is run relative to the interactive page to be tested according to the test standard. And if the actual change of the page relative to the interactive page to be tested, which is obtained after the test script is run, is the same as the due change, determining that the interactive page to be tested passes the test. If the actual change is different from the due change, it can be determined that the interactive page to be tested does not pass the test.
In an embodiment, the method for testing the interactive page of the embodiment may be performed by a preset API interface. For example, a DOM API may be set, configured to analyze a page source of the interactive page to be detected, generate a DOM tree according to the page source, analyze the DOM tree to obtain a class related to the interactive page to be detected, and query the element template library according to the class related to the DOM tree, so as to obtain the attribute information of the target element template and the measurable element. For example, an ACTION API may be provided for generating a test script for implementing a simulation operation based on attribute information of a measurable element.
In summary, the test method according to the embodiment of the present disclosure can generate the test script according to the attribute information in the element template, that is, for the middle stage, the automatic generation of the test script can be realized only by maintaining the element template, so that the generation efficiency of the test script can be improved, and the generation cost can be reduced. And because the templates in the element template library are specific to a single operable element, the test method of the embodiment can be applied to various scenes, and the robustness of the test method is high.
FIG. 6 is a schematic diagram of determining a target element template according to an embodiment of the present disclosure.
According to the embodiment of the disclosure, when the element template in the element template library has the association relationship with the class name of the class of the element group to which the operable element belongs, the element in the interactive page to be tested can be screened according to the class of the element group, so that the measurable element can be obtained. Therefore, the condition that the service plate corresponding to the determined target element template is different from the service plate to which the interactive page to be tested belongs can be avoided, the precision of the determined generated test script can be improved, and the test precision of the interactive page can be improved.
As shown in fig. 6, in the embodiment 600, when determining the target element template, the class to which the interactive page to be detected relates may be determined according to the first DOM tree 610 for the interactive page to be detected, where the class to which the interactive page to be detected relates may include, for example, classes 620_1 to 620_ n, and n classes are total. For example, the embodiment may traverse the first DOM tree 610, and take the classes that all nodes in the first DOM tree 610 have as the classes to which the interactive page to be tested relates.
The embodiment may then query the element template library 630 from classes 620_1 through 620_ n to determine alternative element templates 640 in the element template library. Specifically, the class 620_1 to the class 620_ n may be used as query conditions, and the element template in the element template library, which uses the query conditions as identification information, is obtained through query and is used as the candidate element template. That is, the class of the operable element targeted by the alternative element template belongs to the class referred to by the interactive page to be tested.
Subsequently, the element group to which the operable element targeted by the alternative element template 640 belongs can be determined. I.e., to determine the set of elements that have an affiliation with the alternative element template 640. It is then determined whether the class of the element group belongs to the class to which the interactive page to be tested relates. The element group belonging to the class referred to by the interactive page to be tested may be used as the target element group 650, and the template of the operable element belonging to the target element group in the alternative element template 640 may be used as the target element template 660. In this way, the class of the element group having an affiliation with the operable element targeted by the target element template belongs to the class to which the interactive page to be tested relates.
According to the embodiment of the present disclosure, in the case where the number of measurable elements is plural, a part of measurable elements may be screened for a test according to the test purpose. For example, if the measurable elements include elements provided by a plurality of business functions and the test is performed only on the target business function, the elements provided by the target business function may be screened from the measurable elements as the elements to be tested.
In an embodiment, the test purpose may be to test only a specific type of operable element, and the embodiment may further determine the element to be tested in the plurality of measurable elements according to the test purpose and the element type. Therefore, the testing method of the interactive page can better fit the testing purpose, and the testing precision and the fine design of the testing method are improved.
In an embodiment, when there are a plurality of elements to be tested, a test sequence may be set for the elements to be tested according to the element types, so as to avoid a situation that the interactive page to be tested jumps to other pages when a certain element to be tested is not yet tested, and thus ensure that the elements to be tested are all tested.
For example, when generating a test script, the embodiment may first determine an element to be tested of a plurality of testable elements according to a test purpose and an element type. And then determining the test interaction information aiming at the element to be tested according to the target element template. And determining the test sequence of the elements to be tested according to the element types. And finally, generating a test script for testing the element to be tested according to the test interaction information and the test sequence.
Specifically, after the test interaction information of the element to be tested is obtained, the embodiment may generate the test script for each element to be tested according to the test interaction information and the template of the simulation operation. And then, according to the test sequence of the elements to be tested, sequentially connecting the test scripts aiming at the elements to be tested, thereby obtaining the test script aiming at the interactive page to be tested.
When the interactive information is determined, the element template of the element to be tested in the target element template can be determined first, and the test interactive information associated with the element template of the element to be tested in the element template library is used as the test interactive information for the element to be tested. When the test sequence is determined, the elements to be tested with the element type being the skip type can be ranked at the end, and the elements to be tested with other types can be randomly sequenced. Or, the elements to be tested of other types may be sorted according to the order of the nodes corresponding to the elements to be tested from left to right in the first DOM tree, which is not limited in this disclosure.
According to the embodiment of the disclosure, when the interactive page is tested, the embodiment can also determine the test standard for the element to be tested according to the target element template. Specifically, the test standard associated with the target element template is queried from the element template library. After the test script is run, the tested page of the interactive page to be tested can be obtained after the test script is run. Therefore, the test result of the interactive page to be tested can be determined according to the tested page and the test standard.
It is to be understood that, in the case where there are a plurality of elements to be tested, the embodiment can obtain a test standard for each element to be tested. After the test script for each element to be tested is run, a tested page can be obtained, the tested page is compared with a page before the test script for each element to be tested is run, whether the difference of the two pages obtained by comparison meets the test standard for each element to be tested is determined, and if the difference meets the test standard, the test result of each element to be tested is determined to be passed. And under the condition that the elements to be tested pass the test, determining the test result of the interactive page to be tested as a pass test. Therefore, under the condition that the interactive page to be tested does not pass the test, the operable elements which cannot be accurately responded can be quickly positioned.
The embodiment determines the test result by determining the test standard, and can further improve the test automation degree of the interactive page.
FIG. 7 is a schematic diagram illustrating a method for testing an interactive page according to an embodiment of the present disclosure.
According to the embodiment of the disclosure, when the interactive page to be tested is tested, if the interactive page to be tested includes the lower level pages, all the lower level pages are generally required to be tested, so that the integrity of the test is ensured. If the interactive page to be tested has a sub-page, the sub-page is usually required to be tested.
For example, whether the interaction page to be tested has a lower level page or a sub-page may be determined according to whether the DOM tree of the tested page is changed compared with the DOM tree of the interaction page to be tested. Specifically, when determining the test result for the interactive page to be tested, the embodiment may first determine whether the tested page meets the test standard, specifically, whether the difference between the tested page and the interactive page to be tested meets the test standard. And if the test standard is met, acquiring the page source code of the tested page, and generating a second DOM tree according to the page source code of the tested page, wherein the second DOM tree is the DOM tree for the tested page. And then determining 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 passed. If the two DOM trees are different, the tested page can be used as the interactive page to be tested, the element template library is returned to be inquired again to test the tested page until the DOM tree of the tested 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. By the embodiment, the complete test of the interactive page to be tested can be realized, and the improvement of the test automation degree is facilitated.
In an embodiment, where the second DOM tree is consistent with the first DOM tree, the embodiment may determine whether new test information exists according to a test purpose, an element type, and a target element template. And under the condition that new test information exists, generating a new test script according to the new test information to test the interactive page to be tested again until no new test information exists. This is because the test purpose may be multiple in one test. Even in the case where the test purpose is one, the number of elements of the jump type involved in the test purpose may be plural. In order to avoid incomplete implementation of the test purpose or the situation that the page jumps due to the test of one jump type element and the test of other jump type elements cannot be performed, the embodiment can determine whether new test information exists. The test information may correspond to a test combination, and the test combination is a combination of the elements to be tested determined according to the test purpose. For example, if the test purpose is two, the elements to be tested involved in each test purpose may be configured into a test combination. For example, if the elements of the jump type are two, the elements of the two jump types may be divided into two test combinations.
When a new test script is generated according to the new test information, the attribute information may be determined by determining the template of the candidate element template for the element to be tested in the new test information according to the element to be tested included in the new test information, and the test script may be generated according to the attribute information.
By the test method of the embodiment, the test integrity of the interactive page to be tested can be improved, and the test purpose is achieved.
In an embodiment, a CONTENT API may be preset, and the test information may be generated by calling the CONTENT API. For example, the DOM API described above may also be called to generate a DOM tree of the interactive page to be tested, and obtain the attribute information of the target element template and the measurable elements. The ACTION API described above may also be called to generate a test script.
Accordingly, as shown in fig. 7, when testing the interactive page to be tested, the embodiment 700 may first perform operation S710 to open and render the interactive page to be tested according to the URL address, so as to open the interactive page to be tested. DOM API 711 can then be called to determine the measurable elements and attribute information for the measurable elements. The CONTENT API 712 may then be called to generate a test message, i.e., to determine the element to be tested. The ACTION API 713 is then invoked to generate a test script for the element under test to test the interactive page under test. After the test, it may be determined whether the DOM tree of the tested page is consistent with the DOM tree of the interactive page to be tested through operation S720. And if the page is not consistent with the interaction page to be tested, the tested page is taken as the interaction page to be tested, and the DOM API 711-ACTION API 713 are called again to test the tested page. If so, the CONTENT API 712 is called to obtain new test information. And determines whether new test information is acquired through operation S730. If the interaction page is acquired, the ACTION API 713 is returned to be called again to generate a new test script, and the interaction page to be tested is tested according to the new test script. And completing the test of the interactive page to be tested until no new test information exists.
Based on the method for generating the element template provided by the present disclosure, the present disclosure also provides an element template generation apparatus, which will be described in detail below with reference to fig. 8.
Fig. 8 is a block diagram of a structure of an element template generation apparatus according to an embodiment of the present disclosure.
As shown in fig. 8, the generation apparatus 800 of the element template of this embodiment may include an image detection module 810 and a template generation module 820.
The image detection module 810 is configured to detect a first image of an interactive page, and determine an operable element included in the interactive page and attribute information of the operable element. In an embodiment, the image detection module 810 may be configured to perform the operation S210 described above, which is not described herein again.
The template generating module 820 is configured to generate an element template for each operable element according to the attribute information of each operable element. In an embodiment, the template generating module 820 may be configured to perform the operation S220 described above, which is not described herein again.
According to an embodiment of the present disclosure, the apparatus 800 may further include an element dividing module configured to divide the operable elements into at least one element group. The template generating module 820 is configured to generate an element template for each operable element according to the attribute information of each operable element and the dependency relationship between each operable element and the element group.
According to an embodiment of the present disclosure, the element partitioning module may include a class determination submodule and a partitioning submodule. The class determination submodule is used for determining a plurality of classes related to the interactive page and the association relation among the classes according to the DOM tree aiming at the interactive page. The dividing submodule is used for dividing the operable elements according to the incidence relation to obtain at least one element group. Wherein the plurality of classes includes a class of actionable elements and a class of at least one element group; the class of each element group is a parent of the class of the operable element included in each element group.
According to an embodiment of the present disclosure, the attribute information includes an element type, and the apparatus 800 may further include a simulation operation execution module and a type determination module. And the simulation operation execution module is used for executing a first preset script aiming at a first element of a jump type in the operable elements according to the position information of the first element so as to execute a simulation operation on the interactive page. The type determining module is used for determining that the type of the first element is the jump type in response to the fact that the URL address of the page obtained after the first preset script is operated is not consistent with the URL address of the interactive page.
According to an embodiment of the present disclosure, the attribute information includes an element type. The apparatus 800 may further include an information generation module, an element assignment module, an image acquisition module, and an information determination module. The information generation module is used for randomly generating input information aiming at a second element of the input box type in the operable elements. The element assignment module is used for executing a second predetermined script according to the input information so as to assign the input information to a second element. The image acquisition module is used for acquiring a second image of the interactive page after the second preset script is operated. The information determination module is used for determining a test standard aiming at the second element and test interaction information aiming at the second element according to the input information and the second image. Wherein the element template for the second element is associated with the test criteria and the test interaction information.
Based on the method for testing the interactive page provided by the present disclosure, the present disclosure also provides a device for testing the interactive page, which will be described in detail below with reference to fig. 9.
Fig. 9 is a block diagram of a structure of a test apparatus for interactive pages according to an embodiment of the present disclosure.
As shown in fig. 9, the testing apparatus 900 of the interactive page of this embodiment may include a targeting module 910, an element determining module 920, a script generating module 930, and a testing module 940.
The target determining module 910 is configured to query the element template library according to the interactive page to be tested, and determine a target element template for the interactive page to be tested. Wherein, each element template in the element template library is specific to an operable element, and each element template comprises attribute information of the specific operable element. In an embodiment, the target determining module 910 may be configured to perform the operation S510 described above, which is not described herein again.
The element determining module 920 is configured to determine, according to the target element template, measurable elements and attribute information of the measurable elements included in the interactive page to be detected. In an embodiment, the element determining module 920 may be configured to perform the operation S520 described above, which is not described herein again.
The script generating module 930 is configured to generate a test script for the interactive page to be tested according to the attribute information. In an embodiment, the script generating module 930 may be configured to perform the operation S530 described above, which is not described herein again.
The test module 940 is configured to run a test script to test the interactive page to be tested. In an embodiment, the test module 940 may be configured to perform the operation S540 described above, and is not described herein again.
According to an embodiment of the present disclosure, the target determination module 910 may include a class determination sub-module, an alternative determination sub-module, and a target determination sub-module. And the class determination submodule is used for determining the class related to the interactive page to be detected according to the first DOM tree aiming at the interactive page to be detected. And the alternative determining submodule is used for determining an alternative element template in the element template library, and the class of the operable element aimed at by the alternative element template belongs to the class related to the interactive page to be tested. And the target determining submodule is used for determining a target element template in the alternative element templates according to the class of the element group which has the dependency relationship with the operable element aimed at by the alternative element template. And the class of the element group with the dependent relation with the operable element aimed at by the target element template belongs to the class related to the interactive page to be tested.
According to an embodiment of the present disclosure, the number of measurable elements is plural, and the attribute information includes an element type. The script generating module 930 may include a to-be-tested determining sub-module, an interaction information determining sub-module, a sequence determining sub-module, and a script generating sub-module. And the to-be-tested determining submodule is used for determining the to-be-tested elements in the plurality of measurable elements according to the test purpose and the element types. And the interactive information determining submodule is used for determining the test interactive information aiming at the element to be tested according to the target element template. The sequence determining submodule is used for determining the test sequence of the elements to be tested according to the element types. And the script generation submodule is used for generating a test script for testing the element to be tested according to the test interaction information and the test sequence.
According to an embodiment of the present disclosure, the apparatus 900 may further include a standard determination module, configured to determine a test standard for the element to be tested according to the target element template. The test module 940 may include an operation sub-module, a page obtaining sub-module, and a result determination sub-module. The operation submodule is used for operating the test script. And the page obtaining submodule is used for responding to the completion of the running of the test script and obtaining a tested page aiming at the interactive page to be tested. And the result determining submodule is used for determining a test result aiming at the interactive page to be tested according to the tested page and the test standard.
According to an embodiment of the present disclosure, the result determination sub-module may include the same determination unit and the page determination unit. The same determining unit is used for responding to the fact that the tested page meets the testing standard and determining whether the second DOM tree for the tested page is the same as the first DOM tree for the interactive page to be tested. And the page determining unit is used for responding that the second DOM tree is different from the first DOM tree, and taking the tested page as an interactive page to be tested so as to determine a test result.
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. And the new information determining unit is used for responding to the second DOM tree being the same as the first DOM tree and determining whether new test information exists according to the test purpose, the element type and the target element template. And the test unit is used for responding to the existence of new test information and generating a new test script according to the new test information so as to test the interactive page to be tested. The result determining unit is used for responding to the absence of new test information and determining that the test result is a pass test.
In the technical scheme of the present disclosure, the processes of collecting, storing, using, processing, transmitting, providing, disclosing and applying the personal information of the related users all conform to the regulations of related laws and regulations, and necessary security measures are taken without violating the good customs of the public order. In the technical scheme of the disclosure, before the personal information of the user is acquired or collected, the authorization or the consent of the user is acquired.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 10 illustrates a schematic block diagram of an example electronic device 1000 that may be used to implement the testing methods of interactive pages and/or the generation methods of element templates of embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 10, the apparatus 1000 includes a computing unit 1001 that 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. In the RAM1003, various programs and data necessary for the operation of the device 1000 can also be stored. The calculation unit 1001, the ROM 1002, and the RAM1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
A number of components in device 1000 are connected to I/O interface 1005, including: an input unit 1006 such as a keyboard, a mouse, and the like; an output unit 1007 such as various types of displays, speakers, and the like; a storage unit 1008 such as a magnetic disk, an optical disk, or the like; and a communication unit 1009 such as a network card, a modem, a wireless communication transceiver, or the like. The communication unit 1009 allows the device 1000 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
Computing unit 1001 may be a variety of general and/or special purpose 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 running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 1001 executes the respective methods and processes described above, such as the test method of the interactive page and/or the generation method of the element template. For example, in some embodiments, the method of testing of the interaction page and/or the method of generating the element template may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 1000 via ROM 1002 and/or communications unit 1009. When the computer program is loaded into the RAM1003 and executed by the computing unit 1001, one or more steps of the above-described method for testing an interactive page and/or method for generating an element template may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform the test method of the interaction page and/or the generation method of the element template by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, 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 may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, 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: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The Server may be a cloud Server, which is also called a cloud computing Server or a cloud host, and is a host product in a cloud computing service system, so as to solve the defects of high management difficulty and weak service extensibility in a traditional physical host and a VPS service ("Virtual Private Server", or simply "VPS"). The server may also be a server of a distributed system, or a server incorporating a blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (25)

1. A test method of an interactive page comprises the following steps:
inquiring an element template library according to an interactive page to be detected, and determining a target element template aiming at the interactive page to be detected;
according to the target element template, determining measurable elements and attribute information of the measurable elements included in the interactive page to be detected;
generating a test script aiming at 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 is directed to one operable element, and each element template comprises attribute information of the directed operable element.
2. The method of claim 1, wherein the querying an element template library from an interaction page to be tested, and determining a target element template for the interaction page to be tested comprises:
determining a class related to the interactive page to be detected according to the first DOM tree aiming at the interactive page to be detected;
determining an alternative element template in the element template library, wherein the class of an operable element aimed at by the alternative element template belongs to the class related to the interactive page to be tested; and
determining a target element template in the alternative element templates according to the class of the element group having an affiliation with the operable element for which the alternative element template is directed,
and the class of the element group with the dependency relationship with the operable element aimed at by the target element template belongs to the class related to the interactive page to be tested.
3. The method of claim 1, wherein the number of measurable elements is plural; the attribute information includes an element type; the generating of the test script for the interactive page to be tested according to the attribute information comprises:
determining an element to be tested in the measurable elements according to a test purpose and the element type;
determining test interaction information aiming at the element to be tested according to the target element template;
determining the test sequence of the elements to be tested according to the element types; and
and generating a test script for testing the element to be tested according to the test interaction information and the test sequence.
4. The method of claim 3, wherein:
the method further comprises the following steps: determining a test standard aiming at the element to be tested according to the target element template;
the running of the test script to test the interactive page to be tested comprises the following steps:
running the test script;
responding to the completion of the running of the test script, and obtaining a tested page aiming at the interactive page to be tested; and
and determining a test result aiming at the interactive page to be tested according to the tested page and the test standard.
5. The method of claim 4, wherein the determining, according to the post-test page and the test criteria, a test result for the interactive page to be tested comprises:
in response to the tested page meeting the test standard, determining whether a second DOM tree for the tested page is the same as a first DOM tree for the interactive page to be tested; and
and in response to that the second DOM tree is different from the first DOM tree, taking the tested page as an interactive page to be tested so as to determine the test result.
6. The method of claim 5, wherein the determining a test result for the interactive page to be tested according to the post-test page and the test criteria further comprises:
responding to the second DOM tree is the same as the first DOM tree, and determining whether new test information exists according to the test purpose, the element type and the target element template;
responding to the existence of new test information, and generating a new test script according to the new test information so as to test the interactive page to be tested; and
in response to the absence of new test information, determining the test result as a pass test.
7. A method for generating an element template, comprising:
detecting a first image aiming at an interactive page, and determining an operable element included in the interactive page and attribute information of the operable element; and
and generating an element template for each operable element according to the attribute information of each operable element.
8. The method of claim 7, further comprising:
dividing the operable elements to obtain at least one element group;
wherein generating an element template for each of the actionable elements according to the attribute information of each of the actionable elements comprises:
and generating an element template for each operable element according to the attribute information of each operable element and the membership between each operable element and the element group.
9. The method of claim 8, wherein said partitioning said operable elements into at least one element group comprises:
determining a plurality of classes related to the interactive page and an association relation among the classes according to a DOM tree aiming at the interactive page; and
dividing the operable elements according to the incidence relation to obtain the at least one element group,
wherein the plurality of classes includes a class of the actionable element and a class of the at least one element group; the class of each element group is a parent class of the actionable element that each element group includes.
10. The method of claim 7, wherein the attribute information includes an element type; the method further comprises the following steps:
for a first element of the jump type in the operable elements, running a first preset script according to the position information of the first element so as to execute simulation operation on the interactive page; and
and determining the type of the first element as the jump type in response to the fact that the URL address of the page obtained after the first preset script is executed is not consistent with the URL address of the interactive page.
11. The method of claim 7, wherein the attribute information includes an element type; the method further comprises the following steps:
for a second element of the input box type in the operable elements, 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;
acquiring a second image of the interactive page after the second preset script is operated; and
determining, from the input information and the second image, a test criterion for the second element and test interaction information for the second element,
wherein an element template for the second element is associated with the test criteria and the test interaction information.
12. A device for testing interactive pages, comprising:
the target determining module is used for inquiring an element template library according to the interactive page to be detected and determining a target element template aiming at the interactive page to be detected;
the element determining module is used for determining measurable elements and attribute information of the measurable elements included in the interactive page to be detected according to the target element template;
the script generation module is used for generating a test script aiming at the interactive page to be tested according to the attribute information; and
the test module is used for running the test script to test the interactive page to be tested,
wherein each element template in the element template library is directed to one operable element, and each element template comprises attribute information of the directed operable element.
13. The apparatus of claim 12, wherein the targeting module comprises:
the class determination submodule is used for determining a class related to the interactive page to be detected according to the first DOM tree aiming at the interactive page to be detected;
the alternative determining submodule is used for determining an alternative element template in the element template library, and the class of the operable element aimed at by the alternative element template belongs to the class related to the interactive page to be tested; and
a target determination sub-module, configured to determine a target element template in the alternative element templates according to a class of an element group having a dependency relationship with an operable element for which the alternative element template is intended,
and the classes of the element groups having the dependency relationship with the operable elements aimed at by the target element template belong to the classes referred to by the interactive page to be tested.
14. The apparatus of claim 12, wherein the number of measurable elements is plural; the attribute information includes an element type; the script generation module comprises:
the to-be-tested determining submodule is used for determining to-be-tested elements in the measurable elements according to the test purpose and the element types;
the interactive information determining submodule is used for determining the test interactive information aiming at the element to be tested according to the target element template;
the sequence determination submodule is used for determining the test sequence of the elements to be tested according to the element types; and
and the script generation submodule is used for generating a test script for testing the element to be tested according to the test interaction information and the test sequence.
15. The apparatus of claim 14, wherein:
the device also comprises a standard determining module used for determining a test standard aiming at the element to be tested according to the target element template;
the test module includes:
the operation submodule is used for operating the test script;
the page obtaining submodule is used for responding to the completion of the running of the test script and obtaining a tested page aiming at the interactive page to be tested; and
and the result determining submodule is used for determining a test result aiming at the interactive page to be tested according to the tested page and the test standard.
16. The apparatus of claim 15, wherein the result determination submodule comprises:
the same determining unit is used for responding to the fact that the tested page meets the testing standard, and determining whether a second DOM tree for the tested page is the same as a first DOM tree for the interactive page to be tested; and
and the page determining unit is used for responding that the second DOM tree is different from the first DOM tree, and using the tested page as an interactive page to be tested so as to determine the test result.
17. The apparatus of claim 16, wherein the result determination sub-module further comprises:
a new information determining unit, configured to determine whether new test information exists according to the test purpose, the element type, and the target element template in response to that the second DOM tree is the same as the first DOM tree;
the testing unit is used for responding to the existence of new testing information and generating a new testing script according to the new testing information so as to test the interactive page to be tested; and
and the result determining unit is used for responding to the absence of new test information and determining the test result as a pass test.
18. An apparatus for generating an element template, comprising:
the image detection module is used for detecting a first image aiming at an interactive page and determining an operable element included in the interactive page and attribute information of the operable element; and
and the template generating module is used for generating an element template for each operable element according to the attribute information of each operable element.
19. The apparatus of claim 18, further comprising:
the element dividing module is used for dividing the operable elements to obtain at least one element group;
wherein the template generation module is configured to: and generating an element template for each operable element according to the attribute information of each operable element and the membership between each operable element and the element group.
20. The apparatus of claim 19, wherein the element partitioning module comprises:
the class determination submodule is used for determining a plurality of classes related to the interactive page and the association relation among the classes according to the DOM tree aiming at the interactive page; and
a partitioning submodule, configured to partition the operable element according to the association relationship to obtain the at least one element group,
wherein the plurality of classes includes a class of the actionable element and a class of the at least one element group; the class of each element group is a parent class of the actionable element that each element group includes.
21. The apparatus of claim 18, wherein the attribute information comprises an element type; the device further comprises:
the simulation operation execution module is used for running a first preset script according to the position information of a first element of the jump type in the operable elements so as to execute simulation operation on the interactive page; and
and the type determining module is used for determining that the type of the first element is the jump type in response to the fact that the URL address of the page obtained after the first preset script is operated is not consistent with the URL address of the interactive page.
22. The apparatus of claim 18, wherein the attribute information comprises an element type; the device further comprises:
the information generation module is used for randomly generating input information aiming at a second element of the input box type in the operable elements;
the element assignment module is used for executing a second preset script according to the input information so as to assign the input information to the second element;
the image acquisition module is used for acquiring a second image of the interactive page after the second preset script is operated; and
an information determination module to determine a test criterion for the second element and test interaction information for the second element based on the input information and the second image,
wherein an element template for the second element is associated with the test criteria and the test interaction information.
23. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.
24. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any of claims 1-11.
25. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 11.
CN202210154465.7A 2022-02-18 2022-02-18 Interactive page testing method and element template generating method and device Pending CN114528215A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210154465.7A CN114528215A (en) 2022-02-18 2022-02-18 Interactive page testing method and element template generating method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210154465.7A CN114528215A (en) 2022-02-18 2022-02-18 Interactive page testing method and element template generating method and device

Publications (1)

Publication Number Publication Date
CN114528215A true CN114528215A (en) 2022-05-24

Family

ID=81625481

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210154465.7A Pending CN114528215A (en) 2022-02-18 2022-02-18 Interactive page testing method and element template generating method and device

Country Status (1)

Country Link
CN (1) CN114528215A (en)

Similar Documents

Publication Publication Date Title
CN108683562B (en) Anomaly detection positioning method and device, computer equipment and storage medium
KR101588027B1 (en) Method and apparatus for generating test case to support localization of software
CN112416778A (en) Test case recommendation method and device and electronic equipment
CN109872230B (en) Test method and device of financial data analysis system, medium and electronic equipment
CN114116496A (en) Automatic testing method, device, equipment and medium
CN111654495B (en) Method, apparatus, device and storage medium for determining traffic generation source
CN112069069A (en) Defect automatic positioning analysis method, device and readable storage medium
CN115757150A (en) Production environment testing method, device, equipment and storage medium
CN114419631A (en) Network management virtual system based on RPA
CN112149828B (en) Operator precision detection method and device based on deep learning framework
CN113760891A (en) Data table generation method, device, equipment and storage medium
CN115022201B (en) Data processing function test method, device, equipment and storage medium
CN115576831A (en) Test case recommendation method, device, equipment and storage medium
CN114546799A (en) Point burying log checking method and device, electronic equipment, storage medium and product
CN114528215A (en) Interactive page testing method and element template generating method and device
US11520831B2 (en) Accuracy metric for regular expression
CN114064510A (en) Function testing method and device, electronic equipment and storage medium
CN111008140B (en) Cross-platform UI (user interface) automatic testing method and device
CN113342632A (en) Simulation data automatic processing method and device, electronic equipment and storage medium
KR102217092B1 (en) Method and apparatus for providing quality information of application
CN114116688A (en) Data processing and data quality inspection method, device and readable storage medium
CN113238940A (en) Interface test result comparison method, device, equipment and storage medium
CN111666471A (en) Information acquisition method and device, computer equipment and storage medium
CN116401113B (en) Environment verification method, device and medium for heterogeneous many-core architecture acceleration card
CN116340172A (en) Data collection method and device based on test scene and test case detection method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination