WO2021088724A1 - 一种测试方法及装置 - Google Patents

一种测试方法及装置 Download PDF

Info

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
Application number
PCT/CN2020/125167
Other languages
English (en)
French (fr)
Inventor
万纯
林挺
卢道和
Original Assignee
深圳前海微众银行股份有限公司
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 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021088724A1 publication Critical patent/WO2021088724A1/zh

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/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/03Credit; 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

一种测试方法及装置,其中方法包括:录制用户对测试界面的操作得到测试案例,若确定对测试案例进行测试,则根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放,在每个DOM节点对应的操作回放结束后,对回放得到的第一界面和操作对应的标准界面进行渲染。通过设置每个操作结束后自动执行断言,可以无需用户手动地设置断言条件,即使无编程能力的用户也可以使用该方法进行前端界面测试,使用门槛低,自动化测试的程度较高。且,通过对第一界面和标准界面进行渲染,使得用户能够直观地查看到测试结果中的差异数据,相比于现有的测试方法给出测试报告的方式来说,用户的体验更好。

Description

一种测试方法及装置
相关申请的交叉引用
本申请要求在2019年11月05日提交中国专利局、申请号为201911072997.0、申请名称为“一种测试方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及金融科技(Fintech)技术领域,尤其涉及一种测试方法及装置。
背景技术
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变。然而,由于金融行业的安全性、实时性要求,金融科技也对技术提出了更高的要求。前端界面测试是金融界面开发的一项常规操作,传统的界面测试方法通常需要预先安排测试人员,由测试人员在每次界面测试的过程中重复点击测试界面上的文档对象模型(document object model,DOM)节点。然而,该种方式极为依赖人工操作,不仅测试的效率较低,还可能会由于人为操作的偶然性导致测试的结果不准确。
为了解决上述问题,在一种可能的实现方式中,可以使用现有的自动化测试软件实现自动化的界面测试工作。现有的自动化测试软件比如包括sikuli软件、selenium软件、katalon软件等。然而,这些软件通常需要用户具有一定的编程能力,从而导致其自动化测试的程度低,用户的使用体验不好。比如selenium软件通常需要人为设置断言条件,用户需要使用selenium软件支持的编程语言在selenium软件界面中输入控制断言条件的语句,如此,selenium软件在执行界面测试时才会在满足断言条件的位置进行断言。若用户未设置控制断言条件的语句或者用户设置的语句有误,则selenium软件无法得到准确的测试结果。
综上,目前亟需一种测试方法,用以解决现有的自动化测试软件由于需要用户具有一定的编程能力所导致的自动化测试的程度低、用户的体验不好的技术问题。
发明内容
本发明提供一种测试方法及装置,用以解决现有的自动化测试软件由于需要用户具有一定的编程能力所导致的自动化测试的程度低、用户的体验不好的技术问题。
第一方面,本发明提供一种测试方法,包括:录制用户对测试界面的操作得到测试案例,测试案例包括用户对测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;进一步地,若确定对测试案例进行测试,则根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放,并在每个DOM节点对应的操作回放结束后,根据操作对应的测试结果,对回放得到的第一界面和操作对应的标准界面进行渲染。在上述设计中,通过设置对每个DOM节点的操作结束后自动执行断言,可以无需用户手动地设置断言条件,如此,无编程能力的用户也可以使用该方法进行前端界面测试,从而使用门槛低,自动化测试的程度较高。且,通过设置每个DOM节点的操作回放结束后,根据回放操作的测试结果对第一界面和标准界面进行渲染,可以使得用户直观地查看到测试结果中的差异数据,相比于现有的测试方法给出复杂的测试报告的方式来说,用户的体验更 好,且更浅显易懂。
在一种可能的设计中,录制用户对测试界面的操作得到测试案例,包括:针对用户对测试界面的任一操作,先从测试界面对应的DOM树中确定用户触发的目标DOM节点,再根据目标DOM节点的标识、类型和/或目标DOM节点在DOM树中的层级关系确定目标DOM节点在DOM树中的定位标识,并根据目标DOM节点在DOM树中的定位标识、操作的类型、操作的内容、操作与上一操作的时间信息生成操作对应的测试数据,最后根据用户对测试界面的各个操作对应的测试数据生成测试案例。在上述设计中,通过使用目标DOM节点的标识、类型和/或目标DOM节点在DOM树中的层级关系确定目标DOM节点在DOM树中的定位标识,可以根据实际情况选择较为简单的计算条件来计算目标DOM节点的定位标识,相比于现有的测试方法直接根据目标DOM节点在DOM树中的层级关系得到目标DOM节点的方式来说,可以无需对每个DOM节点执行较为复杂的计算过程,从而可以降低计算复杂度。
在一种可能的设计中,根据目标DOM节点的标识、类型和/或目标DOM节点在DOM树中的层级关系确定目标DOM节点在DOM树中的定位标识,包括:先判断目标DOM节点的标识是否属于第一类型标识,若是,则将目标DOM节点的标识作为目标DOM节点的定位标识,若否,则再判断目标DOM节点的类型是否为DOM树中的唯一类型,若是,则将目标DOM节点的类型作为目标DOM节点的定位标识,若否,则根据目标DOM节点在DOM树中的层级关系确定目标DOM节点的定位标识。其中,第一类型标识用于在录制和回放时唯一标识目标DOM节点。在上述设计中,通过设置先标识、再类型、最后层级关系的计算逻辑,可以快速地计算出目标DOM节点的定位标识,相比于现有技术使用目标DOM节点的绝对路径来计算每个目标DOM节点的定位标识的方式来说,可以极大地降低计算复杂度,提高测试的效率。
在一种可能的设计中,根据目标DOM节点在DOM树中的层级关系确定目标DOM节点的定位标识,包括:先判断目标DOM节点的父节点是否存在,若不存在,则再根据目标DOM节点的类型在DOM树中的顺序确定目标DOM节点的定位标识。若存在,则组合目标DOM节点的父节点的类型、目标DOM节点的类型,得到目标DOM节点对应的一级组合类型,再判断目标DOM节点对应的一级组合类型是否为DOM树中的唯一类型,若是,则将目标DOM节点对应的一级组合类型作为目标DOM节点的定位标识,若否,则最后判断目标DOM节点的父节点的父节点是否存在,若不存在,则根据目标DOM节点对应的一级组合类型在DOM树中的顺序确定目标DOM节点的定位标识,若存在,则组合目标DOM节点的父节点的父节点的类型、目标DOM节点的父节点的类型、目标DOM节点的类型,得到目标DOM节点对应的二级组合类型,并根据目标DOM节点对应的二级组合类型确定目标DOM节点的定位标识。在上述设计中,通过逐次调用父节点得到目标DOM节点对应的组合类型,并在组合类型唯一时直接将组合类型作为定位标识,在组合类型不唯一时调用更上一级父节点得到组合类型,可以根据距离目标DOM节点较近的父节点快速地确定其定位标识,而无需使用目标DOM节点在DOM树中的完整路径确定其定位标识,从而可以在保证定位标识唯一的基础上,降低测试所需处理的数据量,提高测试的效率。
在一种可能的设计中,判断目标DOM节点的标识是否为第一类型标识,包括:若目标DOM节点的标识由数字组成,则确定目标DOM节点的标识不属于第一类型标识。若目标DOM节点的标识包括数字以外的字符,则确定目标DOM节点的标识属于第一类型标识。 在上述设计中,时间戳、设备标识等均是由数字组成,若将时间戳或设备标识作为目标DOM节点的标识,则在录制和回放时由于时间戳不同,或者在不同的测试服务器上执行录制和回放,则目标DOM节点的标识会发生改变,从而导致回放操作时无法根据目标DOM节点的标识定位到录制的目标DOM节点。据此,通过设置第一类型标识包含数字以外的字符,可以明确地判断目标DOM节点的标识是否属于无意义的标识,从而可以避免采用第一类型标识作为定位标识所导致的回放阶段查询不到目标DOM节点的问题,提高测试的准确性。
在一种可能的设计中,根据操作对应的测试结果,对回放得到的第一界面和操作对应的标准界面进行渲染,包括:先解析第一界面得到第一DOM树,再解析标准界面得到标准DOM树,针对于第一DOM树和标准DOM树的第I级节点层中的任一差异节点,根据差异节点在第一DOM树和标准DOM树中的区别生成差异节点对应的差异数据,根据各级节点层中各个差异节点对应的差异数据,在第一界面和标准界面上对各个差异节点对应的元素进行渲染,得到操作对应的测试结果。针对于第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定相同节点存在连接的第I+1级子节点,则对比第一DOM树和标准DOM树中相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点。其中,I为大于0的整数。在上述设计中,每执行一次回放操作即可执行一次对比,并根据对比的结果对本次操作对应的回放界面和标准界面进行渲染,从而用户可以直观地根据回放界面和标准界面确定本次操作的结果是否准确,相比于现有技术需要人为设置断言条件且用户仅能看到复杂的测试报告的方式来说,上述设计可以极大地减轻人为工作量,提高测试效率,降低了测试成本。
在一种可能的设计中,根据对比结果判断任一第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级子节点为相同节点。
在一种可能的设计中,根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放,包括:先将测试案例插入任务池,再从多个进程中选取处于空闲状态的第一进程,将测试案例发送给第一进程,以使第一进程根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放操作,并将任务池中的测试案例设置为锁定状态。其中,任务池用于存储待执行的一个或多个测试案例。在上述设计中,通过设置多个进程并行地执行测试任务,可以较好地提高前端界面的测试效率。
第二方面,本发明提供一种测试装置,该装置包括:录制模块,用于录制用户对测试界面的操作得到测试案例,测试案例包括用户对测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;回放模块,用于在确定对测试案例进行测试的情况下,根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放;处理模块,用于在每个DOM节点对应的操作回放结束后,根据对操作进行回放得到的第一界面和操作对应的标准界面,生成操作对应的测试结果。
在一种可能的设计中,录制模块具体用于:针对用户对测试界面的任一操作,先从测试界面对应的DOM树中确定用户触发的目标DOM节点,再根据目标DOM节点的标识、类型和/或目标DOM节点在DOM树中的层级关系确定目标DOM节点在DOM树中的定位标识,并根据目标DOM节点在DOM树中的定位标识、操作的类型、操作的内容、操作与上一操作的时间信息生成操作对应的测试数据,最后根据用户对测试界面的各个操作对应的测试数据生成测试案例。
在一种可能的设计中,录制模块具体用于:先判断目标DOM节点的标识是否属于第一类型标识,若是,则将目标DOM节点的标识作为目标DOM节点的定位标识。若否,则再判断目标DOM节点的类型是否为DOM树中的唯一类型,若是,则将目标DOM节点的类型作为目标DOM节点的定位标识,若否,则根据目标DOM节点在DOM树中的层级关系确定目标DOM节点的定位标识。其中,第一类型标识用于在录制和回放时唯一标识目标DOM节点。
在一种可能的设计中,录制模块具体用于:先判断目标DOM节点的父节点是否存在,若不存在,则根据目标DOM节点的类型在DOM树中的顺序确定目标DOM节点的定位标识。若存在,则组合目标DOM节点的父节点的类型、目标DOM节点的类型,得到目标DOM节点对应的一级组合类型,并判断目标DOM节点对应的一级组合类型是否为DOM树中的唯一类型。若是,则将目标DOM节点对应的一级组合类型作为目标DOM节点的定位标识,若否,则再判断目标DOM节点的父节点的父节点是否存在。若不存在,则根据目标DOM节点对应的一级组合类型在DOM树中的顺序确定目标DOM节点的定位标识,若存在,则组合目标DOM节点的父节点的父节点的类型、目标DOM节点的父节点的类型、目标DOM节点的类型,得到目标DOM节点对应的二级组合类型,并根据目标DOM节点对应的二级组合类型确定目标DOM节点的定位标识。
在一种可能的设计中,录制模块具体用于:若目标DOM节点的标识由数字组成,则确定目标DOM节点的标识不属于第一类型标识。若目标DOM节点的标识包括数字以外的字符,则确定目标DOM节点的标识属于第一类型标识。
在一种可能的设计中,处理模块具体用于:先解析第一界面得到第一DOM树,再解析标准界面得到标准DOM树,针对于第一DOM树和标准DOM树的第I级节点层中的任一差异节点,根据差异节点在第一DOM树和标准DOM树中的区别生成差异节点对应的差异数据,根据各级节点层中各个差异节点对应的差异数据,在第一界面和标准界面上对各个差异节点对应的元素进行渲染,得到操作对应的测试结果。针对于第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定相同节点存在连接的第I+1级子节点,则对比第一DOM树和标准DOM树中相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点。其中,I为大于0的整数。
在一种可能的设计中,处理模块具体用于:若标准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级子节点为相同节点。
在一种可能的设计中,回放模块具体用于:先将测试案例插入任务池,再从多个进程中选取处于空闲状态的第一进程,将测试案例发送给第一进程,以使第一进程根据用户对一个或多个DOM节点进行操作的操作信息对测试界面进行回放操作,并将任务池中的测试案例设置为锁定状态。其中,任务池用于存储待执行的一个或多个测试案例。
第三方面,本发明提供一种计算设备,包括至少一个处理单元以及至少一个存储单元,其中,存储单元存储有计算机程序,当程序被处理单元执行时,使得处理单元执行上述第一方面任意所述的测试方法。
第四方面,本发明提供一种计算机可读存储介质,其存储有可由计算设备执行的计算机程序,当程序在计算设备上运行时,使得计算设备执行上述第一方面任意所述的测试方法。
本发明的这些方面或其他方面在以下实施例的描述中会更加简明易懂。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种测试方法对应的流程示意图;
图2为本发明实施例提供的一种服务界面的界面示意图;
图3为本发明实施例提供的一种测试界面对应的DOM树的结构示意图;
图4为本发明实施例提供的一种确定目标DOM节点的定位标识的方法对应的流程示意图;
图5为本发明实施例提供的一种可能的案例归类器的界面示意图;
图6为本发明实施例提供的一种Chrome录制插件的界面示意图;
图7为本发明实施例提供的一种测试装置的结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
金融科技(Fintech)技术领域通常涉及到多种业务。比如,银行的业务可以包括售卡业务、存款业务、贷款业务、保险业务和理财业务等,银行每天的业务量可以达到数千笔甚至数万笔。一般来说,银行除了可以在银行所在地进行实地业务外,还可以在网络设置业务对应的前端页面,通过业务对应的前端页面向用户提供相应的业务。比如银行通过设置贷款交易对应的前端界面,使用户可以直接在贷款交易对应的前端界面上进行贷款操作,以便于用户更为便捷地办理贷款业务。
在前端页面的研发过程中,当需要对前端页面进行版本升级或故障维护时,研发人员通常可以修正旧版本的前端页面程序或者基于旧版本的前端页面程序生成新程序。然而, 改动的程序可能会导致界面上的元素错位或者节点功能异常,比如DOM节点的样式改变、DOM节点的属性变更、DOM节点的内容乱码等。因此,界面测试是前端页面的研发过程中不可或缺的一环。界面测试是指通过点击测试界面上的DOM节点确定该DOM节点的样式、内容、位置、功能等相对于标准DOM节点是否发生异常。通过执行界面测试,可以将程序更新过程所导致的异常DOM节点检测出来,从而能够保证前端页面研发的顺利进行。
在一种可能的实现方式中,可以使用Selenium软件进行自动化的界面测试过程,Selenium软件包含四个独立的脚本文件,分别为录制脚本文件、回放脚本文件、断言脚本文件和测试结果脚本文件。相应地,基于Selenium软件的自动化测试过程具体包括录制阶段、回放阶段、断言阶段和测试结果阶段,每个阶段均需要用户使用Selenium软件支持的编程语言调用该阶段的脚本文件。这四个阶段的具体实现过程如下所示:
录制阶段
当用户使用Selenium软件支持的编程语言调用录制阶段的脚本文件后,测试服务器启动录制阶段。在录制阶段,用户可以手动地点击测试界面上的各个DOM节点,对应的,测试服务器会依次记录用户对测试界面上的每个DOM节点进行点击的操作信息,从而将测试界面的变化情况录制成测试案例。举例来说,若用户依次点击了测试界面上的DOM节点A2、DOM节点A1和DOM节点A3,则Selenium软件可以依次记录用户对这三个DOM节点的操作信息,并可以根据用户对这三个DOM节点的操作信息生成测试案例。其中,用户对每个DOM节点的操作信息可以包括该DOM节点的位置信息和用户对该DOM节点的操作类型,如此,测试案例中可以包括用户所操作的每个DOM节点的顺序、位置信息和操作类型。具体实施中,Selenium软件可以使用Xpath方案确定每个DOM节点的位置信息,即先根据测试界面得到测试界面对应的DOM树,然后再根据该DOM节点在测试界面对应的DOM树中的绝对路径得到该DOM节点的位置信息,比如将DOM树中根节点至该DOM节点的路径所包括的DOM节点的标识进行组合,将组合得到的标识作为该DOM的位置信息。
回放阶段
当用户使用Selenium软件支持的编程语言调用回放阶段的脚本文件后,测试服务器启动回放阶段。在回放阶段,测试服务器可以先获取录制阶段生成的测试案例,再按照测试案例依次回放用户对多个DOM节点的操作信息。具体地说,针对于任一操作信息,测试服务器可以先根据DOM节点的位置信息从测试界面中找到该DOM节点,然后根据录制阶段的操作类型对该DOM节点进行回放操作,比如若录制阶段对该DOM节点的操作类型为点击,则回放阶段也可以在测试界面上点击该DOM节点。
断言阶段
断言阶段和回放阶段可以并行执行,断言阶段的断言条件可以由用户设置。如此,测试服务器在执行回放阶段时还可以根据用户设置的断言条件进行断言。具体地说,当用户使用Selenium软件支持的编程语言调用断言阶段的脚本文件后,测试服务器可以响应给用户一个断言界面,用户可以在断言界面上输入断言条件,从而触发测试服务器根据断言条件进行断言。比如,若用户设置对DOM节点A2进行断言,则测试服务器可以在对DOM节点A2进行操作后,对比操作后的界面与标准界面,以确定出DOM节点A2的样式、内容或功能等是否异常。
测试结果阶段
当用户使用Selenium软件支持的编程语言调用测试结果阶段的脚本文件后,测试服务 器可以响应给用户测试结果报告。其中,测试结果报告中可以包括用户设置了断言条件的DOM节点的测试结果,测试结果可以包括测试正常或测试异常,且测试结果报告可以为文本的形式显示给用户。举例来说,若DOM节点A2、DOM节点A1和DOM节点A3均设置了断言条件,而测试结果报告为DOM节点A2测试异常、DOM节点A1测试正常、DOM节点A3测试异常,则用户可以根据该测试结果报告修复DOM节点A2和DOM节点A3。
根据上述内容可知,虽然Selenium软件可以自动完成界面测试,但是由于用户需要使用Selenium软件所支持的编程语言调用每个阶段对应的脚本文件,因此用户需要熟练地掌握Selenium软件所支持的编程语言。这会导致开发难度大,用户的体验不好。也就是说,Selenium软件的自动化程度并不高,无法实现完整意义上的自动化页面测试。此外,基于Selenium软件的自动化测试过程还存在如下缺点:
(1)在录制阶段,Selenium软件基于Xpath方案对每个DOM节点进行定位。然而,由于Xpath方案需要使用DOM节点在DOM树中的绝对路径确定DOM节点的位置信息,从而该种方式对每个DOM节点均需要执行较为复杂的路径确定过程,从而会使得定位DOM节点需要较长的时间,界面测试的效率较低;
(2)Selenium软件将DOM树中DOM节点的标识组合作为DOM节点的位置信息。然而,在大多数情况下,DOM节点的标识可能是无意义的标识,比如时间戳,录制阶段和回放阶段由于时间戳不同会导致同一DOM节点的标识不同。因此,若该种方式根据无意义的标识得到DOM节点的位置信息,可能会使得回放过程中查询不到DOM节点,从而使得测试过程出错,测试的准确性低;
(3)在断言阶段,Selenium软件仅能根据用户设置的断言条件对某一个或某几个DOM节点进行断言。一方面,该方法需要用户手动补充断言条件,导致自动化程序不高。另一方面,由于用户通过编写DOM节点的标识设置对该DOM节点的断言条件,因此可移植性差,无法为每个DOM节点设置通用的断言条件;
(4)Selenium软件对每个DOM节点的测试结果为测试过程成功或测试失败,而无法给出具体的测试结果,这导致用户无法直观地查看到DOM节点的异常信息,从而不利于用户的故障修复过程。
基于此,本发明提供了一种测试方法,用以在提高界面测试的效率、提高测试的准确性及可移植性的基础上,实现一套通用且完整的自动化测试过程。
图1为本发明实施例提供的一种测试方法对应的流程示意图,该方法应用于测试服务器,该方法包括:
步骤101,录制用户对测试界面的操作得到测试案例。
具体实施中,测试服务器上可以设置有服务界面,服务界面为基于全球广域网(world wide web,web)服务器和web浏览器的界面,服务界面上可以包含多个功能图标。在接收到用户在web浏览器上输入的服务界面对应的链接时,测试服务器可以向用户提供服务界面。若检测到用户点击服务界面上的功能图标,测试服务器还可以通过web浏览器执行功能图标对应的功能。
图2为本发明实施例提供的一种服务界面的示意图,如图2所示,服务界面上可以设置有录制子界面和服务子界面,录制子界面上可以设置有“录制插件”的功能按钮,服务子界面上可以设置有“案例管理”的功能按钮、“回放”的功能按钮以及“差异展示”的功能按钮。具体实施中,当用户在web浏览器上输入服务界面对应的链接后,测试服务器可以先通过 web浏览器将录制子界面显示给用户,或者也可以将录制子界面和服务子界面同时显示给用户。进一步地,若检测到用户点击录制子界面上的“录制插件”的功能按钮,则测试服务器可以将web浏览器上的录制子界面转换为测试界面,并可以启动预设录制插件来录制用户对测试界面的操作信息,得到录制脚本。当接收到用户触发的结束录制的消息后,测试服务器可以将录制脚本转化为测试案例,并可以添加在服务子界面所管理的案例中。其中,预设录制插件可以为具有界面录制功能的任一类型的插件,比如Chrome录制插件、Unity3D录制插件等,具体不作限定。
需要说明的是,上述仅是一种示例性的简单说明,并不构成对方案的限定。在具体实施中,功能按钮可以设置服务界面上,也可以设置在测试界面上,不作限定。在上述示例中,由于功能按钮设置在服务界面上,因此检测到用户触发“录制插件”的功能按钮后,测试服务器可以自动从服务界面跳转到测试界面,并录制用户对测试界面的操作信息得到录制脚本。相应地,若功能按钮设置在测试界面上,则检测到用户触发“录制插件”的功能按钮后,测试服务器可以直接录制用户对测试界面的操作信息得到录制脚本。
本发明实施例中,当接收到测试服务器的启动指令后,预设录制插件可以先解析测试界面得到测试界面对应的DOM树。DOM树中可以包括具有层级关系的多个DOM节点,任一DOM节点连接的上一级节点称为该DOM节点的父节点,任一DOM节点连接的下一级节点称为该DOM节点的子节点。一个DOM节点可以具有一个父节点,且可以具有多个子节点。其中,每个DOM节点可以对应测试界面上的一个元素,每个DOM节点可以具有对应的样式、内容、属性和位置等信息。
图3为本发明实施例提供的一种测试界面对应的DOM树的结构示意图,如图3所示,该测试界面对应的DOM树中可以包括第一级节点层、第二级节点层、第三级节点层和第四级节点层。其中,第一级节点层中可以设置有DOM节点B 1,DOM节点B1的类型为Document。第二级节点层中可以设置有DOM节点B 21、DOM节点B 22和DOM节点B 23,DOM节点B 21的类型为Element,DOM节点B 22的类型为Entity,DOM节点B 23的类型为Notation。第三级节点层中可以设置有DOM节点B 31、DOM节点B 32和DOM节点B 33,DOM节点B 31的类型为Element,DOM节点B 32的类型为Notation,DOM节点B 33的类型为Element。第四级节点层中可以设置有DOM节点B 41,DOM节点B 41的类型为Notation。
本发明实施例中,第一级节点层中的节点称为根节点,与根节点连接的第二级节点层中的节点称为根节点的第一级子节点,根节点称为连接的第二级节点层中的节点的第一级父节点。相应地,第三级节点层中的节点称为所连接的第二级节点层中节点的第一级子节点,即根节点的第二级子节点,所连接的第二级节点层中的节点称为第三级节点层中的节点的第一级父节点,根节点称为第三级节点层中的节点的第二级父节点。举例来说,如图3所示,DOM节点B 1为根节点,DOM节点B 21为DOM节点B 1的第一级子节点,且为DOM节点B 31的第一级父节点,为DOM节点B 41的第二级父节点。
需要说明的是,图3仅是一种示例性的简单说明,其仅示意出了各个DOM节点之间的层级关系及类型,并未示意每个DOM节点的属性、样式等信息。该示意仅是为了便于说明方案,并不构成对方案的限定。在具体实施中,DOM树的结构可以根据实际需要进行设置,具体不作限定。
在一种可能的实现方式中,在解析测试界面得到测试界面对应的DOM树后,预设录制插件可以按照如下方式录制用户对测试界面的操作信息得到录制脚本:针对于用户对测试 界面的任一操作,先确定用户在测试界面对应的DOM树中所触发的目标DOM节点,再根据目标DOM节点的标识、类型或目标DOM节点在DOM树中的层级关系得到目标DOM节点在DOM树中的定位标识,并根据目标DOM节点的定位标识、操作的类型、操作的内容、操作与上一操作的时间信息生成该操作对应的录制脚本,之后,当接收到用户触发录制结束的消息时,根据用户对测试界面的各个操作对应的录制脚本得到该次录制对应的测试案例。
下面以一个具体的示例进行说明,在该示例中,测试界面为HTML5浏览器上的页面、预设录制插件为Chrome录制插件:具体实施中,当接收到测试服务器发送的启动指令后,Chrome录制插件可以先缓存测试界面对应的DOM树中的所有DOM节点的类型和标识,然后可以使用HTML5浏览器的MotationObserver API接口监测测试界面上的DOM节点,若监测到DOM节点的新增变更、DOM节点的删除变更或DOM节点的修改变更,则可以重新解析变更DOM节点后的测试界面得到变更后的DOM树,如此,Chrome录制插件可以重新缓存变更后的DOM树中的所有DOM节点的类型和标识。
在上述示例中,监测DOM节点的变更的方式可以为:Chrome录制插件预先在HTML5浏览器的测试页面上设置埋点事件捕获机制,当检测到某一埋点事件(比如点击事件、双击事件或输入事件)被触发时,可以通过埋点事件捕获机制来捕获到用户的操作(对应为点击操作、双击操作或输入操作)。进一步地,针对于任一捕获到的操作,Chrome录制插件可以获取操作的类型、操作的内容、操作对应的目标DOM节点的定位标识、操作与上次操作的时长等信息,然后基于这些信息生成该操作对应的录制脚本。
本发明实施例中,确定操作对应的目标DOM节点的定位标识的方式可以有多种。图4为本发明实施例提供的一种确定目标DOM节点的定位标识的方法对应的流程示意图,如图4所示,该方法包括:
步骤401,根据用户的操作确定本次操作对应的目标DOM节点,并从预先缓存的各个DOM节点的类型和标识中获取目标DOM节点的类型和标识。
举例来说,接收到测试服务器发送的启动指令后,由于Chrome录制插件会先从测试界面对应的DOM树中将所有DOM节点的类型和标识缓存在浏览器空间中,因此,若确定用户针对于某一DOM节点(比如DOM节点B 22)执行了点击操作,则Chrome录制插件可以直接从浏览器空间中获取DOM节点B 22的类型和标识。其中,DOM节点B 22的标识和类型可以由界面开发人员预先设置,因此Chrome录制插件可以通过调用测试界面的配置文件来获取DOM节点B 22的标识和类型。基于图3所示意的DOM树可知,DOM节点B 22的类型为Entity。
步骤402,判断目标DOM节点的标识是否属于第一类型标识,若是,则执行步骤403,若否,则执行步骤404。
本发明实施例中,第一类型标识用于指示在不同的操作过程中能够唯一标识目标DOM节点的标识。若某一DOM节点的标识属于第一类型标识,则即使在不同的时刻和/或不同的设备上对该DOM节点进行点击,该DOM节点的标识也不会发生变化。
在一种可能的场景中,当DOM节点的标识设置为生成时间戳、循环的数字或随机的数字时,若在不同的时刻和/或不同的设备上对该DOM节点进行点击,则该DOM节点的标识会发生变化。举例来说,以DOM节点的标识为生成时间戳为例,若在录制时点击该DOM节点的时间为10:09,而在回放测试案例时点击该DOM节点的时间为12:10,则在录制和回 放时该DOM节点的标识不同,即回放时无法根据录制时的该DOM节点的标识查询到该DOM节点。
基于该原理,本发明实施例中,若目标DOM节点的标识由数字组成,则可以确定目标DOM节点的标识不属于第一类型标识。若目标DOM节点的标识包括数字以外的字符,则可以确定目标DOM节点的标识属于第一类型标识。本发明实施例中,通过设置第一类型标识包含数字以外的字符,可以明确地判断目标DOM节点的标识是否属于无意义的标识,从而可以避免采用第一类型标识作为定位标识所导致的回放阶段查询不到目标DOM节点的问题,提高测试的准确性。
步骤403,将目标DOM节点的标识作为目标DOM节点的定位标识。
当目标DOM节点的标识属于第一类型标识时,由于该目标DOM节点的标识在不同的操作过程中能够唯一标识该目标DOM节点,说明回放时也可以根据录制时确定的该目标DOM节点的标识找到对应的目标DOM节点,因此,可以直接将该目标DOM节点的标识作为目标DOM节点的定位标识。
步骤404,判断目标DOM节点的类型是否为DOM树中的唯一类型,若是,则执行步骤405,若否,则执行步骤406。
当目标DOM节点的标识不属于第一类型标识时,由于该目标DOM节点的标识在不同的操作过程中无法唯一标识该目标DOM节点,说明回放时无法根据录制时确定的该目标DOM节点的标识找到对应的目标DOM节点,因此,不能直接将目标DOM节点的标识作为该目标DOM节点的定位标识。如此,可以先根据目标DOM节点的类型确定目标DOM节点的定位标识,若无法根据目标DOM节点的类型确定目标DOM节点的定位标识,则可以根据目标DOM节点在DOM树中的层级关系确定目标DOM节点的定位标识。
步骤405,将目标DOM节点的类型作为目标DOM节点的定位标识。
步骤406,判断上一级父节点是否存在,若存在,则执行步骤407,若不存在,则执行步骤410。
步骤407,根据上一级父节点的类型得到目标DOM节点对应的组合类型。
步骤408,判断目标DOM节点对应的组合类型是否为DOM树中的唯一类型,若是,则执行步骤409,若否,则执行步骤406。
步骤409,将目标DOM节点对应的组合类型作为目标DOM节点的定位标识。
步骤410,根据目标DOM节点的类型或目标DOM节点对应的组合类型在DOM树中的顺序确定目标DOM节点的定位标识。
基于图3所示意的DOM树,以一个具体的示例来描述步骤404至步骤410的具体实现过程:
为了便于描述,本发明的下列实施例将组合DOM节点的类型、DOM节点的以一级父节点的类型得到的组合类型称为DOM节点对应的一级组合类型,将组合DOM节点的类型、DOM节点的一级父节点的类型、DOM节点的二级父节点的类型得到的组合类型称为DOM节点对应的二级组合类型,依次递推。
如图3所示,DOM节点B 1的类型为Document、DOM节点B 21的类型为Element、DOM节点B 22的类型为Entity、DOM节点B 23的类型为Notation、DOM节点B 31的类型为Element、DOM节点B 32的类型为Notation、DOM节点B 33的类型为Element、DOM节点B 41的类型为Notation,由于Document类型和Entity类型为DOM树中的唯一类型,因此若目标DOM节点 为DOM节点B 1或DOM节点B 22,则可以直接将目标DOM节点的类型作为目标DOM节点的定位标识。比如,若目标DOM节点为DOM节点B 1,则目标DOM节点的定位标识为Document。或者,若目标DOM节点为DOM节点B 22,则目标DOM节点的定位标识为Entity。
相应地,由于DOM节点B 21、DOM节点B 31和DOM节点B 33的类型均为Element类型,DOM节点B 23、DOM节点B 32和DOM节点B 41的类型均为Notation类型,说明Element类型和Notation类型不为DOM树中的唯一类型。因此,若目标DOM节点为DOM节点B 21、DOM节点B 23、DOM节点B 31、DOM节点B 32、DOM节点B 33或DOM节点B 41中的任意一个DOM节点,则预设录制插件可以先组合目标DOM节点的类型、目标DOM节点的一级父节点的类型得到目标DOM节点对应的一级组合类型,并判断目标DOM节点对应的一级组合类型是否为DOM树中的唯一类型。若是,则可以将目标DOM节点对应的一级组合类型作为目标DOM节点的定位标识,若否,则可以根据目标DOM节点的类型、目标DOM节点的一级父节点的类型、目标DOM节点的二级父节点的类型得到目标DOM节点对应的二级组合类型,然后针对于目标DOM节点对应的二级组合类型执行上述判断过程,直至执行至根节点为止。
举例来说,若目标DOM节点为DOM节点B 31,则可以先组合DOM节点B 31的类型Element、DOM节点B 31的一级父节点DOM节点B 21的类型Element,得到DOM节点B 31对应的一级组合类型Element-Element;由于Element-Element类型是DOM树中的唯一类型,因此可以将DOM节点B 31对应的一级组合类型Element-Element作为DOM节点B 31的定位标识。相应地,若目标DOM节点为DOM节点B 32,则可以先组合DOM节点B 32的类型Notation、DOM节点B 32的一级父节点DOM节点B 21的类型Element,得到DOM节点B 32对应的一级组合类型Element-Notation;由于DOM节点B 41对应的一级组合类型也为Element-Notation,说明Element-Notation类型不是DOM树中的唯一类型,因此,不将DOM节点B 32对应的一级组合类型Element-Notation作为DOM节点B 32的定位标识,而是组合DOM节点B 32的类型Notation、DOM节点B 32的一级父节点DOM节点B 21的类型Element、DOM节点B 32的二级父节点DOM节点B 1的类型Document,得到DOM节点B 32对应的二级组合类型Document-Element-Notation;由于Document-Element-Notation类型为DOM树中的唯一类型,因此,可以将DOM节点B 32对应的二级组合类型Document-Element-Notation作为DOM节点B 32的定位标识。
作为一个示例,假设DOM节点B 23的类型不是Notation而是Element,DOM节点B 33的类型不是Element而是Notation,则由于DOM节点B 33对应的二级组合类型也为Document-Element-Notation,说明Document-Element-Notation不是DOM树中的唯一类型,因此,不将DOM节点B 32对应的二级组合类型Document-Element-Notation作为DOM节点B 32的定位标识。进一步地,查询DOM树发现DOM节点B 32的二级父节点DOM节点B 1为根节点,即DOM节点B 32不存在三级父节点,因此预设录制插件可以根据DOM节点B 32对应的二级组合类型Document-Element-Notation在DOM树中的顺序来确定目标DOM节点对应的定位标识,具体地说,由于DOM节点B 32对应的二级组合类型Document-Element-Notation在DOM树中的顺序为第一位,而DOM节点B 33对应的二级组合类型Document-Element-Notation在DOM树中的顺序为第二位,因此,可以将DOM节点B 32对应的二级组合类型与该组合类型在DOM树中的顺序的结合形式Document-Element-Notation-1作为DOM节点B 32的定位标识。
由于Selenium软件直接根据目标DOM节点在DOM树中的绝对路径得到DOM节点的位 置信息(即Xpath方案),因此每个DOM节点均需要较为复杂的计算过程方可确定每个DOM节点的定位标识,从而会使得测试系统的性能损耗较为严重。采用图4所示意的定位方式,通过采用先标识、再类型、最后层级关系的计算逻辑,可以快速地计算出每个DOM节点的定位标识,从而可以降低计算的复杂度,提高测试的效率。
进一步地,在确定目标DOM节点的定位标识后,预设录制插件可以获取本次操作的类型(比如单击、双击、读取或写入等)、操作的内容(比如写入的数据)、本次操作与上次操作之间的时长等操作信息。还可以获取测试界面的统一资源定位符(Uniform Resource Location,URL)、用户代理、设备信息等操作路径信息,并可以按照预设格式组装操作信息和操作路径信息,从而得到本次操作对应的录制脚本。
本发明实施例中,组装操作信息和操作路径信息得到录制脚本的方式可以有多种,在一种可能的实现方式中,测试服务器上预先设置了案例归类器,图5为一种可能的案例归类器的示意图,如图5所示,案例归类器中包含多个操作类型对应的脚本函数,比如creat函数、setViewPort函数、setUserAgent函数、goto函数、wait函数、dbclick函数、click函数、tap函数、input函数、select函数、upload函数、dest函数等。具体实施中,在确定每个操作对应的目标DOM节点的定位标识后,可以自动将每个操作的操作信息和操作路径信息输入案例归类器。如此,案例归类器可以先调用creat函数创建每个操作对应的脚本对象,然后可以根据每个操作的操作路径信息遍历确定每个操作对应的操作过程,最后可以根据遍历过程更新函数的变量,得到录制脚本。比如若某次操作为单击操作,则遍历该次操作的操作路径信息后可以确定该操作对应的脚本函数为click函数。如此,案例归类器可以根据该操作的操作信息更新click函数中的变量,得到该操作对应的录制脚本。
需要说明的是,用户的一次操作可以对应一个录制脚本,也可以对应多个录制脚本,具体不作限定。
本发明实施例中,用户对测试界面执行的每一次操作均可以被实时地输入案例归类器。如此,当用户对测试界面的操作录制完成后,案例归类器可以将用户的每次操作对应的录制脚本按照顺序排列组合,得到本次录制的测试案例(此处指脚本文件)。进一步地,测试服务器可以先为本次录制的测试案例设置标识,然后可以将本次录制的测试案例的脚本文件存储在案例管理文件夹中,并可以将本次录制的测试案例的标识添加在服务子界面对应的“案例管理”的功能按钮对应的界面中,以显示给用户。
上面以软件实现形式描述了使用预设录制插件录制得到测试案例的过程,下面从硬件实现角度描述预设录制插件的各个模块。
图6为本发明实施例提供的一种Chrome录制插件的结构示意图,如图6所示,Chrome录制插件可以由Popup模块、Background模块和Content模块组成,Popup模块、Background模块和Content模块的功能如下所示:
Popup模块负责Chrome录制插件的界面展示和逻辑处理。具体地说,Popup模块可以向用户提供“启动录制”的功能按钮和“结束录制”的功能按钮,并在检测到用户点击“启动录制”的功能按钮或“结束录制”的功能按钮时,告知Background模块。且,Popup模块还可以在Chrome录制插件结束录制后,将Background模块发送的测试案例显示给用户。
Background模块是承接Popup模块和Content模块的桥梁。具体实施中,Background模块可以把用户在Popup模块中点击“启动录制”的功能按钮和“结束录制”的功能按钮的消息通知给Content模块,且可以在Chrome录制插件结束录制后接收Content模块发送的多个埋 点事件对应的操作信息,并可以调用案例归类器将这些操作信息转换成测试案例,然后可以将测试案例发送给Popup模块,以便于用户查看。
Content模块的执行环境可以设置在测试界面中。具体实施中,当接收到Background模块发送的用户点击“启动录制”的功能按钮的消息后,Content模块可以监听并记录测试界面中的埋点事件,比如click事件、input事件、change事件、touchstart事件、touchmove事件、touchend事件和touchcancel事件等。相应地,当接收到Background模块发送的用户点击“结束录制”的功能按钮的消息后,Content模块可以把记录的埋点事件对应的操作信息发送给Background模块。其中,每个埋点事件对应的操作信息可以包含埋点事件的类型、操作的目标DOM节点的定位标识、操作信息、本次操作与上次操作的时间差值等。
步骤102,若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放。
在一种可能的实现方式中,测试服务器可以预先设置多个进程,并可以使用多个进程并行地执行多个测试任务。具体实施中,当用户在服务子界面中触发“案例管理”的功能按钮后,测试服务器可以将历史测试案例显示给用户,如此,若检测到用户触发某一测试案例,则测试服务器可以先将该测试案例的标识添加到待执行任务池中,然后可以轮询多个进程确定每个进程的繁忙程度。若确定存在某一进程处于空闲状态,则可以将该测试案例的脚本文件发送给该空闲进程,并可以锁定待执行任务池中的该测试案例,从而避免其他进程重复处理该测试案例,导致不必要的性能损失。其中,测试服务器中进程的数量可以根据中央处理器(Central Processing Unit,CPU)的核数来设置,或者也可以由用户根据业务需要进行设置,具体不作限定。当进程分配到测试案例后,进程可以利用node.js的VM虚拟机能力来运行测试案例对应的脚本文件。具体地说,进程可以先解析测试案例对应的脚本文件得到多个操作对应的录制脚本,由于每个操作对应的录制脚本通过函数来表示,因此,进程可以采用预设浏览器算法执行函数,从而在测试界面上依次回放多个操作。
本发明实施例中,预设浏览器算法可以由本领域技术人员根据经验进行设置,比如可以为puppeteer浏览器算法、PhantomJS浏览器算法等,具体不作限定。
以通过puppeteer浏览器算法操作无头浏览器为例:具体实施中,进程可以先从测试案例的脚本文件中获取Create函数,并可以使用Create函数调用puppeteer浏览器算法,使得puppeteer浏览器算法执行启动无头浏览器的任务,如此,puppeteer浏览器算法可以跟无头浏览器建立socket连接。进一步地,若某一操作对应的录制脚本为Click函数,则puppeteer浏览器算法可以先根据该操作的目标DOM节点的定位标识等待目标DOM节点对应的元素出现在无头浏览器的测试界面上,然后再按照click函数对目标DOM节点的点击方式向puppeteer浏览器算法发送控制指令,如此,puppeteer浏览器算法可以通过socket连接告知无头浏览器在目标DOM节点对应的元素上执行点击操作。
可以理解的,上述过程是以操作类型为点击为例描述操作的回放过程,其它操作类型可以按照该过程进行实现,此处不再赘述。
举例来说,若某一测试案例对应的脚本文件为:首先click函数记录了用户点击DOM节点B21,然后wait函数()记录了用户在点击DOM节点B21后等待了30秒,接着dbclick函数记录了用户双击DOM节点B23,然后wait函数()记录了用户在双击DOM节点B23后等待了15秒,最后input函数记录了用户在DOM节点B1中输入“文档”,则进程可以通过puppeteer浏览器算法调用无头浏览器,先在无头浏览器的测试界面上单击DOM节点B21,然后等待 30秒后双击DOM节点B23,并在等待15秒后在DOM节点B1中输入“文档”,从而完成对测试案例中的用户的操作进行完整的回放。
步骤103,在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,在回放得到的第一界面和所述操作对应的标准界面上进行渲染。
具体实施中,针对于任一操作(比如双击DOM节点B 23),在进程调用puppeteer浏览器算法控制无头浏览器对测试界面上的DOM节点B 23进行双击后,测试界面可以跳转到第一界面。如此,进程可以对比第一界面和该操作对应的标准界面,确定两个界面对应的DOM树中各个DOM节点的差异,并可以根据各个DOM节点的差异将对应的元素差异渲染在第一界面和标准界面上,以使用户直观地查看到测试结果。其中,用户的每次操作均可以对应有一个标准界面,标准界面可以由本领域技术人员根据经验进行设置,比如可以为编程得到的界面,或者也可以为从历次测试过程中选取的最标准的一个界面,具体不作限定。
本发明实施例中,当跳转到第一界面后,进程可以解析第一界面得到对应的第一DOM树,并可以根据标准数据库中确定标准界面对应的标准DOM树。其中,标准数据库中可以仅存储多个操作分别对应的标准界面,或者也可以同时存储多个操作对应的标准界面和标准DOM树。相应地,进程可以直接从标准数据库中获取标准DOM树,或者也可以先获取标准界面,然后解析得到标准DOM树。进一步地,针对于第I级节点层中的任一差异节点,进程可以根据该差异节点在第一DOM树和标准DOM树中的区别生成该差异节点对应的差异数据,针对于第I级节点层中的任一相同节点,若确定第I+1级节点层中存在该相同节点连接的子节点,则进程可以分别对比第一DOM树和标准DOM树中该相同节点的所有子节点,并可以根据对比结果确定任一子节点属于差异节点还是相同节点,并按照上述过程执行对比,直至对比至所有节点均不存在子节点为止。
具体实施中,进程可以先对比第一DOM树的第一级节点层中的第一根节点和标准DOM树的第一级节点层中的标准根节点,若第一根节点与标准根节点在样式、内容、类型、属性上存在任意一项或任意多项不同,则该节点属于修改节点。若仅存在第一根节点而不存在标准根节点,则确定第一根节点为新增节点。若仅存在标准根节点而不存在第一根节点,则确定标准根节点为删除节点。其中,新增节点、删除节点和修改节点均为差异节点,进程可以根据差异节点在第一DOM树和标准DOM树中的区别生成差异节点对应的差异数据。相应地,若第一根节点与标准根节点的样式、内容、类型、属性等均相同,则第一根节点与标准根节点属于相同节点。针对于相同的第一根节点与标准根节点,进程可以对比第一DOM树中第一根节点的所有子节点和标准DOM树中标准根节点的所有子节点,并可以按照根节点的对比方式确定任一子节点属于差异节点还是相同节点。针对于任一子节点中的差异子节点,进程可以根据差异子节点在第一DOM树和标准DOM树中的区别生成差异子节点对应的差异数据。针对于任一子节点中的相同子节点,进程可以继续对比第一DOM树中相同子节点的所有子节点和标准DOM树中相同子节点的所有子节点,直至对比至不存在子节点为止。
按照上述方式,进程在第一DOM树和标准DOM树对比完成后,可以得到多个差异节点的差异数据。其中,差异数据的类型可以为新增、删除或修改。如此,进程可以根据多个差异节点的差异数据在第一界面和标准界面上进行渲染,比如可以使用第一类型检出框框出第一界面上的新增节点,或者可以使用第二类型检出框框出标准界面上的删除节点,或者可以使用第三类型检出框框出第一界面和第二界面上存在差异的修改节点。其中,第 一类型检出框、第二类型检出框和第三类型检出框可以由本领域技术人员根据经验进行设置,具体不作限定。举例来说,在一种可能的方式中,可以使用颜色来标识不同类型的检出框,比如可以设置第一类型检出框为绿色、第二类型检出框为红色、第三类型检出框为黄色。在另一种可能的方式中,可以使用文字来标识不同类型的检出框,比如在第一类型检出框上添加新增字样,则第二类型检出框上添加删除字样,在第三类型检出框上添加修改字样和/或具体的修改内容。
在一个示例中,在渲染第一界面和标准界面后,为了便于用户直观地查看到差异节点,还可以对第一界面和标准界面上的差异节点进行截图,并将截图显示给用户。
本发明的上述实施例中,录制用户对测试界面的操作得到测试案例,所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;进一步地,若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放,并在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,对回放得到的第一界面和所述操作对应的标准界面进行渲染。本发明实施例中,通过设置对每个DOM节点的操作结束后自动执行断言,可以无需用户手动地设置断言条件,如此,无编程能力的用户也可以使用该方法进行前端界面测试,从而使用门槛低,自动化测试的程度较高。且,通过设置每个DOM节点的操作回放结束后,根据回放操作的测试结果对第一界面和标准界面进行渲染,可以使得用户直观地查看到测试结果中的差异数据,相比于现有的测试方法给出复杂的测试报告的方式来说,用户的体验更好。
针对上述方法流程,本发明实施例还提供一种测试装置,该装置的具体内容可以参照上述方法实施。
图7为本发明实施例提供的一种测试装置的结构示意图,包括:
录制模块701,用于录制用户对测试界面的操作得到测试案例;所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;
回放模块702,用于若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放;
处理模块703,用于在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,对回放得到的第一界面和所述操作对应的标准界面进行渲染。
可选地,所述录制模块701具体用于:针对所述用户对所述测试界面的任一操作,从所述测试界面对应的DOM树中确定所述用户触发的目标DOM节点;根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,并根据所述目标DOM节点在所述DOM树中的定位标识、所述操作的类型、所述操作的内容、所述操作与上一操作的时间信息生成所述操作对应的测试数据;根据所述用户对所述测试界面的各个操作对应的测试数据生成所述测试案例。
可选地,所述录制模块701具体用于:判断所述目标DOM节点的标识是否属于第一类型标识,若是,则将所述目标DOM节点的标识作为所述目标DOM节点的定位标识,所述第一类型标识用于在录制和回放时唯一标识所述目标DOM节点;若否,则判断所述目标DOM节点的类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点的类型作为所述目标DOM节点的定位标识,若否,则根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识。
可选地,所述录制模块701具体用于:判断所述目标DOM节点的父节点是否存在,若不存在,则根据所述目标DOM节点的类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的一级组合类型,判断所述目标DOM节点对应的一级组合类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点对应的一级组合类型作为所述目标DOM节点的定位标识,若否,则判断所述目标DOM节点的父节点的父节点是否存在,若不存在,则根据所述目标DOM节点对应的一级组合类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的父节点的类型、所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的二级组合类型,并根据所述目标DOM节点对应的二级组合类型确定所述目标DOM节点的定位标识。
可选地,所述录制模块701具体用于:若所述目标DOM节点的标识由数字组成,则确定所述目标DOM节点的标识不属于所述第一类型标识,若所述目标DOM节点的标识包括数字以外的字符,则确定所述目标DOM节点的标识属于所述第一类型标识。
可选地,所述处理模块703具体用于:解析所述第一界面得到第一DOM树,解析所述标准界面得到标准DOM树,针对于所述第一DOM树和所述标准DOM树的第I级节点层中的任一差异节点,根据所述差异节点在所述第一DOM树和所述标准DOM树中的区别生成所述差异节点对应的差异数据;针对于所述第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定所述相同节点存在连接的第I+1级子节点,则对比所述第一DOM树和所述标准DOM树中所述相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点,根据各级节点层中各个差异节点对应的差异数据,在所述第一界面和所述标准界面上对所述各个差异节点对应的元素进行渲染,得到所述操作对应的测试结果。其中,I为大于0的整数。
可选地,所述处理模块703具体用于:若所述标准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级子节点为相同节点。
可选地,所述回放模块702具体用于:将所述测试案例插入任务池,所述任务池用于存储待执行的一个或多个测试案例,从多个进程中选取处于空闲状态的第一进程,将所述测试案例发送给所述第一进程,以使所述第一进程根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放操作,并将所述任务池中的所述测试案例设置为锁定状态。
从上述内容可以看出:本发明的上述实施例中,录制用户对测试界面的操作得到测试案例,所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;进一步地,若确定对所述测试案例进行测试,则根据所述用户对 所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放,并在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,对回放得到的第一界面和所述操作对应的标准界面进行渲染。本发明实施例中,通过设置对每个DOM节点的操作结束后自动执行断言,可以无需用户手动地设置断言条件,如此,无编程能力的用户也可以使用该方法进行前端界面测试,从而使用门槛低,自动化测试的程度较高。且,通过设置每个DOM节点的操作回放结束后,根据回放操作的测试结果对第一界面和标准界面进行渲染,可以使得用户直观地查看到测试结果中的差异数据,相比于现有的测试方法给出复杂的测试报告的方式来说,用户的体验更好。
基于同一发明构思,本发明实施例还提供了一种计算设备,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行图2任一项所述的测试方法。
基于同一发明构思,本发明实施例还提供了一种计算机可读存储介质,其存储有可由计算设备执行的计算机程序,当所述程序在所述计算设备上运行时,使得所述计算设备执行图2任一项所述的测试方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (18)

  1. 一种测试方法,其特征在于,所述方法包括:
    录制用户对测试界面的操作得到测试案例;所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;
    若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放;
    在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,在回放得到的第一界面和所述操作对应的标准界面上进行渲染。
  2. 根据权利要求1所述的方法,其特征在于,所述录制用户对测试界面的操作得到测试案例,包括:
    针对所述用户对所述测试界面的任一操作,从所述测试界面对应的DOM树中确定所述用户触发的目标DOM节点;根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,并根据所述目标DOM节点在所述DOM树中的定位标识、所述操作的类型、所述操作的内容、所述操作与上一操作的时间信息生成所述操作对应的测试数据;
    根据所述用户对所述测试界面的各个操作对应的测试数据生成所述测试案例。
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,包括:
    判断所述目标DOM节点的标识是否属于第一类型标识,若是,则将所述目标DOM节点的标识作为所述目标DOM节点的定位标识,所述第一类型标识用于在录制和回放时唯一标识所述目标DOM节点;若否,则判断所述目标DOM节点的类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点的类型作为所述目标DOM节点的定位标识,若否,则根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识。
  4. 根据权利要求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节点的定位标识。
  5. 根据权利要求3所述的方法,其特征在于,所述判断所述目标DOM节点的标识是否 为第一类型标识,包括:
    若所述目标DOM节点的标识由数字组成,则确定所述目标DOM节点的标识不属于所述第一类型标识,若所述目标DOM节点的标识包括数字以外的字符,则确定所述目标DOM节点的标识属于所述第一类型标识。
  6. 根据权利要求1所述的方法,其特征在于,所述根据所述操作对应的测试结果,在回放得到的第一界面和所述操作对应的标准界面上进行渲染,包括:
    解析所述第一界面得到第一DOM树,解析所述标准界面得到标准DOM树;
    针对于所述第一DOM树和所述标准DOM树的第I级节点层中的任一差异节点,根据所述差异节点在所述第一DOM树和所述标准DOM树中的区别生成所述差异节点对应的差异数据;针对于所述第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定所述相同节点存在连接的第I+1级子节点,则对比所述第一DOM树和所述标准DOM树中所述相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点;其中,I为大于0的整数;
    根据各级节点层中各个差异节点对应的差异数据,在所述第一界面和所述标准界面上对所述各个差异节点对应的元素进行渲染,得到所述操作对应的测试结果。
  7. 根据权利要求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级子节点为相同节点。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,所述根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放,包括:
    将所述测试案例插入任务池,所述任务池用于存储待执行的一个或多个测试案例;
    从多个进程中选取处于空闲状态的第一进程,将所述测试案例发送给所述第一进程,以使所述第一进程根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放操作,并将所述任务池中的所述测试案例设置为锁定状态。
  9. 一种测试装置,其特征在于,所述装置包括:
    录制模块,用于录制用户对测试界面的操作得到测试案例;所述测试案例包括所述用户对所述测试界面对应的DOM树上的一个或多个DOM节点进行操作的操作信息;
    回放模块,用于若确定对所述测试案例进行测试,则根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放;
    处理模块,用于在每个DOM节点对应的操作回放结束后,根据所述操作对应的测试结果,对回放得到的第一界面和所述操作对应的标准界面进行渲染。
  10. 根据权利要求9所述的装置,其特征在于,所述录制模块具体用于:
    针对所述用户对所述测试界面的任一操作,从所述测试界面对应的DOM树中确定所述用户触发的目标DOM节点;根据所述目标DOM节点的标识、类型和/或所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点在所述DOM树中的定位标识,并根据所述目标DOM节点在所述DOM树中的定位标识、所述操作的类型、所述操作的内容、所述操作与上一操作的时间信息生成所述操作对应的测试数据;
    根据所述用户对所述测试界面的各个操作对应的测试数据生成所述测试案例。
  11. 根据权利要求10所述的装置,其特征在于,所述录制模块具体用于:
    判断所述目标DOM节点的标识是否属于第一类型标识,若是,则将所述目标DOM节点的标识作为所述目标DOM节点的定位标识,所述第一类型标识用于在录制和回放时唯一标识所述目标DOM节点;若否,则判断所述目标DOM节点的类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点的类型作为所述目标DOM节点的定位标识,若否,则根据所述目标DOM节点在所述DOM树中的层级关系确定所述目标DOM节点的定位标识。
  12. 根据权利要求11所述的装置,其特征在于,所述录制模块具体用于:
    判断所述目标DOM节点的父节点是否存在,若不存在,则根据所述目标DOM节点的类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的一级组合类型,判断所述目标DOM节点对应的一级组合类型是否为所述DOM树中的唯一类型,若是,则将所述目标DOM节点对应的一级组合类型作为所述目标DOM节点的定位标识,若否,则判断所述目标DOM节点的父节点的父节点是否存在,若不存在,则根据所述目标DOM节点对应的一级组合类型在所述DOM树中的顺序确定所述目标DOM节点的定位标识;若存在,则组合所述目标DOM节点的父节点的父节点的类型、所述目标DOM节点的父节点的类型、所述目标DOM节点的类型,得到所述目标DOM节点对应的二级组合类型,并根据所述目标DOM节点对应的二级组合类型确定所述目标DOM节点的定位标识。
  13. 根据权利要求11所述的装置,其特征在于,所述录制模块具体用于:
    若所述目标DOM节点的标识由数字组成,则确定所述目标DOM节点的标识不属于所述第一类型标识,若所述目标DOM节点的标识包括数字以外的字符,则确定所述目标DOM节点的标识属于所述第一类型标识。
  14. 根据权利要求9所述的装置,其特征在于,所述处理模块具体用于:
    解析所述第一界面得到第一DOM树,解析所述标准界面得到标准DOM树;
    针对于所述第一DOM树和所述标准DOM树的第I级节点层中的任一差异节点,根据所述差异节点在所述第一DOM树和所述标准DOM树中的区别生成所述差异节点对应的差异数据;针对于所述第一DOM树和标准DOM树的第I级节点层中的任一相同节点,若确定所述相同节点存在连接的第I+1级子节点,则对比所述第一DOM树和所述标准DOM树中所述相同节点连接的所有第I+1级子节点,并根据对比结果判断任一连接的第I+1级子节点属于差异节点还是相同节点;其中,I为大于0的整数;
    根据各级节点层中各个差异节点对应的差异数据,在所述第一界面和所述标准界面上对所述各个差异节点对应的元素进行渲染,得到所述操作对应的测试结果。
  15. 根据权利要求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级子节点为相同节点。
  16. 根据权利要求9至15中任一项所述的装置,其特征在于,所述回放模块具体用于:
    将所述测试案例插入任务池,所述任务池用于存储待执行的一个或多个测试案例;
    从多个进程中选取处于空闲状态的第一进程,将所述测试案例发送给所述第一进程,以使所述第一进程根据所述用户对所述一个或多个DOM节点进行操作的操作信息对所述测试界面进行回放操作,并将所述任务池中的所述测试案例设置为锁定状态。
  17. 一种计算设备,其特征在于,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行权利要求1~8任一权利要求所述的方法。
  18. 一种计算机可读存储介质,其特征在于,其存储有可由计算设备执行的计算机程序,当所述程序在所述计算设备上运行时,使得所述计算设备执行权利要求1~8任一权利要求所述的方法。
PCT/CN2020/125167 2019-11-05 2020-10-30 一种测试方法及装置 WO2021088724A1 (zh)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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自动化测试方法、计算设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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