A fuzzy playback method, terminal and readable storage medium for automated testing
By obtaining similar elements in web page testing to generate variant actions, building a variant tree and forming an action sequence, the problem of poor logic of test scripts in the existing technology is solved, achieving the effect of reducing costs and enhancing logic.
Patent Information
- Application Number
- CN202311659329.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-04
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-12-04
AI Technical Summary
Existing automated test generation technologies are difficult to effectively retain the tester's domain knowledge, resulting in poor logic of the generated test scripts and high labor and time costs.
By obtaining similar elements of the target element of the interactive action on the web page, generating mutation actions, building a mutation tree and forming an action sequence, outputting the test script, and retaining the domain knowledge of the sample.
It reduces the labor and time costs of recording and playback, enhances the logic of generated test scripts, and can generate multi-step logical association operations similar to existing tests.
Smart Images

Figure CN117873863B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of web page testing, and in particular to a fuzzy playback method, a terminal and a readable storage medium for automated testing. Background Art
[0002] Web applications are applications built on web technologies, accessed and run through a browser, and provide various functions and services on the internet. With the development of network technology and the continuous increase in the number of users, the types and number of web applications have also continued to rise, from simple websites to complex online tools and applications.
[0003] To cope with the growing number of users and reduce losses caused by errors, many web applications require thorough testing before going live. As web applications are constantly evolving, many test automation frameworks support recording user actions on the web pages under test as test scripts and replaying the recorded actions by running the test scripts when needed. Record and replay offers a distinct advantage over random fuzz testing: testers can apply their domain knowledge during the recording process to test important but hard-to-reach functionality, thereby improving the effectiveness of regression testing.
[0004] Most of the current automatic test generation technologies are based on the DOM structure of web pages. They build a state flow graph through the transition between web page states. Based on the state flow graph, they continuously search for new states and paths and output the corresponding paths as new test scripts.
[0005] In traditional technical solutions, automatic test generation technology constructs state flow diagrams based on different state abstraction algorithms and state search algorithms, and outputs the paths in the state flow diagrams as new test scripts in different ways. This method makes it difficult to determine whether there is a logical relationship between the paths.
[0006] To this end, recording and playback technology constructs test scripts by recording the recording operator's interactions with web applications. Manually recorded test scripts often contain a lot of domain knowledge and therefore lack the tester's domain knowledge and have good logic. However, batch generation of test scripts increases both time and labor costs. Test reuse methods use manual testing to construct initial state flow diagrams, providing domain knowledge for the generated new tests.
[0007] Existing methods for generating new test scripts based on manual testing use a webpage state from an existing test as a sample to create an initial state flow diagram, which is then continuously expanded. When outputting test scripts, the generated path is compared to the sample path for similarity, prioritizing tests that are similar to the sample path. The quality of tests generated by these algorithms still depends on the model's pre-defined algorithms, and their utilization of domain knowledge from the sample test is relatively limited. Summary of the Invention
[0008] The purpose of the present invention is to provide a fuzzy playback method, terminal and readable storage medium for automated testing, aiming to enable the generated test script to retain more domain knowledge of samples.
[0009] The technical solutions adopted by the present invention to solve the technical problems are as follows:
[0010] The present invention provides a fuzzy playback method for automated testing, comprising:
[0011] Acquire a test sample, where the test sample includes at least one interactive action;
[0012] According to the target elements of the interactive actions, similar elements of the target elements of each interactive action on the web page are obtained;
[0013] Generate variant actions of each interactive action based on similar elements of the target elements of each interactive action;
[0014] An action sequence is composed according to interactive actions and variation actions, and the action sequence is output as a test script.
[0015] Furthermore, the action sequence is formed according to the interactive action and the variation action, and the action sequence is output as a test script. Specifically, the following steps are repeated until a stop condition is met:
[0016] Determine whether the interaction action corresponding to the currently executed action is the last interaction action of the test case;
[0017] If the interaction action corresponding to the currently executed action is the last interaction action of the test sample, then the action sequence consisting of all actions from the initial state of the webpage to the current state is output as the test sample output, and the action corresponding to the first step of the test sample is selected and played back to the initial state of the webpage for execution;
[0018] If the interaction action corresponding to the currently executed action is not the last interaction action of the test case, the action corresponding to the next interaction action after the interaction action corresponding to the currently executed action is selected for execution;
[0019] The correspondence between an action and an interactive action means that the action is the interactive action or a variant action obtained based on the interactive action.
[0020] Furthermore, the generating of variant actions of each interactive action based on similar elements of the target element of each interactive action further includes:
[0021] The mutation actions and interaction actions are used as nodes to form a mutation tree. The root node of the mutation tree corresponds to the initial state of the web page to be tested. The nth layer of the mutation tree corresponds to the nth step of the test sample. The mutation actions corresponding to the interaction actions of the nth step of the test sample also belong to the nth layer of the mutation tree.
[0022] The step of determining whether the interactive action corresponding to the currently executed action is the last interactive action of the test case is specifically determining whether the currently executed node is the last layer of the node tree. If the currently executed node is the last layer of the node tree, then the interactive action corresponding to the currently executed action is the last interactive action of the test case.
[0023] If the currently executed node is not the last level of the node tree, the interaction action corresponding to the currently executed action is not the last interaction action of the test case;
[0024] The selecting of an action corresponding to the next interactive action of the interactive action corresponding to the currently executed action for execution specifically involves selecting a child node of the currently executed node for execution.
[0025] Furthermore, the steps of obtaining similar elements of the target elements of each interactive action on the webpage based on the target elements of each interactive action, generating variant actions of each interactive action based on the similar elements of the target elements of each interactive action, and forming a variant tree using the variant actions and the interactive actions as nodes specifically include:
[0026] Obtain similar elements of the target element of the interactive action in the first step of the test sample on the webpage, and generate a mutation action corresponding to the interactive action in the first step of the test sample as a node in the first layer of the mutation tree as a child node of the root node;
[0027] Before selecting the child node of the currently executed node for execution, it is also determined whether the currently executed node has a child node. If the currently executed node does not have a child node, similar elements of the interactive action of the next layer of the currently executed node that are visible on the current state of the web page are obtained, and a variant action is generated based on the similar element as the child node of the currently executed node.
[0028] Furthermore, after a leaf node of the variant tree is selected for execution, the leaf node is set as a non-executable node;
[0029] After all child nodes of the non-leaf node of the variant tree are set as non-executable nodes, the non-leaf node is set as a non-executable node.
[0030] Furthermore, the stopping condition specifically includes: the root node has no executable child node.
[0031] Furthermore, obtaining similar elements of the target elements of each interactive action on the web page specifically obtains similar elements of each target element in the interactive elements of the web page to be tested according to one or more of the attributes, tags and Xpath of the target elements of each interactive action.
[0032] Furthermore, obtaining similar elements of each target element in the interactive elements of the web page to be tested according to one or more of the attributes, tags, and XPaths of the target elements of each interactive action specifically includes:
[0033] Judge the target element and each interactive element on the web page in turn;
[0034] If both the target element and the interactive element have tags and class attributes, then if the tags and class attributes of the target element and the interactive element are the same, the interactive element is considered the similar element of the target element;
[0035] If both the target element and the interactive element have tags, but one or both do not have a class attribute, then determine whether the elements without a class attribute all meet one of the first condition or the second condition;
[0036] If all elements without a class attribute meet either the first or second condition, the element that meets the first condition uses the class attribute of its parent element as its own class attribute, and the element that meets the second condition uses the class attribute of its child element as its own class attribute. If the target element and the interactive element have the same label and class attribute, the interactive element is considered the similar element of the target element.
[0037] If the elements without the class attribute do not all meet either the first or second condition, then determine whether the XPath of the target element and the interactive element are the same after removing the index. If the XPath of the target element and the interactive element are the same after removing the index, then the interactive element is regarded as a similar element to the target element.
[0038] The first condition is that the parent element has only one child element, and the second condition is that the child element has only one parent element.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, which includes: a memory, a processor, and a fuzzy replay program for automated testing stored on the memory and run on the processor. When the fuzzy replay program for automated testing is executed by the processor, the terminal is controlled to implement the steps of the fuzzy replay method for automated testing as described above.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also provides a readable storage medium, which stores a fuzzy replay program for automated testing. When the fuzzy replay program for automated testing is executed by a processor, the steps of the fuzzy replay method for automated testing as described above are implemented.
[0041] The present invention adopts the above technical solution to achieve the following effects:
[0042] The present invention expands the original manual test to these similar elements by finding similar elements, uses the domain knowledge of existing tests to enhance the logic of generating test scripts, retains more domain knowledge in test samples, and retains the use of automatic script generation to reduce the labor cost and time cost of recording and playback. On the basis of enhancing the logic of generating test scripts, it can generate multi-step logical association operations similar to existing tests. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flowchart of the steps of the fuzzy playback method of automated testing in a preferred embodiment of the present invention;
[0044] Figure 2 It is a program flow chart of the fuzzy playback method for automated testing in a preferred embodiment of the present invention;
[0045] Figure 3 is a schematic diagram of a web page to be tested in a preferred embodiment of the present invention;
[0046] Figure 4 is a flow chart of the steps for obtaining similar elements in a preferred embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of the structure of the DOM tree in a preferred embodiment of the present invention;
[0048] Figure 6 Schematic diagram of the structure of the variant tree in a preferred embodiment of the present invention;
[0049] Figure 7 Schematic diagram of the coloring of leaf nodes in a preferred embodiment of the present invention;
[0050] Figure 8 Schematic diagram of coloring of non-leaf nodes in a preferred embodiment of the present invention;
[0051] Figure 9 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0053] Example 1
[0054] See Figure 1 and Figure 2 , Embodiment 1 of the present application is a fuzzy playback method for automated testing, comprising the steps of:
[0055] S1. Obtain a test sample, where the test sample includes at least one interactive action.
[0056] Specifically, in this embodiment, Selenium is used as a recording and playback tool, and the test script recorded by Selenium is used as a sample test script. Selenium is a WEB automation tool that supports automatic recording of actions and automatic generation of test scripts in different languages such as .Net, Java, Perl, etc. The test script generated by Selenium is usually an action sequence consisting of a series of interactive actions, where each interactive action consists of three parts: action type, target element and interaction value, which respectively represent the interaction type (such as click, input, etc.), interactive target element (such as button 1, text 2) and supplementary value that may be required in the interaction (such as input value "123", option 1).
[0057] After obtaining the sample test script, the present application analyzes the sample test script to obtain a series of interactive actions corresponding to the sample test script, including the interaction type, target element and possible supplementary value of the interactive action. In other optional embodiments, according to actual needs, the interactive action may also include other elements, and the present invention is not limited to this.
[0058] S2. According to the target elements of the interactive actions, similar elements of the target elements of the interactive actions on the web page to be tested are obtained.
[0059] There are usually multiple elements in a web application that have the same interaction method and similar functions. Usually, these similar elements are different sub-functions of a large web page function. Such elements are called similar elements. Figure 3 As shown, elements in the same frame are similar elements to each other.
[0060] To obtain the interactive elements of the web page to be tested, the web page to be tested may be analyzed to obtain the corresponding interactive elements. Specifically, the web page may be analyzed for graphics and text to obtain the interactive elements that can be interacted with, or the properties of relevant controls on the web page may be obtained to obtain the interactive elements that can be interacted with.
[0061] For similar elements to obtain the target elements of each interaction action, please refer to Figure 4 In this embodiment, similar elements of each target element in the interactive elements of the web page to be tested are obtained based on the attributes, tags and Xpath (XML Path Language) of the target element of each interactive action.
[0062] Specifically, we determine whether two elements have both a tag and a class attribute. If both elements have both attributes, then the elements with the same attributes are considered similar. An element's tag identifies its type, and elements with the same tag often behave similarly. The class attribute is used to query elements in CSS scripts, and elements with the same class attribute often share common visual characteristics and similar functionality. Therefore, using tags and class attributes can satisfy our need for similar elements.
[0063] If the element has no class attribute, check the parent and child generations of the element in the DOM (Document Object Model) tree. Figure 5 As shown, when recording the click of "Solution", the target element recorded is the parent element a of the "Solution" element in the DOM tree. In some cases, element a does not have a class attribute, but its parent div does. If the parent element of an element in the DOM tree has only one child element, such as the parent element div of a has only one child element a, then the two elements are in the same position in the actual web page, and the parent element div can represent the element a, and the same applies to the child elements. Therefore, when the parent element has only one child, check whether the parent element has a class attribute. If so, replace the element with the parent element for similar element judgment; when the element has only one child, check whether the child element has a class attribute. If so, replace the element with the child element for similar element judgment.
[0064] For example, let's say the target element being recorded is a in the DOM tree. In some cases, element a lacks a class attribute, while its parent div does. If, in the DOM tree, the parent div of element a has only one child (e.g., a), then on the actual webpage, these two elements are in the same position. The parent div can represent element a, and the same applies to its child elements. Because class is more accurate than XPath, replacing the original element with a parent or child element that has a class attribute and meets the requirements is more accurate than using XPath directly.
[0065] If none of the above conditions are met, similarity is determined by comparing the two elements' XPaths. If the XPaths of two elements are the same after removing the index, the two elements are considered similar. XPath is a language used to determine the position of nodes in XML documents and is used to locate elements in the DOM structure of web applications. In web applications, similar elements are typically located at the same DOM tree level, so comparing unindexed XPaths can be used to detect element similarity.
[0066] S3. Generate variant actions of each interactive action based on similar elements of the target elements of each interactive action.
[0067] Because similar elements interact in the same way, an interaction action targeting one element can generally achieve different results by changing the interaction method of the target element. If similar elements can be found, new interaction actions can be generated using this method. This method of generating new actions is called mutation, and the generated actions are called mutant actions. For each action in the sample test, multiple mutant actions can be generated through mutation.
[0068] S4. Compose an action sequence based on the interactive actions and the variation actions, and output the action sequence as a test script.
[0069] By combining the mutated actions in a reasonable way, a new action sequence can be obtained as the test script output. The process of generating new test scripts through mutation and combination is called fuzzy replay.
[0070] In this embodiment, the following steps are repeated until the stopping condition is met:
[0071] If the interaction action corresponding to the currently executed action is the last interaction action of the test sample, then the action sequence consisting of all actions from the initial state of the webpage to the current state is output as the test sample output, and the action corresponding to the first step of the test sample is selected and replayed to the initial state of the webpage for execution;
[0072] If the interaction action corresponding to the currently executed action is not the last interaction action of the test case, the action corresponding to the next interaction action after the interaction action corresponding to the currently executed action is selected for execution.
[0073] The correspondence between an action and an interactive action means that the action is the interactive action or a variant action obtained based on the interactive action.
[0074] Figure 3For an action sequence on an existing web application, the corresponding action sequence of the test sample is: 1. Click the "Solution" element. 2. Click the "Artificial Intelligence" element. 3. Click the "Product Discovery" element. "Document AI" and "Contact Center AI" are similar to the "Product Discovery" element. We can mutate the action of clicking "Product Discovery" in the original test into two new actions: clicking "Document AI" and clicking "Contact Center AI", and recombine them with other actions to generate two new test scripts. Similarly, since the "Data Cloud" element is similar to the "Artificial Intelligence" element, we can generate the action of clicking "Data Cloud" through mutation and replace the original action. In a similar way, fuzzy replay can generate a large number of new test scripts that retain the domain knowledge of sample tests.
[0075] If online sequence generation is performed by simply randomly selecting mutation actions, redundant sequences with the same action may be generated multiple times, reducing the performance of fuzzy playback. Therefore, this embodiment can reduce the generation of redundant sequences by using a mutation tree to record mutation information.
[0076] For details, please refer to Figure 6 In this embodiment, the mutation action and the interactive action of the sample test each constitute a mutation tree as a node. The root node of the mutation tree corresponds to the initial state of the web page to be tested. The nth layer of the mutation tree corresponds to the nth step of the test sample. The mutation actions corresponding to the interactive actions of the nth step of the test sample belong to the nth layer of the mutation tree.
[0077] In the mutation tree, each node stores a mutation action derived based on sample similarity, and each node's descendants store all possible subsequent actions that can be executed after executing the node's action. The root node of the mutation tree does not store any actions, and its descendants store all possible entry actions, including those in the sample test. The mutation tree continues to grow during fuzzy playback. When the mutation tree can no longer grow, fuzzy playback ends. The mutation tree constructed in this way has two characteristics: first, the elements between each layer are similar to each other, and second, every path from the root node to the leaf node is a legal action sequence.
[0078] The initial state of the web page is generated as the root node, and the subsequent actions that can be executed after each node is executed are the child nodes of the node. Then, coloring can be avoided according to the mutation tree to avoid repeated execution caused by random selection.
[0079] For details, please refer to Figure 7 For leaf nodes, once the node is selected, it is colored to indicate that it should not be selected again. Please refer to Figure 8,For a non-leaf node, once all its child nodes are selected, color them.
[0080] When selecting the next mutation action, it is selected and executed from the uncolored child nodes. This method can avoid the generation of redundant sequences. When the root node is colored, it means that the fuzzy playback ends.
[0081] In addition, if the entire content of the web page is analyzed directly at once to obtain the variant actions of each interactive action, similar elements with no path to them may be obtained, resulting in the final generation of an action sequence that cannot operate normally. Therefore, in order to avoid generating an action sequence that cannot operate normally, this embodiment uses an online sequence generation method to combine the variant actions, and the mutation process of the online sequence generation will be carried out simultaneously with the interaction of the web application.
[0082] In this embodiment, similar elements of the target element of the interactive action in the first step of the test sample on the web page are initially obtained, and the variant action corresponding to the interactive action in the first step of the test sample is generated as the node of the first layer of the variant tree as the child node of the root node;
[0083] Before selecting the child node of the currently executed node for execution, it is also determined whether the currently executed node has a child node. If the currently executed node does not have a child node, similar elements of the interactive action of the next layer of the currently executed node that are visible on the current state of the web page are obtained, and a variant action is generated based on the similar element as the child node of the currently executed node.
[0084] The stopping condition includes that the root node has no executable child nodes. In addition, it may also include manually set restriction conditions, such as reaching a set time, or reaching a set number of execution actions.
[0085] However, there are certain problems with directly permuting and combining mutated actions to generate action sequences. Since changes in actions will cause changes in the state of the web page, after executing one mutated action, the next mutated action may not be able to execute normally in the new state. For example, "database" and "artificial intelligence" are similar elements, so mutating the action of clicking on "artificial intelligence" can generate an action of clicking on "database." However, the state of the web application after executing the action of clicking on "database" is different from the original state, and elements such as "product discovery" do not exist in this state. If simply combined, it will result in the generation of an action sequence that does not operate normally, such as executing the action of clicking on "database" and then executing the action of clicking on "product discovery."
[0086] Based on this, in this embodiment, the new node only serves as a child node of the executed node and the parent node of the executed node.
[0087] For example, after executing the artificial intelligence node, the obtained CCAI and DAI nodes only serve as child nodes of artificial intelligence, and the industry solution node only serves as a child node of the solution.
[0088] In this way, there will be no situation where CCAI and DAI nodes appear as sub-nodes of industry solutions, or industry solutions appear as sub-nodes of products, which will lead to unfeasible paths and cause testing problems.
[0089] Example 2
[0090] See Figure 9 Based on the above method, the present invention also provides a terminal, which includes: a memory 10, a processor 20, and a fuzzy replay program for automated testing stored on the memory 10 and runnable on the processor 20. When the fuzzy replay program for automated testing is executed by the processor 20, the terminal is controlled to implement the steps of the fuzzy replay method for automated testing as described above.
[0091] In some embodiments, the memory 10 can be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 10 can also be an external storage device of the terminal, such as a plug-in hard disk equipped on the terminal, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Furthermore, the memory 10 can also include both an internal storage unit of the terminal and an external storage device. The memory 10 is used to store application software and various types of data installed on the terminal, such as the program code of the installation terminal. The memory 10 can also be used to temporarily store data that has been output or is to be output. In one embodiment, a fuzzy replay program for automated testing is stored on the memory 10, and the fuzzy replay program for automated testing can be executed by the processor 20, thereby realizing the fuzzy replay method for automated testing in this application.
[0092] In some embodiments, the processor 20 may be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to execute program codes or process data stored in the memory 10, such as executing the fuzzy playback method of the automated test.
[0093] Example 3
[0094] This embodiment provides a storage medium, characterized in that the readable storage medium stores a fuzzy playback program for automated testing, and when the fuzzy playback program for automated testing is executed by a processor, the steps of the fuzzy playback method for automated testing described above are implemented.
[0095] In summary, the present invention obtains the quantum fidelity between the many-body ground state and the target ground state by using a neural network to obtain the expectation value of the Pauli operator corresponding to the parameters of the Hamiltonian equation of the many-body system in the many-body ground state. It only needs to measure the expectation value of the Pauli operator corresponding to the parameters of the Hamiltonian equation of the many-body system in the many-body ground state to obtain the quantum fidelity between the many-body ground state and the target ground state, which greatly reduces the number of global Pauli operator measurements and has higher acquisition accuracy than existing quantum fidelity methods.
[0096] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or terminal comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or terminal comprising the element.
[0097] Of course, those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware (such as a processor, controller, etc.) through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a memory, a magnetic disk, an optical disk, etc.
[0098] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A fuzzy playback method for automated testing, characterized in that: include: Acquire a test sample, where the test sample includes at least one interactive action; According to the target elements of the interactive actions, similar elements of the target elements of each interactive action on the web page are obtained; Generate variant actions of each interactive action based on similar elements of the target elements of each interactive action; Compose an action sequence based on interactive actions and variant actions, and output the action sequence as a test script; The action sequence is composed according to the interactive action and the variation action, and the action sequence is output as a test script. Specifically, the following steps are repeated until the stop condition is met: Determine whether the interaction action corresponding to the currently executed action is the last interaction action of the test case; If the interaction action corresponding to the currently executed action is the last interaction action of the test sample, then the action sequence consisting of all actions from the initial state of the webpage to the current state is output as the test sample output, and the action corresponding to the first step of the test sample is selected and replayed to the initial state of the webpage for execution; If the interaction action corresponding to the currently executed action is not the last interaction action of the test case, the action corresponding to the next interaction action after the interaction action corresponding to the currently executed action is selected for execution; The correspondence between an action and an interactive action means that the action is the interactive action or a variant action obtained based on the interactive action; The step of generating a variant action of each interactive action based on similar elements of the target element of each interactive action further includes: The mutation actions and interaction actions are used as nodes to form a mutation tree. The root node of the mutation tree corresponds to the initial state of the web page to be tested. The nth layer of the mutation tree corresponds to the nth step of the test sample. The mutation actions corresponding to the interaction actions of the nth step of the test sample also belong to the nth layer of the mutation tree. The step of determining whether the interactive action corresponding to the currently executed action is the last interactive action of the test case is specifically determining whether the currently executed node is the last layer of the node tree. If the currently executed node is the last layer of the node tree, then the interactive action corresponding to the currently executed action is the last interactive action of the test case. If the currently executed node is not the last level of the node tree, the interaction action corresponding to the currently executed action is not the last interaction action of the test case; The selecting of an action corresponding to the next interactive action of the interactive action corresponding to the currently executed action for execution specifically involves selecting a child node of the currently executed node for execution.
2. The fuzzy playback method for automated testing according to claim 1, characterized in that: The step of obtaining similar elements of the target elements of each interactive action on a webpage according to the target elements of the interactive actions, generating variant actions of each interactive action according to the similar elements of the target elements of each interactive action, and forming a variant tree using the variant actions and the interactive actions as nodes specifically includes: Obtain similar elements of the target element of the interactive action in the first step of the test sample on the webpage, and generate a mutation action corresponding to the interactive action in the first step of the test sample as a node in the first layer of the mutation tree as a child node of the root node; Before selecting the child node of the currently executed node for execution, it is also determined whether the currently executed node has a child node. If the currently executed node does not have a child node, similar elements of the interactive action of the next layer of the currently executed node that are visible on the current state of the web page are obtained, and a variant action is generated based on the similar element as the child node of the currently executed node.
3. The fuzzy playback method for automated testing according to claim 1, characterized in that: After a leaf node of the variant tree is selected for execution, the leaf node is set as an unexecutable node; After all child nodes of the non-leaf node of the variant tree are set as non-executable nodes, the non-leaf node is set as a non-executable node.
4. The fuzzy playback method for automated testing according to claim 1, characterized in that: The stopping condition specifically includes: the root node has no executable child node.
5. The fuzzy playback method for automated testing according to claim 1, characterized in that: The obtaining of similar elements of the target elements of each interactive action on the web page specifically involves obtaining similar elements of each target element in the interactive elements of the web page to be tested according to one or more of the attributes, tags and Xpaths of the target elements of each interactive action.
6. The fuzzy playback method for automated testing according to claim 5, characterized in that: The step of obtaining similar elements of each target element in the interactive elements of the web page to be tested according to one or more of the attributes, tags, and XPaths of the target elements of each interactive action specifically includes: Judge the target element and each interactive element on the web page in turn; If both the target element and the interactive element have tags and class attributes, then if the tags and class attributes of the target element and the interactive element are the same, the interactive element is considered the similar element of the target element; If both the target element and the interactive element have tags, but one or both do not have a class attribute, then determine whether the elements without a class attribute all meet one of the first condition or the second condition; If all elements without a class attribute meet either the first or second condition, the element that meets the first condition uses the class attribute of its parent element as its own class attribute, and the element that meets the second condition uses the class attribute of its child element as its own class attribute. If the target element and the interactive element have the same label and class attribute, the interactive element is considered the similar element of the target element. If the elements without the class attribute do not all meet either the first or second condition, then determine whether the XPath of the target element and the interactive element are the same after removing the index. If the XPath of the target element and the interactive element are the same after removing the index, then the interactive element is regarded as a similar element to the target element. The first condition is that the parent element has only one child element, and the second condition is that the child element has only one parent element.
7. A terminal, characterized in that: The terminal includes: a memory, a processor, and a fuzzy replay program for automated testing stored in the memory and runnable on the processor. When the fuzzy replay program for automated testing is executed by the processor, the terminal is controlled to implement the steps of the fuzzy replay method for automated testing as described in any one of claims 1-6.
8. A readable storage medium, characterized in that: The readable storage medium stores a fuzzy replay program for automated testing, and when the fuzzy replay program for automated testing is executed by a processor, the steps of the fuzzy replay method for automated testing according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Test method based on machine vision and DOM tree structure
CN110515835A
Automated testing script recording method and device, computer equipment and medium
CN115481025A