Error correction method and apparatus for page test script
By identifying and adjusting control objects based on document object model information in B/S architecture application systems, and generating test script modification information, the problem of automated test failure caused by control attribute modification is solved, and the stability and automation level of test scripts are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2022-08-12
- Publication Date
- 2026-05-01
AI Technical Summary
In the automated testing of B/S architecture application systems in the financial industry, existing technologies cannot intelligently correct errors caused by changes in control attributes, which lead to the failure of automated test script execution. This requires frequent maintenance, and the OCR image recognition mode cannot achieve 100% accuracy, resulting in frequent errors in amount verification.
By determining the target control object set based on the execution results of the page test statements and the control element attribute set, and identifying the control objects in the document object model information, page test script modification information is generated, the control identification method and frame information are adjusted to correct the control attributes, and the target test script is generated.
It improves the stability and intelligence of automated test scripts, reduces the maintenance workload of testers, and ensures the stable execution of test scripts.
Smart Images

Figure CN115687075B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of automated testing technology, specifically to the field of page testing technology, and more specifically to a method, apparatus, device, storage medium, and program product for correcting errors in page test scripts. Background Technology
[0002] In the process of automating testing B / S application systems, the most commonly used automated testing technologies are generally three types: one is based on browser control object attribute recognition (such as Selenium, UFT, etc.); the second is based on control image feature recognition, such as OCR; and the third is based on ordered fixed operation commands and sequences of mouse and keyboard. Because transactions in the financial industry typically involve long processes, numerous control elements displayed on the page, and a large amount of numerical amount verification, the second type of automated testing technology, OCR image recognition, is limited by technology and cannot achieve 100% accuracy, easily leading to errors in amount verification. Furthermore, the third type fails when the interface display order changes or a certain step fails, causing all subsequent automated test scripts to fail, making it unsuitable for scalable application. Therefore, in the current financial industry, the first type, based on browser control object attribute recognition, is primarily preferred for automated testing of B / S architecture application systems.
[0003] When using the first method of automated testing based on browser control object attribute recognition, the automated testing framework relies on XPath and other methods defined in the automated test scripts for control identification and manipulation. When partial modifications are made to the page control attributes of the application under test, the framework lacks intelligent error correction capabilities. Because the control attributes defined in the original script do not exist in the current browser's DOM tree structure, the automated test script directly reports an "object does not exist" error, causing execution failure. Sometimes, although some control attributes are modified, the corresponding browser interface appears unchanged, making it undetectable to testers. This leads testers to believe the automated test script is unstable. Furthermore, these version modifications, which show no difference in the browser's display before and after, are indistinguishable from a human user's perspective. However, each page adjustment requires modification of the automated test script, resulting in a significant amount of script maintenance.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] In view of the above problems, this disclosure provides methods, apparatus, devices, media and program products for correcting page test scripts to improve the intelligence level of automated testing frameworks.
[0006] According to a first aspect of this disclosure, a method for correcting errors in a page test script is provided, the method comprising:
[0007] The target control object set is determined based on the execution result of the page test statement and the control element attribute set. The control element attribute set is pre-established based on the document object model information of the test page. The target control object set includes at least one target control object that the test script cannot recognize.
[0008] When it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page, the positioning method and attribute information of the target control object are determined;
[0009] Based on the positioning method and attribute information of the target control object, the first target control object is identified in the document object model information of the test page to generate the first page test script modification information;
[0010] When it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object, the test script modification information of the second page is generated based on the frame information where the target control object is located.
[0011] The page test script is modified according to the modification information of the first page test script and the modification information of the second page test script to generate the target test script.
[0012] According to embodiments of this disclosure, the step of identifying the first target control object in the document object model information of the test page based on the positioning method and attribute information of the target control object, in order to generate first page test script modification information, includes:
[0013] When it is determined that the positioning method of the target control object is text positioning, the first target control object is identified in the document object model information of the test page according to the tag information of the target control object, so as to generate the first page test script modification information;
[0014] When it is determined that the positioning method of the target control object is non-text positioning, the first target control object is identified in the document object model information of the test page according to the text attribute of the target control object, so as to generate the first page test script modification information.
[0015] According to embodiments of this disclosure, the step of identifying the first target control object in the document object model information of the test page based on the tag information of the target control object to generate first page test script modification information includes:
[0016] In the document object model structure tree of the test page, determine the nearest identifiable control element node before the statement corresponding to the target control object;
[0017] Starting from the nearest identifiable control element node, traverse the target tags of the same type as those based on the tag information of the target control object;
[0018] The first target control object is determined based on the text matching degree between the control name in the script statement comment and the target label; and
[0019] Generate a first target execution statement based on the attribute information of the first target control object; and
[0020] The first page of test script modification information is generated based on the first target execution statement that was successfully executed.
[0021] According to embodiments of this disclosure, the step of identifying the first target control object in the document object model information of the test page based on the text attributes of the target control object to generate first page test script modification information includes:
[0022] The target node is determined based on the value of the target control object and / or the attribute value of the underlying template.
[0023] The target node that matches the defined control type will be used as the first target control object; and
[0024] Generate a second target execution statement based on the attribute information of the target node; and
[0025] The first page of test script modification information is generated based on the successfully executed second target execution statement.
[0026] According to embodiments of this disclosure, the step of generating the second page test script modification information based on the frame information of the target control object includes:
[0027] When it is determined that the frame name of the target control object is consistent with the frame name of the document object model information of the test page, a statement with a waiting time is added before the statement executed by the target control object;
[0028] When it is determined that the frame name of the target control object is inconsistent with the frame name of the document object model information of the test page, the node with the tag type of floating frame tag is found as the parent node of the target control object.
[0029] Generate a jump statement for the frame name based on the name or id value of the parent node.
[0030] According to embodiments of this disclosure, it further includes:
[0031] A test script change log is generated based on the test script modification information on the first page and the test script modification information on the second page.
[0032] According to embodiments of this disclosure, the target control object set includes control type, frame name where the control is located, unique identifier attribute, value, underlying template attribute value, and identification status.
[0033] A second aspect of this disclosure provides an error correction device for a page test script, the device comprising:
[0034] The first determining module is used to determine the target control object set based on the execution result of the page test statement and the control element attribute set, wherein the control element attribute set is pre-established based on the document object model information of the test page, and the target control object set includes at least one target control object that the test script cannot recognize.
[0035] The second determining module is used to determine the positioning method and attribute information of the target control object when it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page;
[0036] The first generation module is used to identify the first target control object in the document object model information of the test page according to the positioning method and attribute information of the target control object, so as to generate the first page test script modification information;
[0037] The second generation module is used to generate second page test script modification information based on the frame information where the target control object is located when it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object.
[0038] The target test script generation module is used to modify the page test script according to the modification information of the first page test script and the modification information of the second page test script to generate the target test script.
[0039] According to embodiments of this disclosure, the first generation module includes:
[0040] The first generation submodule is used to identify the first target control object in the document object model information of the test page according to the tag information of the target control object when it is determined that the positioning method of the target control object is text positioning, so as to generate the first page test script modification information.
[0041] The second generation submodule is used to identify the first target control object in the document object model information of the test page based on the text attribute of the target control object when it is determined that the positioning method of the target control object is non-text positioning, so as to generate the first page test script modification information.
[0042] According to embodiments of this disclosure, the first generation submodule includes:
[0043] The first determining unit is used to determine the nearest identifiable control element node before the statement corresponding to the target control object in the document object model structure tree of the test page;
[0044] A traversal unit is used to traverse target tags of the same type as the tag information based on the target control object, starting from the nearest identifiable control element node;
[0045] The second determining unit is used to determine the first target control object based on the text matching degree between the control name in the script statement comment and the target label;
[0046] The first generation unit is configured to generate a first target execution statement based on the attribute information of the first target control object; and
[0047] The second generation unit is used to generate the first page test script modification information based on the first target execution statement that has been successfully executed.
[0048] According to embodiments of this disclosure, the second generation submodule includes:
[0049] The third determining unit is used to determine the target node based on the value of the target control object and / or the attribute value of the underlying template.
[0050] The fourth determining unit is used to select the target node that matches the defined control type as the first target control object;
[0051] The third generation unit is used to generate a second target execution statement based on the attribute information of the target node; and
[0052] The fourth generation unit is used to generate the modification information of the first page test script based on the successfully executed second target execution statement.
[0053] According to embodiments of this disclosure, the second generation module includes:
[0054] The first determining submodule is used to add a waiting time statement before the execution statement of the target control object when it is determined that the frame name of the target control object is consistent with the frame name of the document object model information of the test page;
[0055] The second determining submodule is used to find the node with the tag type of floating frame tag as the parent node of the target control object when the frame name of the target control object is inconsistent with the frame name of the document object model information of the test page.
[0056] The third generation submodule is used to generate a jump processing statement for the frame name based on the name or id value of the parent node.
[0057] According to embodiments of this disclosure, the device further includes:
[0058] The third generation module is used to generate a test script change log based on the test script modification information on the first page and the test script modification information on the second page.
[0059] A third aspect of this disclosure provides an electronic device comprising: one or more processors; and a memory for storing one or more programs, wherein, when the one or more programs are executed by the one or more processors, the one or more processors execute the error correction method of the page test script described above.
[0060] A fourth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to execute the aforementioned page test script error correction method.
[0061] The fifth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the error correction method for the page test script described above.
[0062] This disclosure provides a method for correcting page test scripts. It determines a set of target control objects based on the execution results of page test statements and the attribute set of control elements. When it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page, a first target control object is identified in the document object model information of the test page based on the positioning method and attribute information of the target control object, thereby generating first page test script modification information. When it is determined that the unique identifier attribute of the target control object exists in the document object model information of the test page, a second page test script modification information is generated based on the frame information where the target control object is located. The page test script is modified according to the first and second page test script modification information to generate a target test script. Compared to related technologies, the method provided in this disclosure automatically finds the new attribute features of modified controls during the execution of automated test scripts and automatically adjusts the original automated test script to maintain its freshness based on the control identification results. This reduces the workload of testers in maintaining and updating automated test scripts and improves the automation level of testing. Attached Figure Description
[0063] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0064] Figure 1 The illustration schematically depicts an application scenario of a page test script error correction method, apparatus, device, medium, and program product according to embodiments of the present disclosure;
[0065] Figure 2 A flowchart illustrating a method for correcting errors in a page test script according to an embodiment of the present disclosure is shown schematically.
[0066] Figure 3a This illustration schematically shows one of the flowcharts for a method of generating first page test script modification information according to an embodiment of the present disclosure;
[0067] Figure 3b This schematically illustrates a second flowchart of a method for generating first page test script modification information according to an embodiment of the present disclosure;
[0068] Figure 3c A flowchart illustrating the method for generating first page test script modification information according to an embodiment of this disclosure is shown in Figure 3.
[0069] Figure 4 A flowchart illustrating a method for generating second-page test script modification information according to an embodiment of this disclosure is shown schematically.
[0070] Figure 5 This schematically illustrates a structural block diagram of a page test script error correction device according to an embodiment of the present disclosure; and
[0071] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a page test script error correction method according to an embodiment of the present disclosure. Detailed Implementation
[0072] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0073] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0074] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0075] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0076] First, the terminology appearing in the embodiments of this disclosure will be explained:
[0077] Document Object Model (DOM): The DOM is an API (Application Programming Interface) used to render and interact with any HTML or XML document. The DOM is a document model loaded into the browser, representing the document as a tree of nodes, where each node represents a component of the document (e.g., page elements, strings, or comments).
[0078] DOM tree: The document tree model maps a document into a tree structure, which is processed through node objects, and the results can be added to the current page.
[0079] Nodes: The most basic building blocks of a webpage. All content in a webpage is a node (tag, attribute, text, comment, etc.) in the document tree, represented by the node.
[0080] In the software development process, automated testing technology has been adopted by more and more large enterprises as a very common testing mode. Through the concept of layered automated testing, different automated testing tools and technologies are used in unit testing, interface testing, integration testing and acceptance testing to achieve the quality protection goals of each testing stage.
[0081] With the development of Internet information technology, web-based systems under the B / S architecture are becoming increasingly prevalent in large financial enterprises due to their ease of deployment and maintenance and low requirements for client installation and operation. More and more systems and platforms are being developed using the B / S architecture, and automated testing tools and solutions for B / S application systems are receiving increasing attention.
[0082] In the process of automating the testing of B / S application systems, there are usually three most commonly used automated testing technology solutions: one is based on browser control object attribute recognition mode (such as Selenium, UFT, etc.), the second is based on control image feature recognition mode such as OCR, and the third is based on ordered fixed operation commands and sequence mode of mouse and keyboard.
[0083] Because transactions in the financial industry typically involve lengthy processes and numerous control elements displayed on the page, and financial transactions require extensive verification of numerical amounts, the second OCR image recognition mode in current automated testing solutions is limited by technology and cannot achieve 100% accuracy, easily leading to errors in amount verification. The third mode fails to execute all subsequent automated test scripts when the interface display order changes or a particular operation fails, making it unsuitable for large-scale application. Therefore, in the current financial industry, the first mode based on browser control object attribute recognition is primarily prioritized for automated testing of B / S architecture application systems. The second or third automated testing tools are only attempted in special scenarios where interface control attribute verification fails.
[0084] When using the first method of automated testing based on browser control object attribute recognition, the automated testing framework relies on XPath and other methods defined in the automated test scripts for control identification and manipulation. When partial modifications are made to the page control attributes of the application under test, the framework lacks intelligent error correction capabilities. Because the control attributes defined in the original script do not exist in the current browser's DOM tree structure, the automated test script directly reports an "object does not exist" error, causing execution failure. Sometimes, although some control attributes are modified, the corresponding browser interface appears unchanged, making it undetectable to testers. This leads testers to believe the automated test script is unstable. Furthermore, these version modifications, which show no difference in the browser's display before and after, are indistinguishable from a human user's perspective. However, each page adjustment requires modification of the automated test script, resulting in a significant amount of script maintenance.
[0085] Based on the aforementioned technical problems, embodiments of this disclosure provide a method for correcting page test scripts. The method includes: determining a set of target control objects based on the execution result of a page test statement and a set of control element attributes, wherein the set of control element attributes is pre-established based on the document object model information of the test page, and the set of target control objects includes at least one target control object that the test script cannot recognize; when it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page, determining the positioning method and attribute information of the target control object; identifying a first target control object in the document object model information of the test page based on the positioning method and the attribute information of the target control object, to generate first page test script modification information; when it is determined that the unique identifier attribute of the target control object exists in the document object model information of the test page, generating second page test script modification information based on the frame information where the target control object is located; and modifying the page test script based on the first page test script modification information and the second page test script modification information to generate a target test script.
[0086] Figure 1 The illustration schematically depicts an application scenario of a page test script error correction method, apparatus, device, medium, and program product according to embodiments of the present disclosure.
[0087] like Figure 1 As shown, application scenario 100 according to this embodiment may include an automated testing scenario for page test scripts. Network 104 is used as a medium to provide a communication link between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0088] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0089] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0090] Server 105 can be a page test script management server. In response to page test requests initiated by users through the application server, such as test requests issued by users using terminal devices 101, 102, and 103, the page test script management server runs the page test script according to the received page test request, performs error correction operations on the page test script based on the execution results of the page test statements, and generates a new test script.
[0091] It should be noted that the page test script error correction method provided in this embodiment can generally be executed by server 105. Correspondingly, the page test script error correction device provided in this embodiment can generally be located in server 105. The page test script error correction method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the page test script error correction device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0092] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0093] It should be noted that the error correction method and apparatus for page test scripts determined in the embodiments of this disclosure can be used in the field of automated testing technology, the field of financial technology, and any field other than the financial field. The application field of the error correction method and apparatus for page test scripts determined in the embodiments of this disclosure is not limited.
[0094] The following will be based on Figure 1 The described scene, through Figures 2-4 The present disclosure provides a detailed description of the error correction method for page test scripts according to embodiments.
[0095] Figure 2 A flowchart illustrating a method for correcting errors in a page test script according to an embodiment of this disclosure is shown schematically. Figure 2 As shown, the error correction method for the page test script in this embodiment includes operations S210 to S250, which can be executed by a server or other computing device.
[0096] In operation S210, the target control object set is determined based on the execution result of the page test statement and the control element attribute set.
[0097] According to embodiments of this disclosure, the set of control element attributes is pre-established based on the document object model information of the test page, and the set of target control objects includes at least one target control object that the test script cannot recognize.
[0098] In one example, the automated testing framework uses the Page Object (PO) pattern. It retrieves a collection of all control element attributes for each page in the application. These attributes include control type (input, button, label, etc.), frame name, unique identifier (name, id, or XPath), value, and underlying template value (innertext). Within the automated testing framework, the execution results of the automated test statements are replayed on the current browser page. Based on the pre-established collection of control element attributes, a set of statements is generated that correctly identify the page control objects in the current application interface, and a set of statements that cannot identify the corresponding page control objects, as shown in Table 1 below.
[0099] Table 1. Collection of Target Control Objects
[0100]
[0101]
[0102] The target control object set includes at least one target control object that the test script cannot recognize. Specifically, it includes the control type, the frame name where the control resides, a unique identifier attribute, a value, an underlying template attribute value, and a recognition status. The recognition status determines whether the control object can be recognized by the test script. During page testing, if page control attributes are adjusted or testers make mistakes in coding, and the corresponding test script is not adjusted accordingly, the original test script may fail to recognize the control, leading to an error. Information about the currently unrecognizable control object is obtained based on the test script's execution status. For unrecognizable control objects, i.e., target control objects, the target control object is relocated by analyzing the browser page's DOM structure. First, a judgment is made based on the target control object's unique identifier attribute. If the unique identifier attribute of the target control object does not exist in the document object model information of the test page, operations S220 and S230 are executed; if the unique identifier attribute of the target control object exists in the document object model information of the test page, operation S240 is executed.
[0103] In operation S220, when it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page, the positioning method and attribute information of the target control object are determined.
[0104] In operation S230, the first target control object is identified in the document object model information of the test page according to the positioning method of the target control object and the attribute information, so as to generate the first page test script modification information.
[0105] In one example, if the unique identifier attribute of the target control object is not present in the Document Object Model (DOM) information of the test page, it indicates that the attribute of the current target control object does indeed have a problem and needs to be corrected. First, the specific position of the target control in the DOM structure tree of the test page is determined. Then, based on the relocated control attribute information, the first page test script modification information is generated. Later, the test script execution statements are modified and replaced based on this modification information, thereby achieving test script error correction. In this embodiment, the method for identifying the target control differs depending on the location method of the target control object. For a specific method for identifying the first target control object, please refer to [link to relevant documentation]. Figures 3a-3c The operating steps will not be repeated here.
[0106] In operation S240, when it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object, the second page test script modification information is generated based on the frame information where the target control object is located.
[0107] In one example, when the Document Object Model (DOM) information of the test page contains a unique identifier attribute for the target control object, it first checks whether the frame name of the target control object matches the frame names in Table 1. If the frame name matches, it indicates a possible slow page loading or response. If the frame name does not match, it searches for the node of the floating frame label of the current target control object, generates a frame name redirection statement based on the node information, and generates the second page test script modification information. The method for generating the second page test script modification information can be found in [reference needed]. Figure 4 Operations S241 to S243 are shown.
[0108] In operation S250, the page test script is modified according to the modification information of the first page test script and the modification information of the second page test script to generate the target test script.
[0109] In one example, after the above error correction, modification information for the first page test script and modification information for the second page test script are generated. Based on the modification information for the first page test script and modification information for the second page test script, the page test script is modified. For example, it may be a modification of the name or id attribute of a control, or a replacement of the XPath path, to generate a new test script, i.e., the target test script.
[0110] The system is expandable. To facilitate testers' control over the test scripts, operation S310 is included after operation S250. In operation S310, a test script change log is generated based on the test script modification information on the first page and the test script modification information on the second page. The replaced statements before the automated test script's intelligent error correction, along with the corresponding relationships and change information, are recorded for testers to review and track.
[0111] The page test script error correction method provided by the embodiments of this disclosure automatically identifies new attribute features of modified controls during the execution of automated test scripts, and automatically adjusts and maintains the original automated test script based on the control identification results. This reduces the workload of testers in maintaining and updating automated test scripts and improves the level of automation in testing.
[0112] The following will combine Figures 3a-3c This section describes the process for determining the modification information in the test script on the first page. Figure 3a This illustration schematically shows one of the flowcharts for a method of generating first page test script modification information according to an embodiment of the present disclosure. Figure 3b This schematically illustrates a second flowchart of a method for generating first-page test script modification information according to an embodiment of the present disclosure. Figure 3c This schematically illustrates a third flowchart of a method for generating first-page test script modification information according to an embodiment of the present disclosure, such as... Figure 3a As shown, operation S230 includes operations S231 to S232.
[0113] In operation S231, when it is determined that the positioning method of the target control object is text positioning, the first target control object is identified in the document object model information of the test page according to the tag information of the target control object, so as to generate the first page test script modification information.
[0114] like Figure 3b As shown, operation S231 includes operations S2311 to S2315.
[0115] In operation S2311, the nearest identifiable control element node before the statement corresponding to the target control object is determined in the document object model structure tree of the test page.
[0116] In operation S2312, starting from the nearest identifiable control element node, target tags of the same type as those based on the tag information of the target control object are traversed.
[0117] In operation S2313, the first target control object is determined based on the text matching degree between the control name in the script statement comment and the target label.
[0118] In operation S2314, a first target execution statement is generated based on the attribute information of the first target control object.
[0119] In operation S2315, the first page of test script modification information is generated based on the first target execution statement that was successfully executed.
[0120] In one example, if the element location method in the statement uses text (e.g., using linkText, partialLinkText, or XPath containing text()), then the search is prioritized by traversing tags of the same type. When traversing tags, the most recent recognizable element before the currently failed statement in the automation script is first found. In the DOM tree, traversal begins from the recognizable element node.
[0121] Optionally, if the location is based on `linkText` or `partialLinkText`, the process iterates through the `` tags following the most recently identifiable element, and, combining this with the control names commented in the script, checks the text matching degree between each `` tag and the commented control name. The tag with the highest matching degree is then identified, and its attribute is used to replace the attribute in the original automation script. The text matching degree refers to matching based on predefined configuration content, such as: "OK", "Confirm"; "Add", "Increase"; "Delete", "Remove", etc. If the element originally located by the "OK" text cannot be found, after re-traversing the elements, if a matching element with "Confirm" is found, that element replaces the element with "OK". If the element cannot be found in the predefined dictionary, the text content of the found tag is compared with the text of the control name in the comments, and the attribute of the element with the highest text overlap is used to replace the current element's attribute.
[0122] Optionally, if the text() method in XPath is used, then the tag type starting from the absolute path in the XPath is obtained. Then, all nodes of that tag type after the most recent recognizable element are obtained. Combined with the control name in the script statement comments, the text matching degree between the node text and the control name in the comments is judged one by one. The node with the highest matching degree is found, and its XPath attribute is obtained to replace the attribute in the original automation script.
[0123] This approach is extensible. When multiple target objects with the same name exist on a page, the original DOM structure tree is analyzed to find the nearest previous and next controls that can be successfully identified. The content between these two DOM structures is selected as the analysis target, and a new XPath path is formed using the method described above. If controls with the same name still exist after the above processing, it is checked whether there are controls with the same name in the statements that cannot correctly identify the controls. If there are controls with the same name that are not identified in the script, and the number of them matches the number of controls with the same name in the corresponding DOM structure, the DOM tree is traversed from top to bottom according to the corresponding order of the controls in the script. The XPath attribute replacement relationship of the controls with the same name is formed according to the order, and the new XPath value is replaced.
[0124] Based on the properties of the first target control object identified above, the first target execution statement is generated, and the automated test statement code is re-executed. If the first target control object passes the execution, it indicates that the error correction is successful, and the identification and error correction of the next control is carried out.
[0125] In operation S232, when it is determined that the positioning method of the target control object is non-text positioning, the first target control object is identified in the document object model information of the test page according to the text attribute of the target control object, so as to generate the first page test script modification information.
[0126] like Figure 3c As shown, operation S232 includes operations S2321 to S2324.
[0127] In operation S2321, the target node is determined based on the value of the target control object and / or the attribute value of the underlying template.
[0128] In operation S2322, the target node that matches the defined control type is used as the first target control object.
[0129] In operation S2323, a second target execution statement is generated based on the attribute information of the target node.
[0130] In operation S2324, the modification information of the first page test script is generated based on the successfully executed second target execution statement.
[0131] In one example, if the element location method in the statement uses a non-text method (such as using the control's name, id attributes, or relative paths in XPath that do not include the text() method), then the corresponding node and its parent node are searched in the DOM based on the control's text attributes for error correction. Specifically, based on the value or underlying template value corresponding to the node in the attribute set, and the control name commented in the script statement, the DOM structure tree is analyzed. First, the node containing the value or underlying template value is located. It is then determined whether the node type is consistent with the defined control type. If they are inconsistent, the parent nodes are retrieved level by level until a certain level of parent node type matches the known control type. Then, it is determined whether the parent node has a unique name or id attribute. If it does, the name or id attribute is used as a unique identifier; if it does not, the XPath path of the parent node is obtained to replace the original XPath path in the automation script, and the corresponding automation test statement code is re-executed, i.e., the second target execution statement. After the current control passes the execution, the first page test script modification information is generated for intelligent identification and error correction of the next control.
[0132] Figure 4 A flowchart illustrating a method for generating second-page test script modification information according to an embodiment of this disclosure is shown, such as... Figure 4 As shown, operation S240 includes operations S241 to S243.
[0133] In operation S241, when it is determined that the frame name of the target control object is consistent with the frame name of the document object model information of the test page, a wait time statement is added before the execution statement of the target control object. In operation S242, when it is determined that the frame name of the target control object is inconsistent with the frame name of the document object model information of the test page, a node with a label type of floating frame label is found as the parent node of the target control object. In operation S243, a jump processing statement for the frame name is generated based on the name or id value of the parent node.
[0134] In one example, the system checks if the unique identifier attribute and its value exist in the Document Object Model (DOM) information of the test page. If they exist, it checks if the frame name of the element matches the frame name in the table above. If they match, there may be a problem with slow page loading or response, so a wait time statement is automatically added before the execution statement of the element in the automation script. If the frame names do not match, the system obtains the frame name of the current element by finding the parent node of the current element, finding the first node with a floating frame tag, and obtaining its name or id value. At the same time, a jump statement for the frame name is automatically added to the script to solve the problem of the control element not being recognized.
[0135] Based on the above-described error correction method for page test scripts, this disclosure also provides an error correction device for page test scripts. The following will combine... Figure 5 The device is described in detail.
[0136] Figure 5 The diagram illustrates a structural block diagram of a page test script error correction device according to an embodiment of the present disclosure.
[0137] like Figure 5 As shown, the page test script error correction device 500 of this embodiment includes a first determining module 510, a second determining module 520, a first generating module 530, a second generating module 540, and a target test script generating module 550.
[0138] The first determining module 510 is used to determine a set of target control objects based on the execution result of the page test statement and the set of control element attributes. The set of control element attributes is pre-established based on the document object model information of the test page, and the set of target control objects includes at least one target control object that the test script cannot recognize. In one embodiment, the first determining module 510 can be used to execute the operation S210 described above, which will not be repeated here.
[0139] The second determining module 520 is used to determine the positioning method and attribute information of the target control object when it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page. In one embodiment, the second determining module 520 can be used to perform the operation S220 described above, which will not be repeated here.
[0140] The first generation module 530 is used to identify the first target control object in the document object model information of the test page according to the positioning method and attribute information of the target control object, so as to generate the first page test script modification information. In one embodiment, the first generation module 530 can be used to perform the operation S230 described above, which will not be repeated here.
[0141] The second generation module 540 is used to generate second page test script modification information based on the frame information where the target control object is located when it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object. In one embodiment, the second generation module 540 can be used to perform the operation S240 described above, which will not be repeated here.
[0142] The target test script generation module 550 is used to modify the page test script according to the first page test script modification information and the second page test script modification information to generate a target test script. In one embodiment, the target test script generation module 550 can be used to perform the operation S250 described above, which will not be repeated here.
[0143] According to embodiments of this disclosure, the first generation module 530 includes a first generation submodule and a second generation submodule.
[0144] The first generation submodule is used to identify the first target control object in the document object model information of the test page based on the tag information of the target control object when it is determined that the positioning method of the target control object is text positioning, so as to generate the first page test script modification information. In one embodiment, the first generation submodule can be used to perform the operation S231 described above, which will not be repeated here.
[0145] The second generation submodule is used to identify the first target control object in the document object model information of the test page based on the text attribute of the target control object when it is determined that the positioning method of the target control object is non-text positioning, so as to generate the first page test script modification information. In one embodiment, the identification submodule can be used to perform the operation S222 described above, which will not be repeated here.
[0146] According to embodiments of this disclosure, the first generation submodule includes: a first determining unit, a traversal unit, a second determining unit, a first generation unit, and a second generation unit.
[0147] The first determining unit is used to determine the nearest identifiable control element node before the statement corresponding to the target control object in the document object model structure tree of the test page. In one embodiment, the first determining unit can be used to perform the operation S2311 described above, which will not be repeated here.
[0148] The traversal unit is used to traverse target tags of the same type as the tag information of the target control object, starting from the nearest identifiable control element node. In one embodiment, the traversal unit can be used to perform the operation S2312 described above, which will not be repeated here.
[0149] The second determining unit is used to determine the first target control object based on the text matching degree between the control name in the script statement comment and the target label. In one embodiment, the traversal unit can be used to execute the operation S2312 described above, which will not be repeated here.
[0150] The first generation unit is configured to generate a first target execution statement based on the attribute information of the first target control object. In one embodiment, the first generation unit can be used to execute the operation S2313 described above, which will not be repeated here.
[0151] The second generation unit is used to generate modification information for the first page test script based on the successfully executed first target execution statement. In one embodiment, the traversal unit can be used to execute the operation S2314 described above, which will not be repeated here.
[0152] According to embodiments of this disclosure, the second generation submodule includes a third determining unit, a fourth determining unit, a third generation unit, and a fourth generation unit.
[0153] The third determining unit is used to determine the target node based on the value of the target control object and / or the attribute value of the underlying template. In one embodiment, the third determining unit can be used to perform the operation S2321 described above, which will not be repeated here.
[0154] The fourth determining unit is used to select a target node that matches the defined control type as the first target control object. In one embodiment, the fourth determining unit can be used to perform the operation S2322 described above, which will not be repeated here.
[0155] The third generation unit is used to generate a second target execution statement based on the attribute information of the target node. In one embodiment, the third generation unit can be used to execute the operation S2323 described above, which will not be repeated here.
[0156] The fourth generation unit is used to generate modification information for the first page test script based on the successfully executed second target execution statement. In one embodiment, the fourth generation unit can be used to perform the operation S2324 described above, which will not be repeated here.
[0157] According to embodiments of this disclosure, the second generation module 540 includes a first determining submodule, a second determining submodule, and a third generation submodule.
[0158] The first determining submodule is used to add a waiting time statement before the statement executed by the target control object when it is determined that the frame name of the target control object is consistent with the frame name of the document object model information of the test page. In one embodiment, the first determining submodule can be used to execute the operation S241 described above, which will not be repeated here.
[0159] The second determining submodule is used to find the node with a floating frame tag type as the parent node of the target control object when the frame name of the target control object is inconsistent with the frame name of the document object model information of the test page. In one embodiment, the second determining submodule can be used to perform the operation S242 described above, which will not be repeated here.
[0160] The third generation submodule is used to generate a jump processing statement for the frame name based on the name or id value of the parent node. In one embodiment, the third generation submodule can be used to execute the operation S243 described above, which will not be repeated here.
[0161] According to embodiments of this disclosure, the apparatus further includes a third generation module.
[0162] The third generation module is used to generate a test script change log based on the modification information of the test script on the first page and the modification information of the test script on the second page. In one embodiment, the third generation submodule can be used to perform the operation S310 described above, which will not be repeated here.
[0163] According to embodiments of this disclosure, any plurality of modules among the first determining module 510, the second determining module 520, the first generating module 530, the second generating module 540, and the target test script generating module 550 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the first determining module 510, the second determining module 520, the first generating module 530, the second generating module 540, and the target test script generating module 550 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in a suitable combination of any of these. Alternatively, at least one of the first determining module 510, the second determining module 520, the first generating module 530, the second generating module 540, and the target test script generating module 550 may be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0164] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a page test script error correction method according to an embodiment of the present disclosure.
[0165] like Figure 6 As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0166] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0167] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0168] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the error correction method for a page test script according to embodiments of this disclosure.
[0169] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0170] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the error correction method for the page test script provided in the embodiments of this disclosure.
[0171] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0172] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0173] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0174] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0175] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0176] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0177] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A method for correcting errors in a page test script, characterized in that, The method includes: The target control object set is determined based on the execution result of the page test statement and the control element attribute set. The control element attribute set is pre-established based on the document object model information of the test page. The target control object set includes at least one target control object that the test script cannot recognize. When it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page, the positioning method and attribute information of the target control object are determined; Based on the positioning method and attribute information of the target control object, the first target control object is identified in the document object model information of the test page to generate the first page test script modification information; When it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object, modification information for the second page test script is generated based on the frame information of the target control object; and The page test script is modified according to the modification information of the first page test script and the modification information of the second page test script to generate the target test script. The step of identifying the first target control object in the document object model information of the test page based on the positioning method and attribute information of the target control object, and generating the first page test script modification information, includes: When it is determined that the positioning method of the target control object is text positioning, the first target control object is identified in the document object model information of the test page based on the tag information of the target control object, so as to generate the first page test script modification information; and When it is determined that the positioning method of the target control object is non-text positioning, the first target control object is identified in the document object model information of the test page according to the text attribute of the target control object, so as to generate the first page test script modification information.
2. The method according to claim 1, characterized in that, The step of identifying the first target control object in the document object model information of the test page based on the tag information of the target control object, and generating the first page test script modification information, includes: In the document object model structure tree of the test page, determine the nearest identifiable control element node before the statement corresponding to the target control object; Starting from the nearest identifiable control element node, traverse the target tags of the same type as those based on the tag information of the target control object; The first target control object is determined based on the text matching degree between the control name in the script statement comment and the target label; Generate a first target execution statement based on the attribute information of the first target control object; and The first page of test script modification information is generated based on the first target execution statement that was successfully executed.
3. The method according to claim 1, characterized in that, The step of identifying the first target control object in the document object model information of the test page based on the text attributes of the target control object to generate the first page test script modification information includes: The target node is determined based on the value of the target control object and / or the attribute value of the underlying template. Use the target node that matches the defined control type as the first target control object; Generate a second target execution statement based on the attribute information of the target node; and The first page of test script modification information is generated based on the successfully executed second target execution statement.
4. The method according to claim 1, characterized in that, The step of generating the second page test script modification information based on the frame information of the target control object includes: When it is determined that the frame name of the target control object is consistent with the frame name of the document object model information of the test page, a statement with a waiting time is added before the statement executed by the target control object; When it is determined that the frame name of the target control object is inconsistent with the frame name of the document object model information of the test page, the node with the tag type of floating frame tag is selected as the parent node of the target control object; and Generate a jump statement for the frame name based on the name or id value of the parent node.
5. The method according to claim 1, characterized in that, Also includes: A test script change log is generated based on the test script modification information on the first page and the test script modification information on the second page.
6. The method according to any one of claims 1 to 5, characterized in that, The target control object collection includes control type, frame name where the control is located, unique identifier attribute, value, underlying template attribute value, and identification status.
7. A device for correcting errors in a page test script, characterized in that, The device includes: The first determining module is used to determine the target control object set based on the execution result of the page test statement and the control element attribute set, wherein the control element attribute set is pre-established based on the document object model information of the test page, and the target control object set includes at least one target control object that the test script cannot recognize. The second determining module is used to determine the positioning method and attribute information of the target control object when it is determined that the unique identifier attribute of the target control object does not exist in the document object model information of the test page; The first generation module is used to identify the first target control object in the document object model information of the test page according to the positioning method and attribute information of the target control object, so as to generate the first page test script modification information; The second generation module is used to generate second page test script modification information based on the frame information where the target control object is located when it is determined that the document object model information of the test page contains a unique identifier attribute of the target control object. The target test script generation module is used to modify the page test script according to the modification information of the first page test script and the modification information of the second page test script to generate the target test script; The first generation module is further configured to, when determining that the positioning method of the target control object is text positioning, identify the first target control object in the document object model information of the test page according to the tag information of the target control object, so as to generate first page test script modification information; when determining that the positioning method of the target control object is non-text positioning, identify the first target control object in the document object model information of the test page according to the text attribute of the target control object, so as to generate first page test script modification information.
8. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors execute the error correction method of the page test script according to any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform an error correction method for a page test script according to any one of claims 1 to 6.
10. A computer program product comprising a computer program that, when executed by a processor, implements the error correction method for a page test script according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for processing automatic test scrip of software
CN103034583A
Web page element positioning method, apparatus and system
CN104424087A