WO2021088724A1 - 一种测试方法及装置 - Google Patents
一种测试方法及装置 Download PDFInfo
- Publication number
- WO2021088724A1 WO2021088724A1 PCT/CN2020/125167 CN2020125167W WO2021088724A1 WO 2021088724 A1 WO2021088724 A1 WO 2021088724A1 CN 2020125167 W CN2020125167 W CN 2020125167W WO 2021088724 A1 WO2021088724 A1 WO 2021088724A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- node
- dom
- target
- type
- test
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/03—Credit; Loans; Processing thereof
Definitions
- the present invention relates to the technical field of financial technology (Fintech), in particular to a testing method and device.
- Front-end interface testing is a routine operation of financial interface development.
- Traditional interface testing methods usually require testers to be arranged in advance, and the testers repeatedly click the document object model on the test interface during each interface test. DOM) node.
- this method relies heavily on manual operation, not only the efficiency of the test is low, but also the result of the test may be inaccurate due to the contingency of the manual operation.
- the existing automated testing software can be used to implement automated interface testing.
- Existing automated testing software includes, for example, sikuli software, selenium software, katalon software, and so on.
- these software usually require users to have a certain programming ability, which leads to a low degree of automated testing and poor user experience.
- selenium software usually needs to manually set the assertion conditions. The user needs to use the programming language supported by the selenium software to enter the statement that controls the assertion condition in the selenium software interface. In this way, the selenium software will make an assertion at the position that meets the assertion condition when the interface test is executed. . If the user does not set the statement that controls the assertion condition or the statement set by the user is wrong, the selenium software cannot get accurate test results.
- the present invention provides a testing method and device, which are used to solve the technical problems of low degree of automated testing and poor user experience due to the existing automated testing software requiring users to have a certain programming ability.
- the present invention provides a test method, including: recording a user's operation on a test interface to obtain a test case, the test case including operation information of the user operating one or more DOM nodes on the DOM tree corresponding to the test interface; Further, if it is determined to test the test case, the test interface is played back according to the operation information of the user's operation on one or more DOM nodes, and after the playback of the operation corresponding to each DOM node is completed, the test is performed according to the operation. As a result, the first interface obtained by playback and the standard interface corresponding to the operation are rendered.
- recording the user's operation on the test interface to obtain a test case including: for any user's operation on the test interface, first determine the target DOM node triggered by the user from the DOM tree corresponding to the test interface, and then according to The identification and type of the target DOM node and/or the hierarchical relationship of the target DOM node in the DOM tree determine the location identification of the target DOM node in the DOM tree, and according to the location identification, operation type and operation of the target DOM node in the DOM tree The content, operation and time information of the previous operation generate test data corresponding to the operation, and finally test cases are generated based on the test data corresponding to each operation of the user on the test interface.
- the identification and type of the target DOM node and/or the hierarchical relationship of the target DOM node in the DOM tree are used to determine the location identification of the target DOM node in the DOM tree.
- Simpler calculation conditions can be selected according to the actual situation. Calculating the location identification of the target DOM node, compared to the existing test method, which directly obtains the target DOM node according to the hierarchical relationship of the target DOM node in the DOM tree, there is no need to perform a more complicated calculation process for each DOM node. , Which can reduce the computational complexity.
- determining the location identification of the target DOM node in the DOM tree according to the identification and type of the target DOM node and/or the hierarchical relationship of the target DOM node in the DOM tree includes: first determining the identification of the target DOM node Whether it belongs to the first type of identification, if it is, the identification of the target DOM node is used as the location identification of the target DOM node, if not, then it is judged whether the type of the target DOM node is the only type in the DOM tree, and if it is, the target DOM The type of the node is used as the location identifier of the target DOM node.
- the location identifier of the target DOM node is determined according to the hierarchical relationship of the target DOM node in the DOM tree.
- the first type identification is used to uniquely identify the target DOM node during recording and playback.
- the location identification of the target DOM node can be quickly calculated, compared to the prior art using the absolute path of the target DOM node to calculate each target In terms of the way of locating the DOM node, it can greatly reduce the computational complexity and improve the efficiency of the test.
- determining the location identifier of the target DOM node according to the hierarchical relationship of the target DOM node in the DOM tree includes: first determining whether the parent node of the target DOM node exists, if not, then according to the target DOM node The order of the types in the DOM tree determines the location identifier of the target DOM node.
- the type of the parent node of the target DOM node and the type of the target DOM node to obtain the first-level combination type corresponding to the target DOM node, and then determine whether the first-level combination type corresponding to the target DOM node is the only type in the DOM tree , If yes, use the first-level combination type corresponding to the target DOM node as the location identifier of the target DOM node. If not, then finally determine whether the parent node of the parent node of the target DOM node exists, if not, then according to the target DOM node correspondence The order of the first-level combination type in the DOM tree determines the location identifier of the target DOM node.
- the type of the parent node of the parent node of the target DOM node, the type of the parent node of the target DOM node, and the type of the target DOM node are combined , Obtain the secondary combination type corresponding to the target DOM node, and determine the location identifier of the target DOM node according to the secondary combination type corresponding to the target DOM node.
- the combination type corresponding to the target DOM node is obtained by successively calling the parent node, and the combination type is directly used as the positioning identifier when the combination type is unique, and the higher parent node is called to obtain the combination type when the combination type is not unique.
- the location identifier can be quickly determined according to the parent node that is closer to the target DOM node, without using the complete path of the target DOM node in the DOM tree to determine its location identifier, which can reduce the number of test sites on the basis of ensuring the uniqueness of the location identifier.
- the amount of data to be processed improves the efficiency of the test.
- determining whether the identification of the target DOM node is the first type identification includes: if the identification of the target DOM node is composed of numbers, determining that the identification of the target DOM node does not belong to the first type identification. If the identifier of the target DOM node includes characters other than numbers, it is determined that the identifier of the target DOM node belongs to the first type of identifier.
- the timestamp, device identification, etc. are all composed of numbers. If the timestamp or device identification is used as the identification of the target DOM node, the time stamp is different during recording and playback, or it is executed on different test servers.
- the identification of the target DOM node will be changed, resulting in the inability to locate the recorded target DOM node according to the identification of the target DOM node during the playback operation. Accordingly, by setting the first type identifier to contain characters other than numbers, it is possible to clearly determine whether the identifier of the target DOM node is a meaningless identifier, so as to avoid the use of the first type identifier as a positioning identifier, which may cause the playback stage to be inaccessible. The problem of the target DOM node improves the accuracy of the test.
- rendering the first interface obtained by playback and the standard interface corresponding to the operation according to the test result corresponding to the operation includes: first parsing the first interface to obtain the first DOM tree, and then parsing the standard interface to obtain the standard DOM tree, for any difference node in the first level node layer of the first DOM tree and the standard DOM tree, the difference data corresponding to the difference node is generated according to the difference between the difference node in the first DOM tree and the standard DOM tree, according to The difference data corresponding to each difference node in each node layer is rendered on the first interface and the standard interface, and the corresponding element of each difference node is rendered to obtain the test result corresponding to the operation.
- a comparison can be performed every time a playback operation is performed, and the playback interface and standard interface corresponding to this operation are rendered according to the result of the comparison, so that the user can intuitively determine the operation based on the playback interface and the standard interface
- the above design can greatly reduce human workload, improve test efficiency, and reduce test costs.
- judging whether any I+1 level child node is a difference node or the same node according to the comparison result includes: if the I+1 level child node does not exist in the standard DOM tree and the first DOM tree If there is a child node of level I+1, it is determined that the child node of level I+1 is a new node. If the I+1 level child node exists in the standard DOM tree and the I+1 level child node does not exist in the first DOM tree, it is determined that the I+1 level child node is a deleted node.
- the I+1 level child node is a change node. Further, if the I+1 level child node is any one of a new node, a deleted node, or a changed node, the I+1 level child node is determined to be a difference node. If the I+1 level child node in the standard DOM tree and the I+1 level child node in the first DOM tree are the same in style, type, name, identification, and attribute, then the I+1 level child node is determined Is the same node.
- the test interface is played back according to the operation information of the user's operation on one or more DOM nodes, including: first inserting the test case into the task pool, and then selecting the first idle state from multiple processes A process that sends the test case to the first process, so that the first process plays back the test interface according to the operation information of the user's operation on one or more DOM nodes, and sets the test case in the task pool to the locked state .
- the task pool is used to store one or more test cases to be executed.
- the present invention provides a test device, the device includes: a recording module for recording a user's operation on a test interface to obtain a test case, and the test case includes one or more DOMs on the DOM tree corresponding to the test interface by the user.
- the operation information of the node operation is used to replay the test interface according to the operation information of the user's operation on one or more DOM nodes when the test case is determined to be tested; the processing module is used to After the playback of the operation corresponding to each DOM node is completed, the test result corresponding to the operation is generated according to the first interface obtained by replaying the operation and the standard interface corresponding to the operation.
- the recording module is specifically used to: for any user operation on the test interface, first determine the target DOM node triggered by the user from the DOM tree corresponding to the test interface, and then according to the identification and type of the target DOM node And/or the hierarchical relationship of the target DOM node in the DOM tree determines the location identification of the target DOM node in the DOM tree, and according to the location identification of the target DOM node in the DOM tree, the type of operation, the content of the operation, the operation and the previous The time information of the operation generates test data corresponding to the operation, and finally a test case is generated based on the test data corresponding to each operation of the user on the test interface.
- the recording module is specifically configured to first determine whether the identifier of the target DOM node belongs to the first type of identifier, and if so, use the identifier of the target DOM node as the location identifier of the target DOM node. If not, then judge whether the type of the target DOM node is the only type in the DOM tree. If it is, use the type of the target DOM node as the location identifier of the target DOM node. If not, then determine whether the target DOM node is the only type in the DOM tree.
- the hierarchical relationship determines the location identification of the target DOM node. Among them, the first type identification is used to uniquely identify the target DOM node during recording and playback.
- the recording module is specifically configured to first determine whether the parent node of the target DOM node exists, and if it does not exist, determine the location identifier of the target DOM node according to the order of the target DOM node type in the DOM tree. If it exists, combine the type of the parent node of the target DOM node and the type of the target DOM node to obtain the first-level combination type corresponding to the target DOM node, and determine whether the first-level combination type corresponding to the target DOM node is the only type in the DOM tree .
- the first-level combination type corresponding to the target DOM node is used as the location identifier of the target DOM node; if not, then it is determined whether the parent node of the parent node of the target DOM node exists. If it does not exist, determine the location identifier of the target DOM node according to the sequence of the first-level combination type corresponding to the target DOM node in the DOM tree. The type of the parent node and the type of the target DOM node are used to obtain the secondary combination type corresponding to the target DOM node, and the positioning identifier of the target DOM node is determined according to the secondary combination type corresponding to the target DOM node.
- the recording module is specifically configured to: if the identification of the target DOM node is composed of numbers, it is determined that the identification of the target DOM node does not belong to the first type of identification. If the identifier of the target DOM node includes characters other than numbers, it is determined that the identifier of the target DOM node belongs to the first type of identifier.
- the processing module is specifically used to: first parse the first interface to obtain the first DOM tree, and then parse the standard interface to obtain the standard DOM tree, targeting the first DOM tree and the level I node layer of the standard DOM tree According to any difference node in the first DOM tree and the standard DOM tree, the difference data corresponding to the difference node is generated according to the difference between the difference node in the first DOM tree and the standard DOM tree. The elements corresponding to each difference node are rendered on the interface, and the test results corresponding to the operation are obtained.
- the processing module is specifically configured to: if there is no child node at level I+1 in the standard DOM tree and there is a child node at level I+1 in the first DOM tree, determine the level I+1 The child nodes are newly added nodes. If the I+1 level child node exists in the standard DOM tree and the I+1 level child node does not exist in the first DOM tree, it is determined that the I+1 level child node is a deleted node. If the I+1 level child node in the standard DOM tree is different from the I+1 level child node in the first DOM tree in any one or more of the styles, types, names, logos, and attributes, it is determined The I+1 level child node is a change node.
- the I+1 level child node is determined to be a difference node. If the I+1 level child node in the standard DOM tree and the I+1 level child node in the first DOM tree are the same in style, type, name, identification, and attribute, then the I+1 level child node is determined Is the same node.
- the playback module is specifically used to: first insert the test case into the task pool, then select the first process in the idle state from multiple processes, and send the test case to the first process so that the first process
- the process performs a playback operation on the test interface according to the operation information of the user's operation on one or more DOM nodes, and sets the test case in the task pool to the locked state.
- the task pool is used to store one or more test cases to be executed.
- the present invention provides a computing device that includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes any of the above-mentioned first aspects.
- the present invention provides a computer-readable storage medium that stores a computer program executable by a computing device, and when the program runs on the computing device, the computing device executes any of the test methods described in the first aspect.
- FIG. 1 is a schematic diagram of a process corresponding to a test method provided by an embodiment of the present invention
- FIG. 2 is a schematic diagram of an interface of a service interface provided by an embodiment of the present invention.
- FIG. 3 is a schematic diagram of the structure of a DOM tree corresponding to a test interface provided by an embodiment of the present invention
- FIG. 4 is a schematic flowchart of a method for determining the location identifier of a target DOM node according to an embodiment of the present invention
- FIG. 5 is a schematic diagram of an interface of a possible case classifier provided by an embodiment of the present invention.
- FIG. 6 is a schematic diagram of an interface of a Chrome recording plug-in provided by an embodiment of the present invention.
- FIG. 7 is a schematic structural diagram of a testing device provided by an embodiment of the present invention.
- the field of financial technology usually involves a variety of businesses.
- the business of a bank can include card sales, deposit business, loan business, insurance business and wealth management business, etc.
- the daily business volume of the bank can reach thousands or even tens of thousands.
- a bank in addition to conducting field business at the bank's location, a bank can also set up a front-end page corresponding to the business on the network, and provide users with corresponding services through the front-end page corresponding to the business. For example, by setting the front-end interface corresponding to the loan transaction, the bank enables the user to directly perform loan operations on the front-end interface corresponding to the loan transaction, so that the user can handle the loan business more conveniently.
- the research and development personnel can usually modify the old version of the front-end page program or generate a new program based on the old version of the front-end page program.
- the modified program may cause dislocation of elements on the interface or abnormal function of the node, such as the style change of the DOM node, the attribute change of the DOM node, and the content of the DOM node garbled. Therefore, interface testing is an indispensable part of the front-end page development process.
- the interface test is to determine whether the style, content, position, function, etc. of the DOM node are abnormal relative to the standard DOM node by clicking the DOM node on the test interface. By performing interface testing, abnormal DOM nodes caused by the program update process can be detected, so as to ensure the smooth progress of front-end page development.
- Selenium software can be used to automate the interface testing process.
- the Selenium software includes four independent script files, which are a recording script file, a playback script file, an assertion script file, and a test result script file.
- the automated test process based on Selenium software specifically includes a recording phase, a playback phase, an assertion phase, and a test result phase. In each phase, the user needs to use the programming language supported by the Selenium software to call the script file of this phase.
- the specific implementation process of these four stages is as follows:
- the test server After the user uses the programming language supported by the Selenium software to call the script file of the recording phase, the test server starts the recording phase. In the recording phase, the user can manually click on each DOM node on the test interface. Correspondingly, the test server will record the user’s click operation information on each DOM node on the test interface in turn, thereby recording the changes in the test interface into Test Case. For example, if the user clicks on the DOM node A2, DOM node A1, and DOM node A3 on the test interface in turn, the Selenium software can record the user's operation information on these three DOM nodes in turn, and can according to the user's The operation information of the DOM node generates a test case.
- the user's operation information on each DOM node may include the location information of the DOM node and the user's operation type on the DOM node.
- the test case may include the sequence, location information and information of each DOM node operated by the user. Operation type.
- Selenium software can use the Xpath scheme to determine the location information of each DOM node, that is, first obtain the DOM tree corresponding to the test interface according to the test interface, and then obtain it according to the absolute path of the DOM node in the DOM tree corresponding to the test interface
- the position information of the DOM node for example, combines the DOM node identifiers included in the path from the root node to the DOM node in the DOM tree, and uses the combined identifier as the position information of the DOM.
- the test server After the user uses the programming language supported by the Selenium software to call the script file in the playback phase, the test server starts the playback phase.
- the test server can first obtain the test cases generated in the recording phase, and then play back the user's operation information on multiple DOM nodes in sequence according to the test cases. Specifically, for any operation information, the test server can first find the DOM node from the test interface according to the location information of the DOM node, and then perform playback operations on the DOM node according to the operation type of the recording stage, for example, if the recording stage The operation type of the DOM node is click, and the DOM node can also be clicked on the test interface during the playback stage.
- the assertion phase and the playback phase can be executed in parallel, and the assertion conditions of the assertion phase can be set by the user.
- the test server can also make an assertion according to the assertion condition set by the user when executing the playback stage.
- the test server can respond to the user with an assertion interface, and the user can enter the assertion condition on the assertion interface, thereby triggering the test server to make an assertion based on the assertion condition .
- the test server can compare the operated interface with the standard interface after operating the DOM node A2 to determine whether the style, content, or function of the DOM node A2 is abnormal.
- the test server can respond to the user with a test result report.
- the test result report may include the test result of the DOM node for which the user has set the assertion condition, the test result may include the test normal or the test abnormal, and the test result report may be displayed to the user in the form of text. For example, if DOM node A2, DOM node A1, and DOM node A3 are all set with assertion conditions, and the test result is reported as abnormal test of DOM node A2, normal test of DOM node A1, and abnormal test of DOM node A3, the user can follow this The test result report repairs DOM node A2 and DOM node A3.
- the Selenium software can automatically complete the interface test, because the user needs to use the programming language supported by the Selenium software to call the script file corresponding to each stage, the user needs to be proficient in the programming language supported by the Selenium software. This will lead to difficult development and poor user experience. In other words, the degree of automation of Selenium software is not high, and it is impossible to realize automated page testing in a complete sense. In addition, the automated testing process based on Selenium software also has the following shortcomings:
- the test result of Selenium software for each DOM node is the success or failure of the test process, and no specific test results can be given, which causes the user to be unable to visually view the abnormal information of the DOM node, which is not conducive to the user's failure Repair process.
- the present invention provides a testing method for realizing a universal and complete automated testing process on the basis of improving the efficiency of interface testing, improving the accuracy and portability of the testing.
- Fig. 1 is a schematic diagram of a process corresponding to a test method provided by an embodiment of the present invention. The method is applied to a test server, and the method includes:
- Step 101 Record the user's operation on the test interface to obtain a test case.
- a service interface may be provided on the test server.
- the service interface is an interface based on a worldwide web (web) server and a web browser, and the service interface may contain multiple function icons.
- the test server may provide the user with the service interface. If it is detected that the user clicks the function icon on the service interface, the test server can also execute the function corresponding to the function icon through the web browser.
- FIG. 2 is a schematic diagram of a service interface provided by an embodiment of the present invention.
- a recording sub-interface and a service sub-interface can be set on the service interface, and a function button of "recording plug-in" can be set on the recording sub-interface
- the service sub-interface can be set with the function button of "case management", the function button of "playback” and the function button of "difference display”.
- the test server can first display the recording sub-interface to the user through the web browser, or it can also display the recording sub-interface and the service sub-interface to the user at the same time .
- the test server can convert the recording sub-interface on the web browser into a test interface, and can start the preset recording plug-in to record the user's comments. Test the operation information of the interface and get the recording script. After receiving a user-triggered message to end the recording, the test server can convert the recording script into a test case and add it to the case managed by the service sub-interface.
- the preset recording plug-in may be any type of plug-in that has an interface recording function, such as a Chrome recording plug-in, a Unity3D recording plug-in, etc., which are not specifically limited.
- the function button can be set on the service interface or on the test interface, without limitation.
- the test server can automatically jump from the service interface to the test interface, and record the user's operation information on the test interface Get the recording script.
- the test server can directly record the user's operation information on the test interface to obtain the recording script.
- the preset recording plug-in may first parse the test interface to obtain the DOM tree corresponding to the test interface.
- the DOM tree may include multiple DOM nodes with hierarchical relationships.
- the upper-level node connected by any DOM node is called the parent node of the DOM node, and the next-level node connected by any DOM node is called the child of the DOM node. node.
- a DOM node can have one parent node and can have multiple child nodes. Among them, each DOM node can correspond to an element on the test interface, and each DOM node can have corresponding information such as style, content, attributes, and location.
- FIG. 3 is a schematic structural diagram of a DOM tree corresponding to a test interface provided by an embodiment of the present invention.
- the DOM tree corresponding to the test interface may include a first-level node layer, a second-level node layer, and a second-level node layer.
- the third-level node layer and the fourth-level node layer may be set in the first-level node layer, and the type of the DOM node B 1 is Document.
- the second-level node layer can be provided with DOM node B 21 , DOM node B 22, and DOM node B 23.
- the type of DOM node B 21 is Element, the type of DOM node B 22 is Entity, and the type of DOM node B 23 is Notation.
- the third-level node layer can be provided with DOM node B 31 , DOM node B 32 and DOM node B 33.
- the type of DOM node B 31 is Element, the type of DOM node B 32 is Notation, and the type of DOM node B 33 is Element.
- a DOM node B 41 may be set in the fourth-level node layer, and the type of the DOM node B 41 is Notation.
- the node in the first-level node layer is called the root node
- the node in the second-level node layer connected to the root node is called the first-level child node of the root node
- the root node is called the connected first-level child node.
- the first-level parent node of the node in the second-level node layer is called the root node
- the nodes in the third-level node layer are called the first-level child nodes of the nodes in the connected second-level node layer, that is, the second-level child nodes of the root node, and the nodes in the connected second-level node layer
- the node is called the first-level parent node of the node in the third-level node layer
- the root node is called the second-level parent node of the node in the third-level node layer.
- DOM node B 1 is the root node
- DOM node B 21 is the first-level child node of DOM node B 1
- FIG. 3 is only an exemplary simple description, which only illustrates the hierarchical relationship and types between various DOM nodes, and does not indicate the attributes, styles and other information of each DOM node. This illustration is only for the convenience of explaining the solution, and does not constitute a limitation on the solution. In specific implementation, the structure of the DOM tree can be set according to actual needs, and the specifics are not limited.
- the preset recording plug-in can record the user's operation information on the test interface in the following manner to obtain the recording script:
- One operation first determine the target DOM node triggered by the user in the DOM tree corresponding to the test interface, and then obtain the target DOM node in the DOM tree according to the target DOM node's identification, type, or the hierarchical relationship of the target DOM node in the DOM tree.
- the location identification and based on the location identification of the target DOM node, the type of operation, the content of the operation, the operation and the time information of the previous operation, the recording script corresponding to the operation is generated, and then, when a message that the user triggers the end of the recording is received, according to The recording script corresponding to each operation of the test interface by the user obtains the test case corresponding to the recording.
- the test interface is a page on the HTML5 browser
- the preset recording plug-in is the Chrome recording plug-in:
- Chrome records can first cache the types and identifications of all DOM nodes in the DOM tree corresponding to the test interface, and then use the MotationObserver API interface of the HTML5 browser to monitor the DOM nodes on the test interface. If it detects new changes to DOM nodes, DOM nodes If you delete the change or modify the DOM node, you can re-parse the test interface after changing the DOM node to get the changed DOM tree. In this way, the Chrome recording plug-in can re-cache the types and identifications of all DOM nodes in the changed DOM tree. .
- the way to monitor the changes of DOM nodes can be: the Chrome recording plug-in sets up a buried event capture mechanism on the test page of the HTML5 browser in advance.
- a buried event such as a click event, a double-click event or
- the user's operation corresponding to a click operation, a double-click operation, or an input operation
- the Chrome recording plug-in can obtain information such as the type of operation, the content of the operation, the location identifier of the target DOM node corresponding to the operation, the duration of the operation and the last operation, etc., and then generate information based on this information The recording script corresponding to this operation.
- FIG. 4 is a schematic flowchart corresponding to a method for determining the location identifier of a target DOM node according to an embodiment of the present invention. As shown in FIG. 4, the method includes:
- Step 401 Determine the target DOM node corresponding to this operation according to the user's operation, and obtain the type and identifier of the target DOM node from the pre-cached types and identifiers of each DOM node.
- the Chrome recording plug-in After receiving the start instruction sent by the test server, the Chrome recording plug-in will first cache the types and identifiers of all DOM nodes in the browser space from the DOM tree corresponding to the test interface. Therefore, if it is determined that the user is targeted at When a certain DOM node (such as DOM node B 22 ) performs a click operation, the Chrome recording plug-in can directly obtain the type and identification of DOM node B 22 from the browser space.
- the identification and type of the DOM node B 22 can be preset by the interface developer, so the Chrome recording plug-in can obtain the identification and type of the DOM node B 22 by calling the configuration file of the test interface. Based on the DOM tree shown in FIG. 3, it can be seen that the type of the DOM node B 22 is Entity.
- step 402 it is determined whether the identifier of the target DOM node belongs to the first type of identifier, if so, step 403 is executed, and if not, step 404 is executed.
- the first type identifier is used to indicate an identifier that can uniquely identify the target DOM node during different operations. If the identifier of a certain DOM node belongs to the first type of identifier, even if the DOM node is clicked on at a different time and/or on a different device, the identifier of the DOM node will not change.
- the ID of the DOM node when the ID of the DOM node is set to generate a timestamp, a circular number or a random number, if the DOM node is clicked on at a different time and/or on a different device, the DOM node The identity of the node will change. For example, taking the identification of the DOM node as the generation timestamp as an example, if the time when the DOM node is clicked during recording is 10:09, and the time when the DOM node is clicked when the test case is played back is 12:10, then The identification of the DOM node during recording and playback is different, that is, during playback, the DOM node cannot be queried according to the identification of the DOM node during recording.
- the identifier of the target DOM node is composed of numbers, it can be determined that the identifier of the target DOM node does not belong to the first type of identifier. If the identifier of the target DOM node includes characters other than numbers, it can be determined that the identifier of the target DOM node belongs to the first type of identifier.
- the first type identifier to contain characters other than numbers, it is possible to clearly determine whether the identifier of the target DOM node is a meaningless identifier, thereby avoiding the playback stage caused by using the first type identifier as the positioning identifier. The problem that the target DOM node cannot be queried can improve the accuracy of the test.
- Step 403 Use the identifier of the target DOM node as the location identifier of the target DOM node.
- the identification of the target DOM node belongs to the first type of identification, since the identification of the target DOM node can uniquely identify the target DOM node during different operations, it means that the identification of the target DOM node determined during recording can also be used during playback. The corresponding target DOM node is found. Therefore, the identifier of the target DOM node can be directly used as the location identifier of the target DOM node.
- step 404 it is determined whether the type of the target DOM node is the only type in the DOM tree, if it is, step 405 is executed, and if not, step 406 is executed.
- the identification of the target DOM node does not belong to the first type of identification, because the identification of the target DOM node cannot uniquely identify the target DOM node during different operations, it means that the identification of the target DOM node determined during recording cannot be used during playback. The corresponding target DOM node is found. Therefore, the identifier of the target DOM node cannot be directly used as the location identifier of the target DOM node. In this way, the location identifier of the target DOM node can be determined first according to the type of the target DOM node.
- the target DOM can be determined according to the hierarchical relationship of the target DOM node in the DOM tree. The location identifier of the node.
- Step 405 Use the type of the target DOM node as the location identifier of the target DOM node.
- step 406 it is determined whether the parent node at the upper level exists, if it exists, then step 407 is executed, and if it does not exist, step 410 is executed.
- Step 407 Obtain the combination type corresponding to the target DOM node according to the type of the parent node at the upper level.
- step 408 it is determined whether the combination type corresponding to the target DOM node is the only type in the DOM tree, if so, step 409 is executed, and if not, step 406 is executed.
- Step 409 Use the combination type corresponding to the target DOM node as the location identifier of the target DOM node.
- Step 410 Determine the location identifier of the target DOM node according to the type of the target DOM node or the sequence of the combination type corresponding to the target DOM node in the DOM tree.
- the following embodiments of the present invention refer to the combination type obtained by combining the type of DOM node and the type of the first-level parent node of the DOM node as the first-level combination type corresponding to the DOM node, and combine the type of DOM node, DOM
- the combination type obtained by the type of the first-level parent node of the node and the type of the second-level parent node of the DOM node is called the second-level combination type corresponding to the DOM node, which is recursively in turn.
- the type of DOM node B 1 is Document
- the type of DOM node B 21 is Element
- the type of DOM node B 22 is Entity
- the type of DOM node B 23 is Notation
- the type of DOM node B 31 is Element.
- the type of DOM node B 32 is Notation
- the type of DOM node B 33 is Element
- the type of DOM node B 41 is Notation. Since the Document type and Entity type are the only types in the DOM tree, if the target DOM node is a DOM node B 1 or DOM node B 22 , the type of the target DOM node can be directly used as the location identifier of the target DOM node.
- the location identifier of the target DOM node is Document.
- the location identifier of the target DOM node is Entity.
- DOM node B 21 , DOM node B 31, and DOM node B 33 are all Element types
- the types of DOM node B 23 , DOM node B 32, and DOM node B 41 are all Notation types
- the Element type and The Notation type is not the only type in the DOM tree.
- the preset recording plug-in can first Combine the type of the target DOM node and the type of the first-level parent node of the target DOM node to obtain the first-level combination type corresponding to the target DOM node, and determine whether the first-level combination type corresponding to the target DOM node is the only type in the DOM tree. If it is, the first-level combination type corresponding to the target DOM node can be used as the positioning identifier of the target DOM node.
- the type of the target DOM node obtains the second-level combination type corresponding to the target DOM node, and then executes the above-mentioned judgment process for the second-level combination type corresponding to the target DOM node until the execution reaches the root node.
- the first composition can DOM Node type Element B 31, and a DOM node 31 is the parent node of the DOM node B Element 21 of the type B, to obtain the corresponding DOM node B 31 is The primary combined type Element-Element; because the Element-Element type is the only type in the DOM tree, the primary combined type Element-Element corresponding to the DOM node B 31 can be used as the location identifier of the DOM node B 31.
- the first composition can DOM Node type Notation B 32, the parent node of a DOM node DOM node B 32 and B types of Element 21, B 32 to obtain a corresponding DOM node
- the first-level combination type Element-Notation since the first-level combination type corresponding to DOM node B 41 is also Element-Notation, indicating that the Element-Notation type is not the only type in the DOM tree, therefore, the first-level combination corresponding to DOM node B 32 is not combined type Element-Notation positioning mark as a DOM node B 32, but the combination of B type Notation DOM node 32, the parent node of a DOM node B 32 B DOM node type of Element 21, two DOM node of the parent node B 32
- the type Document of DOM node B 1 obtains the secondary combined type Document-Element-Notation corresponding to DOM node B 32 ; since the Document-Element-
- the type of DOM node B 23 is not Notation but Element
- the type of DOM node B 33 is not Element but Notation.
- the secondary combination type corresponding to DOM node B 33 is also Document-Element-Notation
- the description Document-Element-Notation is not the only type in the DOM tree. Therefore, the secondary combined type Document-Element-Notation corresponding to DOM node B 32 is not used as the location identifier of DOM node B 32.
- the query the DOM tree found two DOM Node B 32 is the parent node of DOM node B as a root node.
- the preset recording can plug the corresponding DOM node B 32 in accordance with two
- the order of the secondary combination type Document-Element-Notation in the DOM tree determines the location identifier corresponding to the target DOM node, specifically, the order of the secondary combination type Document-Element-Notation corresponding to the DOM node B 32 in the DOM tree Is the first place, and the order of the secondary combination type Document-Element-Notation corresponding to DOM node B 33 is the second in the DOM tree. Therefore, the secondary combination type corresponding to DOM node B 32 can be combined with the combination type
- the sequential combined form Document-Element-Notation-1 in the DOM tree serves as the location identifier of the DOM node B 32.
- each DOM node Since the Selenium software directly obtains the position information of the DOM node according to the absolute path of the target DOM node in the DOM tree (that is, the Xpath scheme), each DOM node requires a more complicated calculation process to determine the location identification of each DOM node. This will make the performance loss of the test system more serious.
- the positioning method shown in Figure 4 by using the calculation logic of first identification, then type, and finally hierarchical relationship, the positioning identification of each DOM node can be quickly calculated, thereby reducing the complexity of calculation and improving the efficiency of testing.
- the preset recording plug-in can obtain the type of operation (such as click, double-click, read or write, etc.), the content of the operation (such as written data), Operation information such as the length of time between this operation and the last operation. You can also obtain operation path information such as Uniform Resource Location (URL), user agent, and device information of the test interface, and assemble operation information and operation path information in a preset format to obtain the recording corresponding to this operation script.
- type of operation such as click, double-click, read or write, etc.
- the content of the operation such as written data
- Operation information such as the length of time between this operation and the last operation.
- You can also obtain operation path information such as Uniform Resource Location (URL), user agent, and device information of the test interface, and assemble operation information and operation path information in a preset format to obtain the recording corresponding to this operation script.
- URL Uniform Resource Location
- a case classifier is preset on the test server.
- Figure 5 shows a possible The schematic diagram of the case classifier is shown in Figure 5.
- the case classifier contains script functions corresponding to multiple operation types, such as creat function, setViewPort function, setUserAgent function, goto function, wait function, dbclick function, click function, Tap function, input function, select function, upload function, dest function, etc.
- the operation information and operation path information of each operation can be automatically input into the case classifier.
- the case classifier can first call the creat function to create the script object corresponding to each operation, and then traverse the operation path information of each operation to determine the operation process corresponding to each operation, and finally update the function variables according to the traversal process. Get the recording script. For example, if a certain operation is a click operation, after traversing the operation path information of the operation, it can be determined that the script function corresponding to the operation is the click function. In this way, the case classifier can update the variable in the click function according to the operation information of the operation to obtain the recording script corresponding to the operation.
- one operation of the user can correspond to one recording script or multiple recording scripts, which is not specifically limited.
- each operation performed by the user on the test interface can be input into the case classifier in real time.
- the case categorizer can arrange and combine the recording scripts corresponding to each operation of the user in order to obtain the recorded test case (here, the script file).
- the test server can first set an identifier for the recorded test case, and then store the script file of the recorded test case in the case management folder, and add the identifier of the recorded test case to In the interface corresponding to the function button of "Case Management" corresponding to the service sub-interface, it is displayed to the user.
- FIG. 6 is a schematic structural diagram of a Chrome recording plug-in provided by an embodiment of the present invention.
- the Chrome recording plug-in can be composed of Popup module, Background module and Content module.
- the functions of Popup module, Background module and Content module are as follows Shown:
- the Popup module is responsible for the interface display and logic processing of the Chrome recording plug-in. Specifically, the Popup module can provide the user with a "start recording” function button and a "end recording” function button, and notify the user when it detects that the user clicks the "start recording” function button or the "end recording” function button Background module. In addition, the Popup module can also display the test case sent by the Background module to the user after the Chrome recording plug-in finishes recording.
- the Background module is a bridge to undertake the Popup module and the Content module.
- the Background module can notify the Content module of the message that the user clicks the "Start Recording" function button and the "End Recording" function button in the Popup module, and can receive the message sent by the Content module after the Chrome recording plug-in finishes recording Operation information corresponding to multiple buried events, and the case classifier can be called to convert these operation information into test cases, and then the test cases can be sent to the Popup module for users to view.
- the execution environment of the Content module can be set in the test interface.
- the Content module can listen to and record the buried events in the test interface, such as click event, input event, change event, touchstart event , Touchmove event, touchend event, touchcancel event, etc.
- the Content module can send the operation information corresponding to the recorded buried event to the Background module.
- the operation information corresponding to each buried event may include the type of the buried event, the location identifier of the target DOM node of the operation, the operation information, the time difference between the current operation and the last operation, and so on.
- Step 102 If it is determined to test the test case, play back the test interface according to the operation information of the user's operation on the one or more DOM nodes.
- the test server may preset multiple processes, and may use multiple processes to execute multiple test tasks in parallel.
- the test server can display historical test cases to the user. In this way, if the user is detected to trigger a test case, the test server can first The identification of the test case is added to the task pool to be executed, and then multiple processes can be polled to determine how busy each process is. If it is determined that a certain process is in an idle state, the script file of the test case can be sent to the idle process, and the test case in the task pool to be executed can be locked, so as to prevent other processes from repeatedly processing the test case, resulting in failure Necessary performance loss.
- the number of processes in the test server can be set according to the number of cores of a central processing unit (Central Processing Unit, CPU), or can also be set by the user according to business needs, which is not specifically limited.
- the process can use the VM virtual machine capability of node.js to run the script file corresponding to the test case. Specifically, the process can first parse the script file corresponding to the test case to obtain the recording script corresponding to multiple operations. Since the recording script corresponding to each operation is represented by a function, the process can use the preset browser algorithm to execute the function, thereby Play back multiple operations in sequence on the test interface.
- CPU Central Processing Unit
- the preset browser algorithm can be set by those skilled in the art based on experience.
- it can be the puppeteer browser algorithm, the PhantomJS browser algorithm, etc., which are not specifically limited.
- the process can first obtain the Create function from the script file of the test case, and can use the Create function to call the puppeteer browser algorithm to start the puppeteer browser algorithm execution The task of the headless browser. In this way, the puppeteer browser algorithm can establish a socket connection with the headless browser. Further, if the recording script corresponding to a certain operation is the Click function, the puppeteer browser algorithm can first wait for the element corresponding to the target DOM node to appear on the test interface of the headless browser according to the location identifier of the target DOM node of the operation.
- a control instruction is sent to the puppeteer browser algorithm.
- the puppeteer browser algorithm can tell the headless browser to perform the click operation on the element corresponding to the target DOM node through the socket connection.
- the script file corresponding to a test case is: first the click function records that the user clicks on the DOM node B21, then the wait function () records that the user waits for 30 seconds after clicking the DOM node B21, and then the dbclick function records The user double-clicks the DOM node B23, and then the wait function () records that the user waits for 15 seconds after double-clicking the DOM node B23.
- the input function records the user input "document” in the DOM node B1, and the process can be called by the puppeteer browser algorithm
- the puppeteer browser algorithm For headless browsers, first click DOM node B21 on the test interface of the headless browser, then double-click DOM node B23 after waiting 30 seconds, and enter "document” in DOM node B1 after waiting 15 seconds to complete the alignment The user's operations in the test case are fully replayed.
- Step 103 After the playback of the operation corresponding to each DOM node ends, rendering is performed on the first interface obtained by playback and the standard interface corresponding to the operation according to the test result corresponding to the operation.
- the test interface can jump to the first One interface.
- the process can compare the first interface with the standard interface corresponding to the operation, determine the difference between each DOM node in the DOM tree corresponding to the two interfaces, and can render the corresponding element difference in the first interface and according to the difference of each DOM node.
- the standard interface can be set by those skilled in the art based on experience. For example, it can be an interface obtained by programming, or it can be the most standard one selected from the previous test process. The interface is not specifically limited.
- the process can parse the first interface to obtain the corresponding first DOM tree, and can determine the standard DOM tree corresponding to the standard interface according to the standard database.
- the standard database may only store standard interfaces corresponding to multiple operations, or may also store standard interfaces and standard DOM trees corresponding to multiple operations at the same time.
- the process can directly obtain the standard DOM tree from the standard database, or it can first obtain the standard interface, and then parse the standard DOM tree.
- the process can generate difference data corresponding to the difference node according to the difference between the difference node in the first DOM tree and the standard DOM tree, for the first-level node
- the process can compare all the child nodes of the same node in the first DOM tree and the standard DOM tree, and According to the comparison result, it can be determined whether any child node belongs to a different node or the same node, and the comparison is performed according to the above process until the comparison reaches that all nodes have no child nodes.
- the process can first compare the first root node in the first-level node layer of the first DOM tree with the standard root node in the first-level node layer of the standard DOM tree. If the first root node and the standard root node are between If there are any one or multiple differences in style, content, type, and attributes, the node is a modified node. If there is only the first root node and no standard root node, the first root node is determined to be a newly added node. If there is only the standard root node but not the first root node, the standard root node is determined to be the deleted node.
- the new node, the deleted node, and the modified node are all different nodes, and the process can generate the difference data corresponding to the difference node according to the difference between the difference node in the first DOM tree and the standard DOM tree.
- the style, content, type, attributes, etc. of the first root node and the standard root node are the same, the first root node and the standard root node belong to the same node.
- the process can compare all child nodes of the first root node in the first DOM tree with all child nodes of the standard root node in the standard DOM tree, and can follow the comparison method of the root node Determine whether any child node is a difference node or the same node.
- the process may generate difference data corresponding to the difference child node according to the difference between the difference child node in the first DOM tree and the standard DOM tree.
- the process can continue to compare all child nodes of the same child node in the first DOM tree with all child nodes of the same child node in the standard DOM tree until the comparison reaches no child node.
- the process can obtain the difference data of multiple difference nodes after the comparison between the first DOM tree and the standard DOM tree is completed.
- the type of difference data can be new, deleted or modified.
- the process can be rendered on the first interface and the standard interface based on the difference data of multiple difference nodes. For example, you can use the first type checkout box to frame the new node on the first interface, or you can use the second type checkout Frame the deleted node on the standard interface, or you can use the third-type checkout frame to frame the modified node that has differences between the first interface and the second interface.
- the first type of checkout box, the second type of checkout box, and the third type of checkout box can be set by those skilled in the art based on experience, and the details are not limited.
- colors can be used to identify different types of checkout boxes.
- the frame is yellow.
- text can be used to identify different types of checkout boxes. For example, add new words to the first type of checkout box, then add delete words to the second type of checkout box, and in the third type Add modified words and/or specific modified content to the type checkout box.
- a screenshot of the difference node on the first interface and the standard interface may also be taken, and the screenshot is displayed to the user.
- a test case is obtained by recording a user's operation on a test interface, and the test case includes operation information of the user operating one or more DOM nodes on the DOM tree corresponding to the test interface; Further, if it is determined to test the test case, the test interface is played back according to the operation information of the user's operation on the one or more DOM nodes, and the operation corresponding to each DOM node is played back After the end, according to the test result corresponding to the operation, the first interface obtained by playback and the standard interface corresponding to the operation are rendered.
- the test result corresponding to the operation the first interface obtained by playback and the standard interface corresponding to the operation are rendered.
- an embodiment of the present invention also provides a testing device, and the specific content of the device can be implemented with reference to the foregoing method.
- FIG. 7 is a schematic structural diagram of a testing device provided by an embodiment of the present invention, including:
- the recording module 701 is configured to record the user's operation on the test interface to obtain a test case; the test case includes the operation information of the user's operation on one or more DOM nodes on the DOM tree corresponding to the test interface;
- the playback module 702 is configured to, if it is determined to test the test case, play back the test interface according to the operation information of the user's operation on the one or more DOM nodes;
- the processing module 703 is configured to render the first interface obtained by playback and the standard interface corresponding to the operation according to the test result corresponding to the operation after the playback of the operation corresponding to each DOM node ends.
- the recording module 701 is specifically configured to: for any operation of the user on the test interface, determine the target DOM node triggered by the user from the DOM tree corresponding to the test interface; The identification and type of the target DOM node, and/or the hierarchical relationship of the target DOM node in the DOM tree, determine the location identification of the target DOM node in the DOM tree, and determine the location of the target DOM node in the DOM tree according to the target DOM node in the DOM tree.
- the location identifier in the DOM tree, the type of the operation, the content of the operation, and the time information of the operation and the previous operation generate test data corresponding to the operation; according to the user's various operations on the test interface
- the corresponding test data generates the test case.
- the recording module 701 is specifically configured to: determine whether the identifier of the target DOM node belongs to the first type of identifier, and if so, use the identifier of the target DOM node as the location identifier of the target DOM node, so The first type identifier is used to uniquely identify the target DOM node during recording and playback; if not, it is determined whether the type of the target DOM node is the only type in the DOM tree, and if so, the target The type of the DOM node is used as the location identifier of the target DOM node. If not, the location identifier of the target DOM node is determined according to the hierarchical relationship of the target DOM node in the DOM tree.
- the recording module 701 is specifically configured to: determine whether the parent node of the target DOM node exists, and if not, determine the target according to the order of the target DOM node type in the DOM tree The location identifier of the DOM node; if it exists, combine the type of the parent node of the target DOM node and the type of the target DOM node to obtain the first-level combination type corresponding to the target DOM node, and determine that the target DOM node corresponds Whether the first-level combination type of is the only type in the DOM tree, if so, the first-level combination type corresponding to the target DOM node is used as the location identifier of the target DOM node, if not, the target DOM is determined Whether the parent node of the parent node of the node exists, if it does not exist, determine the location identifier of the target DOM node according to the order in the DOM tree of the first-level combination type corresponding to the target DOM node; if it exists
- the recording module 701 is specifically configured to: if the identification of the target DOM node is composed of numbers, determine that the identification of the target DOM node does not belong to the first type identification, and if the identification of the target DOM node If the identifier includes characters other than numbers, it is determined that the identifier of the target DOM node belongs to the first type identifier.
- the processing module 703 is specifically configured to: parse the first interface to obtain a first DOM tree, and parse the standard interface to obtain a standard DOM tree.
- the difference data corresponding to the difference node is generated according to the difference between the difference node in the first DOM tree and the standard DOM tree; for the first DOM If it is determined that the same node has the same node in the level I node layer of the standard DOM tree and there are connected sub-nodes of level I+1, then compare the first DOM tree and the standard DOM tree All I+1 level child nodes connected to the same node, and determine whether any connected I+1 level child node is a difference node or the same node according to the comparison result, according to the difference corresponding to each difference node in each level of the node layer Data, rendering the elements corresponding to the respective difference nodes on the first interface and the standard interface to obtain the test result corresponding to the operation.
- I is an integer greater than zero.
- the processing module 703 is specifically configured to: if the I+1 level child node does not exist in the standard DOM tree and the I+1 level child node exists in the first DOM tree, It is determined that the I+1 level child node is a new node; if the I+1 level child node exists in the standard DOM tree and the I+1 level does not exist in the first DOM tree Child node, determine that the I+1 level child node is a deletion node; if the I+1 level child node in the standard DOM tree is the same as the I+1 level child node in the first DOM tree If any one or more of the styles, types, names, identifiers, and attributes of the child nodes of the first level are different, it is determined that the child nodes of the I+1 level are changed nodes.
- the I+1 level child node is any one of a new node, a deleted node, or a changed node, the I+1 level child node is determined to be a difference node, and if all the nodes in the standard DOM tree are If the I+1 level child node and the I+1 level child node in the first DOM tree are the same in style, type, name, identification, and attribute, then the I+1 level child node is determined The nodes are the same node.
- the playback module 702 is specifically configured to insert the test case into a task pool, and the task pool is used to store one or more test cases to be executed, and select the first in an idle state from a plurality of processes.
- a test case is obtained by recording user operations on a test interface, and the test case includes one or more DOMs on the DOM tree corresponding to the test interface by the user.
- the operation information of the node operation further, if it is determined to test the test case, the test interface is played back according to the operation information of the user’s operation on the one or more DOM nodes, and every After the playback of the operation corresponding to each DOM node is completed, the first interface obtained by playback and the standard interface corresponding to the operation are rendered according to the test result corresponding to the operation.
- the user does not need to manually set the assertion condition.
- users without programming ability can also use this method to perform front-end interface testing, thereby using the threshold Low, the degree of automated testing is high.
- the first interface and the standard interface are rendered according to the test results of the playback operation, so that the user can intuitively view the difference data in the test results, compared with the existing As far as the test method is to give a complex test report, the user experience is better.
- embodiments of the present invention also provide a computing device, including at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit , So that the processing unit executes the test method described in any one of FIG. 2.
- embodiments of the present invention also provide a computer-readable storage medium that stores a computer program executable by a computing device, and when the program runs on the computing device, the computing device executes The test method described in any one of Figure 2.
- the embodiments of the present invention can be provided as methods or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
- a computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
- These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
- the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
- These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
- the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- General Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- Computer Hardware Design (AREA)
- Development Economics (AREA)
- General Business, Economics & Management (AREA)
- Technology Law (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Economics (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
Claims (18)
- 一种测试方法,其特征在于,所述方法包括:录制用户对测试界面的操作得到测试案例;所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放;在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,在回放得到的第一界面和所述操作对应的标准界面上进行渲染。
- 根据权利要求1所述的方法,其特征在于,所述录制用户对测试界面的操作得到测试案例,包括:针对所述用户对所述测试界面的任一操作,从所述测试界面对应的DOM树中确定所述用户触发的目标DOM节点;根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,并根据所述目标DOM节点在所述DOM树中的定位标识、所述操作的类型、所述操作的内容、所述操作与上一操作的时间信息生成所述操作对应的测试数据;根据所述用户对所述测试界面的各个操作对应的测试数据生成所述测试案例。
- 根据权利要求2所述的方法,其特征在于,所述根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,包括:判断所述目标DOM节点的标识是否属于第一类型标识,若是,则将所述目标DOM节点的标识作为所述目标DOM节点的定位标识,所述第一类型标识用于在录制和回放时唯一标识所述目标DOM节点;若否,则判断所述目标DOM节点的类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点的类型作为所述目标DOM节点的定位标识,若否,则根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识。
- 根据权利要求3所述的方法,其特征在于,所述根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识,包括:判断所述目标DOM节点的父节点是否存在,若不存在,则根据所述目标DOM节点的类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的一级组合类型,判断所述目标DOM节点对应的一级组合类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点对应的一级组合类型作为所述目标DOM节点的定位标识,若否,则判断所述目标DOM节点的父节点的父节点是否存在,若不存在,则根据所述目标DOM节点对应的一级组合类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的父节点的类型、所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的二级组合类型,并根据所述目标DOM节点对应的二级组合类型确定所述目标DOM节点的定位标识。
- 根据权利要求3所述的方法,其特征在于,所述判断所述目标DOM节点的标识是否 为第一类型标识,包括:若所述目标DOM节点的标识由数字组成,则确定所述目标DOM节点的标识不属于所述第一类型标识,若所述目标DOM节点的标识包括数字以外的字符,则确定所述目标DOM节点的标识属于所述第一类型标识。
- 根据权利要求1所述的方法,其特征在于,所述根据所述操作对应的测试结果,在回放得到的第一界面和所述操作对应的标准界面上进行渲染,包括:解析所述第一界面得到第一DOM树,解析所述标准界面得到标准DOM树;针对于所述第一DOM树和所述标准DOM树的第I级节点层中的任一差异节点,根据所述差异节点在所述第一DOM树和所述标准DOM树中的区别生成所述差异节点对应的差异数据;针对于所述第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定所述相同节点存在连接的第I+1级子节点,则对比所述第一DOM树和所述标准DOM树中所述相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点;其中,I为大于0的整数;根据各级节点层中各个差异节点对应的差异数据,在所述第一界面和所述标准界面上对所述各个差异节点对应的元素进行渲染,得到所述操作对应的测试结果。
- 根据权利要求6所述的方法,其特征在于,所述根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点,包括:若所述标准DOM树中不存在所述第I+1级子节点且所述第一DOM树中存在所述第I+1级子节点,则确定所述第I+1级子节点为新增节点;若所述标准DOM树中存在所述第I+1级子节点且所述第一DOM树中不存在所述第I+1级子节点,则确定所述第I+1级子节点为删除节点;若所述标准DOM树中的所述第I+1级子节点与所述第一DOM树中的所述第I+1级子节点在样式、类型、名称、标识、属性上存在任意一项或任意多项不同,则确定所述第I+1级子节点为变更节点;若所述第I+1级子节点为新增节点、删除节点或变更节点中的任意一种,则确定所述第I+1级子节点为差异节点,若所述标准DOM树中的所述第I+1级子节点与所述第一DOM树中的所述第I+1级子节点在样式、类型、名称、标识、属性上均相同,则确定所述第I+1级子节点为相同节点。
- 根据权利要求1至7中任一项所述的方法,其特征在于,所述根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放,包括:将所述测试案例插入任务池,所述任务池用于存储待执行的一个或多个测试案例;从多个进程中选取处于空闲状态的第一进程,将所述测试案例发送给所述第一进程,以使所述第一进程根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放操作,并将所述任务池中的所述测试案例设置为锁定状态。
- 一种测试装置,其特征在于,所述装置包括:录制模块,用于录制用户对测试界面的操作得到测试案例;所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;回放模块,用于若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放;处理模块,用于在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,对回放得到的第一界面和所述操作对应的标准界面进行渲染。
- 根据权利要求9所述的装置,其特征在于,所述录制模块具体用于:针对所述用户对所述测试界面的任一操作,从所述测试界面对应的DOM树中确定所述用户触发的目标DOM节点;根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,并根据所述目标DOM节点在所述DOM树中的定位标识、所述操作的类型、所述操作的内容、所述操作与上一操作的时间信息生成所述操作对应的测试数据;根据所述用户对所述测试界面的各个操作对应的测试数据生成所述测试案例。
- 根据权利要求10所述的装置,其特征在于,所述录制模块具体用于:判断所述目标DOM节点的标识是否属于第一类型标识,若是,则将所述目标DOM节点的标识作为所述目标DOM节点的定位标识,所述第一类型标识用于在录制和回放时唯一标识所述目标DOM节点;若否,则判断所述目标DOM节点的类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点的类型作为所述目标DOM节点的定位标识,若否,则根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识。
- 根据权利要求11所述的装置,其特征在于,所述录制模块具体用于:判断所述目标DOM节点的父节点是否存在,若不存在,则根据所述目标DOM节点的类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的一级组合类型,判断所述目标DOM节点对应的一级组合类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点对应的一级组合类型作为所述目标DOM节点的定位标识,若否,则判断所述目标DOM节点的父节点的父节点是否存在,若不存在,则根据所述目标DOM节点对应的一级组合类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的父节点的类型、所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的二级组合类型,并根据所述目标DOM节点对应的二级组合类型确定所述目标DOM节点的定位标识。
- 根据权利要求11所述的装置,其特征在于,所述录制模块具体用于:若所述目标DOM节点的标识由数字组成,则确定所述目标DOM节点的标识不属于所述第一类型标识,若所述目标DOM节点的标识包括数字以外的字符,则确定所述目标DOM节点的标识属于所述第一类型标识。
- 根据权利要求9所述的装置,其特征在于,所述处理模块具体用于:解析所述第一界面得到第一DOM树,解析所述标准界面得到标准DOM树;针对于所述第一DOM树和所述标准DOM树的第I级节点层中的任一差异节点,根据所述差异节点在所述第一DOM树和所述标准DOM树中的区别生成所述差异节点对应的差异数据;针对于所述第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定所述相同节点存在连接的第I+1级子节点,则对比所述第一DOM树和所述标准DOM树中所述相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点;其中,I为大于0的整数;根据各级节点层中各个差异节点对应的差异数据,在所述第一界面和所述标准界面上对所述各个差异节点对应的元素进行渲染,得到所述操作对应的测试结果。
- 根据权利要求14所述的装置,其特征在于,所述处理模块具体用于:若所述标准DOM树中不存在所述第I+1级子节点且所述第一DOM树中存在所述第I+1级子节点,则确定所述第I+1级子节点为新增节点;若所述标准DOM树中存在所述第I+1级子节点且所述第一DOM树中不存在所述第I+1级子节点,则确定所述第I+1级子节点为删除节点;若所述标准DOM树中的所述第I+1级子节点与所述第一DOM树中的所述第I+1级子节点在样式、类型、名称、标识、属性上存在任意一项或任意多项不同,则确定所述第I+1级子节点为变更节点;若所述第I+1级子节点为新增节点、删除节点或变更节点中的任意一种,则确定所述第I+1级子节点为差异节点,若所述标准DOM树中的所述第I+1级子节点与所述第一DOM树中的所述第I+1级子节点在样式、类型、名称、标识、属性上均相同,则确定所述第I+1级子节点为相同节点。
- 根据权利要求9至15中任一项所述的装置,其特征在于,所述回放模块具体用于:将所述测试案例插入任务池,所述任务池用于存储待执行的一个或多个测试案例;从多个进程中选取处于空闲状态的第一进程,将所述测试案例发送给所述第一进程,以使所述第一进程根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放操作,并将所述任务池中的所述测试案例设置为锁定状态。
- 一种计算设备,其特征在于,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行权利要求1~8任一权利要求所述的方法。
- 一种计算机可读存储介质,其特征在于,其存储有可由计算设备执行的计算机程序,当所述程序在所述计算设备上运行时,使得所述计算设备执行权利要求1~8任一权利要求所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911072997.0 | 2019-11-05 | ||
CN201911072997.0A CN110928772B (zh) | 2019-11-05 | 2019-11-05 | 一种测试方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021088724A1 true WO2021088724A1 (zh) | 2021-05-14 |
Family
ID=69852387
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/125167 WO2021088724A1 (zh) | 2019-11-05 | 2020-10-30 | 一种测试方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110928772B (zh) |
WO (1) | WO2021088724A1 (zh) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113312259A (zh) * | 2021-05-26 | 2021-08-27 | 深圳前海微众银行股份有限公司 | 一种接口测试方法及装置 |
CN113392007A (zh) * | 2021-06-17 | 2021-09-14 | 网易(杭州)网络有限公司 | 一种兼容性测试的方法及装置 |
CN113485909A (zh) * | 2021-06-01 | 2021-10-08 | 杭州网易云音乐科技有限公司 | 测试方法、装置、计算设备以及介质 |
CN114978360A (zh) * | 2022-05-10 | 2022-08-30 | 紫光计算机科技有限公司 | 通信设备的自动化测试方法和装置、电子设备和存储介质 |
Families Citing this family (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110928772B (zh) * | 2019-11-05 | 2022-03-08 | 深圳前海微众银行股份有限公司 | 一种测试方法及装置 |
CN111767217B (zh) * | 2020-06-24 | 2024-02-02 | 中国工商银行股份有限公司 | Js单元测试案例生成方法及装置 |
CN111857932A (zh) * | 2020-07-27 | 2020-10-30 | 成都安恒信息技术有限公司 | 一种基于puppeteer用于运维审计系统的web代填方法 |
CN111881043B (zh) * | 2020-07-27 | 2022-10-14 | 山石网科通信技术股份有限公司 | 页面测试方法、装置、存储介质和处理器 |
CN112116439A (zh) * | 2020-08-10 | 2020-12-22 | 杭州优行科技有限公司 | 一种清结算测试方法、装置、终端及存储介质 |
CN113032229B (zh) * | 2021-02-24 | 2022-09-20 | 山东英信计算机技术有限公司 | 一种java性能测试方法、系统及介质 |
CN112817866A (zh) * | 2021-02-25 | 2021-05-18 | 北京百家科技集团有限公司 | 录制回放方法、装置、系统、计算机设备以及存储介质 |
CN113238949A (zh) * | 2021-05-19 | 2021-08-10 | 北京仁科互动网络技术有限公司 | 一种测试方法、装置、电子设备及存储介质 |
CN113901365A (zh) * | 2021-05-29 | 2022-01-07 | 长沙市到家悠享家政服务有限公司 | 性能压测平台及方法、电子设备及可读介质 |
CN113901360A (zh) * | 2021-10-25 | 2022-01-07 | 联想(北京)有限公司 | 一种数据处理方法、装置及电子设备 |
CN114297076A (zh) * | 2021-12-30 | 2022-04-08 | 四川启睿克科技有限公司 | 一种Web网站自动化测试方法 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102419732A (zh) * | 2011-12-27 | 2012-04-18 | Tcl集团股份有限公司 | 基于android平台的自动化测试方法及测试工具 |
CN104598232A (zh) * | 2015-01-12 | 2015-05-06 | 北京大学 | 一种Web应用跨设备捕捉-回放方法 |
US20180307466A1 (en) * | 2015-04-22 | 2018-10-25 | Salesforce.Com, Inc. | Systems and methods of implementing extensible browser executable components |
CN109684220A (zh) * | 2018-12-26 | 2019-04-26 | 苏州博纳讯动软件有限公司 | 一种基于事件回放的浏览器兼容性分析方法 |
CN110928772A (zh) * | 2019-11-05 | 2020-03-27 | 深圳前海微众银行股份有限公司 | 一种测试方法及装置 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103562927B (zh) * | 2011-05-31 | 2016-06-01 | 惠普发展公司,有限责任合伙企业 | 自动化安全测试 |
US9785637B2 (en) * | 2014-03-18 | 2017-10-10 | Google Inc. | System and method for computing, applying, and displaying document deltas |
CN105740154A (zh) * | 2016-03-03 | 2016-07-06 | 北京白鹭时代信息技术有限公司 | 一种网页游戏测试脚本生成方法及装置 |
CN108415702B (zh) * | 2018-01-22 | 2021-05-25 | 北京奇艺世纪科技有限公司 | 一种移动终端应用界面动态渲染方法和装置 |
CN109144856A (zh) * | 2018-07-27 | 2019-01-04 | 北京皮尔布莱尼软件有限公司 | 一种ui自动化测试方法、计算设备及存储介质 |
-
2019
- 2019-11-05 CN CN201911072997.0A patent/CN110928772B/zh active Active
-
2020
- 2020-10-30 WO PCT/CN2020/125167 patent/WO2021088724A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102419732A (zh) * | 2011-12-27 | 2012-04-18 | Tcl集团股份有限公司 | 基于android平台的自动化测试方法及测试工具 |
CN104598232A (zh) * | 2015-01-12 | 2015-05-06 | 北京大学 | 一种Web应用跨设备捕捉-回放方法 |
US20180307466A1 (en) * | 2015-04-22 | 2018-10-25 | Salesforce.Com, Inc. | Systems and methods of implementing extensible browser executable components |
CN109684220A (zh) * | 2018-12-26 | 2019-04-26 | 苏州博纳讯动软件有限公司 | 一种基于事件回放的浏览器兼容性分析方法 |
CN110928772A (zh) * | 2019-11-05 | 2020-03-27 | 深圳前海微众银行股份有限公司 | 一种测试方法及装置 |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113312259A (zh) * | 2021-05-26 | 2021-08-27 | 深圳前海微众银行股份有限公司 | 一种接口测试方法及装置 |
CN113312259B (zh) * | 2021-05-26 | 2023-12-29 | 深圳前海微众银行股份有限公司 | 一种接口测试方法及装置 |
CN113485909A (zh) * | 2021-06-01 | 2021-10-08 | 杭州网易云音乐科技有限公司 | 测试方法、装置、计算设备以及介质 |
CN113485909B (zh) * | 2021-06-01 | 2023-10-27 | 杭州网易云音乐科技有限公司 | 测试方法、装置、计算设备以及介质 |
CN113392007A (zh) * | 2021-06-17 | 2021-09-14 | 网易(杭州)网络有限公司 | 一种兼容性测试的方法及装置 |
CN113392007B (zh) * | 2021-06-17 | 2023-09-08 | 网易(杭州)网络有限公司 | 一种兼容性测试的方法及装置 |
CN114978360A (zh) * | 2022-05-10 | 2022-08-30 | 紫光计算机科技有限公司 | 通信设备的自动化测试方法和装置、电子设备和存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN110928772B (zh) | 2022-03-08 |
CN110928772A (zh) | 2020-03-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021088724A1 (zh) | 一种测试方法及装置 | |
US10810074B2 (en) | Unified error monitoring, alerting, and debugging of distributed systems | |
CN109697066B (zh) | 实现数据表拼接及自动训练机器学习模型的方法和系统 | |
CN110457190B (zh) | 一种基于区块链的全链路监控方法、装置及系统 | |
US8731998B2 (en) | Three dimensional visual representation for identifying problems in monitored model oriented business processes | |
CN109739855B (zh) | 实现数据表拼接及自动训练机器学习模型的方法和系统 | |
US8495008B2 (en) | Application-aware recording and replay | |
CA2739231A1 (en) | System and method for analytic process design | |
KR20120115478A (ko) | 트랜잭션 트레이스 그래프와 논리적 서브시스템들의 맵 사이의 관계들을 시각화하는 방법 | |
KR20120115477A (ko) | 트랜잭션을 논리적 서브시스템들의 맵을 통하는 흐름들로서 시각화하는 방법 | |
US11436133B2 (en) | Comparable user interface object identifications | |
CN107003931B (zh) | 将测试验证从测试执行分离 | |
WO2017044069A1 (en) | Automatic regression identification | |
WO2016178661A1 (en) | Determining idle testing periods | |
CN115576974B (zh) | 数据处理方法、装置、设备和介质 | |
KR20150118963A (ko) | 큐 모니터링 및 시각화 | |
CN113987393A (zh) | 一种网页操作记录器、系统、装置及方法 | |
CN105468511A (zh) | 网页脚本错误定位方法及装置 | |
CN111966587A (zh) | 数据采集方法、装置和设备 | |
US9164746B2 (en) | Automatic topology extraction and plotting with correlation to real time analytic data | |
US11119899B2 (en) | Determining potential test actions | |
CN113485909A (zh) | 测试方法、装置、计算设备以及介质 | |
US20180219752A1 (en) | Graph search in structured query language style query | |
CN116069649A (zh) | 页面测试方法、装置、设备及介质 | |
CN113706098B (zh) | 基于业务的偏差原因识别方法、装置及电子设备 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20884398 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20884398 Country of ref document: EP Kind code of ref document: A1 |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 210922) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20884398 Country of ref document: EP Kind code of ref document: A1 |