An automated test input generation method based on dynamic page splitting
Through an automated test input generation method based on dynamic page splitting, combined with the Cypress framework and GraphQLAPI, the dynamic content elements are monitored and classified in real time, and the test input templates and data are automatically generated, and a natural language processing module is introduced for semantic analysis, which solves the limitations of the test input generation method in dynamic web page automation testing, and realizes efficient and accurate test input generation and semantic consistency verification.
Patent Information
- Application Number
- CN202411538095.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In the automated testing of dynamic web pages, the test input data generation method is too dependent on manual operations or static data sets, and cannot dynamically respond to page changes, and lacks in-depth analysis of dynamic content, making it difficult to cover all user operation scenarios and edge cases. Especially in complex web applications supported by multilinguals, the semantic consistency of the page cannot be ensured.
The automated test input generation method based on dynamic page splitting is adopted, and the DOM structure of dynamic web pages is analyzed through the Cypress framework, and dynamic content elements are monitored and classified in real time. The page components are logically grouped together to form test data dynamically, and the test input templates and data are automatically generated. The natural language processing module is introduced for semantic analysis to generate test input data and verification rules that conform to semantics.
Real-time response and comprehensive coverage generated by dynamic web test inputs are achieved, which significantly improves the accuracy and efficiency of testing, ensures effective verification of page semantic consistency and dynamic behavior in multi-language environments, and reduces test maintenance costs.
Smart Images

Figure CN119576760B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of dynamic web pages, and particularly relates to an automated test input generation method based on dynamic page splitting. Background Art
[0002] With the rapid development of Web technology, dynamic web pages have become the core components in modern Web applications. Dynamic web pages can update the page content in real time according to user interactions and changes in background data, providing a more flexible and personalized user experience. However, with the increasing complexity of dynamic web pages, how to effectively test these web pages, especially automated testing, has become a major challenge in software quality assurance.
[0003] In the prior art, the testing of dynamic web pages usually relies on manually generated test cases and input data. This manual testing method may be feasible for simple static web pages, but for complex Web applications with a large amount of dynamic content, this method seems inadequate. The content and structure in dynamic web pages often change frequently with user operations or changes in background data. Manual testing is not only inefficient but also difficult to comprehensively cover all possible user operation scenarios. This testing method is prone to missing key edge cases, resulting in insufficient test coverage and accuracy, and unable to fully guarantee the software quality.
[0004] Some automated testing tools in the prior art attempt to simulate user operations through scripting, but these tools usually rely on fixed page structures and element identifiers. Once the page structure changes, the scripts need to be rewritten or adjusted, increasing the maintenance cost. In addition, these tools usually lack the ability to deeply analyze and process dynamic content, and it is difficult to handle the complex interaction logic and changing content layout in dynamic pages.
[0005] In terms of the generation of test inputs for dynamic pages, the prior art often relies on predefined input data sets and cannot dynamically generate test inputs according to the real-time state of the page. This static test input generation method has obvious limitations when dealing with complex dynamic web pages and cannot effectively cover all possible user operation paths and data scenarios. Especially for complex Web applications with multi-language support, the prior art is difficult to ensure the semantic consistency of the page in different language environments and cannot comprehensively verify the matching degree between the dynamic behavior of the page and the semantic expectations.
[0006] In addition, when dealing with complex web applications, existing automated testing tools often lack in-depth understanding of page text content and are unable to generate appropriate test inputs and expected results for different language and semantic changes. This results in difficulty for testing tools to effectively evaluate the semantic performance of pages in a multilingual environment and inability to ensure the consistency and accuracy of pages in different language versions.
[0007] In summary, the prior art has the following deficiencies in the automated testing of dynamic pages: First, the generation method of test input data relies too much on manual operations or static data sets and cannot dynamically respond to page changes; Second, existing tools lack the ability to deeply analyze dynamic content and it is difficult to cover all user operation scenarios and edge cases; Third, for web applications with multilingual support, the prior art cannot ensure the semantic consistency of pages and cannot comprehensively verify the dynamic behavior of pages in different language environments. These deficiencies seriously affect the efficiency and coverage of dynamic web page testing, and there is an urgent need for a new automated test input generation method to solve these problems. Summary of the Invention
[0008] The problem to be solved by the present invention is to effectively verify the semantic consistency of pages in complex web applications with multilingual support, and a method for generating automated test inputs based on dynamic page splitting is proposed.
[0009] To achieve the above object, the present invention is realized through the following technical solutions:
[0010] A method for generating automated test inputs based on dynamic page splitting includes the following steps:
[0011] S1. Obtain the dynamic web page to be tested, and based on the Cypress framework, parse the document object model structure of the dynamic web page, and real-time monitor the dynamic content elements in the page. The dynamic content elements include input fields, buttons, dropdown menus, and pop-up windows dynamically generated by user interactions or background data;
[0012] S2. Utilize the real-time DOM operation ability of Cypress to perform real-time classification and marking on the dynamic content elements monitored in step S1, and according to the real-time layout and structure information of the page, perform logical grouping on different types of dynamic content elements to form multiple page components, and each page component contains one or more related dynamic content elements;
[0013] S3. Based on the structural information of the page components obtained in step S2, combined with the integration of Cypress and GraphQL API, dynamically obtain test data from the background, and automatically generate a test input template that matches the current state of the page. The test input template includes the input types, corresponding input rules, and GraphQL query results of each dynamic content element in each page component;
[0014] S4. According to the test input template obtained in step S3, automatically generate test input data covering various user operation scenarios. The test input data is obtained through GraphQL queries and is applied to dynamic page testing in real time;
[0015] S5. Utilize the fast feedback ability of the Cypress framework to apply the test input data generated in step S4 to the dynamic web page to be tested in real time. Execute the test by simulating user interactions, and record and analyze the test results while the page changes to generate a test report;
[0016] S6. Introduce a natural language processing module to parse the text content in the dynamic web page obtained in step S5, and automatically generate a semantic consistency report that conforms to the semantics based on the parsing results to optimize the test input generation method;
[0017] S7. Based on the test report obtained in step S5 and the semantic consistency report obtained in step S6, optimize the page splitting strategy, input generation rules, and GraphQL query configuration.
[0018] Furthermore, the specific implementation method of step S1 includes the following steps:
[0019] S11. Load the URL of the dynamic web page to be tested through the access function of the Cypress framework, and record the initial loading state of the dynamic web page. The initial loading state includes the DOM structure, CSS styles, and JavaScript files of the dynamic web page;
[0020] S12. Based on the DOM structure parsing function of the Cypress framework, monitor the changes of dynamic content elements in real time after the dynamic web page is loaded, and define a set of monitoring parameters {P i}, where P i represents the dynamic elements in the dynamic web page, including input fields, buttons, dropdown menus, and pop-up windows;
[0021] S13. After each refresh or interaction of the dynamic web page, capture and analyze the newly added or changed dynamic content elements in the dynamic web page in real time, add the captured elements to the parameter set {P i}, and record the attributes and behaviors of the captured elements:
[0022]
[0023] where Δt represents the time increment, and E m (t + Δt) represents the m-th dynamic element newly added or changed at time t + Δt, and γ(E m (t + Δt)) is an indicator function indicating whether the newly added element is added to the parameter set;
[0024] S14. Combine the event listening function of the Cypress framework to monitor user interaction events and background data updates in real time, capture events associated with dynamic content elements, including click events, input events, and data update events, and associate the events associated with dynamic content elements with the corresponding dynamic content elements to form an event-element mapping set;
[0025] S15. Through the DOM tree traversal function provided by Cypress, analyze the hierarchical relationship and dependency relationship of each dynamic content element, and establish a dynamic web page element tree, where the nodes of the element tree represent dynamic content elements, and the edges represent the parent-child or sibling relationship between elements;
[0026] S16. Based on the captured and monitored results, generate an initial record of the changes in dynamic content elements of the dynamic web page, and store it as an initial record data set D init .
[0027] Further, the specific implementation method of step S2 includes the following steps:
[0028] S21. Based on the parameter set {P i} and the initial record data set D init of the changes in dynamic content elements, use the real-time DOM operation ability of the Cypress framework to classify the monitored dynamic content elements in real time, and divide the dynamic content elements into subsets {P i,j (t)} according to the element type, interaction method, and hierarchical relationship, where P i,j (t) represents the i-th dynamic content element belonging to category j at time t;
[0029] S22. Using the initial records in the initial record data set D init , combined with the real-time layout information of the page, perform position and structure analysis on the dynamic content elements of each category, and use the position vector to represent the coordinate information of the element in the page;
[0030] S23. Combine the spatial relationship of the page layout and the hierarchical structure between elements recorded in the initial record data set D init to logically group the dynamic content elements within the same category to form multiple page components S k(t);
[0031] S24. Mark each page component S k (t), and record the element type, quantity it contains, and its relationship with other page components in combination with the initial record data set D init to form a page structure tree. The nodes of the page structure tree represent page components, and the edges represent the hierarchical or dependency relationships between page components.
[0032] Furthermore, the generation process of the page structure tree T page (t) in step S24 is represented by the following formula:
[0033]
[0034] where β k represents the node weight of the page component S k (t), γ k,l (t) is the relationship weight between the page component S k (t) and other page components S l (t), and f(S k (t), S l (t)) represents the hierarchical or dependency relationship function between the page components S k (t) and S l (t), which is defined as:
[0035] f(S k (t), S l (t)) = exp(-λ·d(S k (t), S l (t)))·δ(S k (t), S l (t));
[0036] where λ is an adjustment factor that controls the decay rate of the relationship function; d(S k (t), S l (t)) represents the distance function between the page components S k (t) and S l (t), and this function can be the Euclidean distance, Manhattan distance, or other distance metrics selected according to the page layout; δ(S k (t), S l (t)) is an indicator function that represents whether there is a hierarchical or dependency relationship between the page components S k (t) and S l (t). δ(S k (t), S l (t)) = 1 indicates the existence of a relationship, δ(Sk (t), S l (t)) = 0 indicates no relationship;
[0037] Compare and update the nodes and edges of the page structure tree T page (t) with the records in the initial record dataset to make the hierarchical structure of the page components consistent with the initial records. At the same time, adjust the weight coefficients β k and γ k,l (t) of the page structure tree in real time according to the dynamic changes of the page, reflecting the latest state of the relationship between page components.
[0038] Furthermore, the specific implementation method of step S3 includes the following steps:
[0039] S31. Based on the page structure tree T page (t) and the attributes of its nodes and edges, combined with the integration of Cypress and GraphQL API, dynamically obtain test data matching the current state of the page from the background, and define the test dataset {D test (t)}, where {D test (t)} represents the set of test data obtained from the background at time t;
[0040] S32. According to the structure information of each page component S page (t) in the page structure tree T k (t), automatically generate the corresponding test input template T input (t). The test input template includes the input types and corresponding input rules of each dynamic content element P i,j (t) in the page component;
[0041] S33. Combine the query results obtained from GraphQL API, match the data in the test dataset {D test (t)} with the dynamic content elements in the page component, and generate the final test input template T input_final (t).
[0042] Furthermore, the specific implementation method of step S4 includes the following steps:
[0043] S41. Based on the final test input template T input_final (t), automatically generate a test input dataset {D input (t)} covering various user operation scenarios according to the structure and element attributes of the page component;
[0044] S42. Combine the real-time query results obtained from GraphQL API, and match the generated test input dataset {D input(t) is matched with the dynamic content elements in the page components, so that the test input data reflects the current state of the page and its possible changes, and the operation scenario function f is defined. op (t) is used to describe the user operation scenario:
[0045]
[0046] Among them, μ k (t) is the weight coefficient of the page component S k (t) under a specific operation scenario, and ν i,j (t) is the input weight coefficient of the dynamic content element P i,j (t) under the corresponding operation scenario. D input,k (t) represents the test input data related to the page component S k (t), and f op (t) represents the input data function for different operation scenarios generated at time t;
[0047] S43. Apply the generated test input data set to the dynamic page test, simulate user interaction operations through the Cypress framework, and monitor and record the response of the page in real time;
[0048] S44. According to the page response data collected during the test, adjust the test input data set in real time, dynamically optimize the operation scenario function f op (t), so that the test input data adapts to the changes of the page and covers all edge scenarios and abnormal situations. The updated operation scenario function is expressed as:
[0049] f op_updated (t) = f op (t) + Δf op (t);
[0050] Among them, Δf op (t) represents the adjustment amount of the operation scenario function according to the test feedback, which is used to reflect the dynamic changes of the page and new test requirements.
[0051] Furthermore, the specific implementation method of step S5 includes the following steps:
[0052] S51. Utilize the fast feedback ability of the Cypress framework to apply the test input data set to the dynamic web page to be tested in real time, execute the test by simulating user interaction operations, and record the page response status R page (t) of each test step;
[0053] S52. During the process of dynamic change of the page, monitor and record each dynamic content element P i,j(t) updates the status information of page components and the page structure tree according to the status change of (t), and defines the page response function f resp (t) is used to describe the response of the page under different input conditions;
[0054] S53. Analyze the page response data collected during the test, identify abnormal response situations and potential problems in the page, and generate a preliminary test report, including the page response analysis results of each test step and the information of anomaly detection;
[0055] S54. Based on the data in the preliminary test report, analyze the dynamic behavior of the page, optimize the test input data set and the page response function, and generate a final test report. The final test report includes the response summary of the page under all test conditions and a comprehensive evaluation of the dynamic page behavior.
[0056] Furthermore, the specific implementation method of step S6 includes the following steps:
[0057] S61. Introduce a natural language processing module to perform semantic parsing on the text content in the dynamic page and extract the key text elements in the page;
[0058] S62. Based on the semantic analysis ability of the natural language processing module, classify and label the extracted key text elements to generate the text semantic model M semantic (t);
[0059] S63. Use the text semantic model M semantic to generate a test input data set {D semantic (t)} that conforms to the current semantics of the page. The test input data set is used to test the semantic consistency of the dynamic elements related to the text content in the page, make the input data match the semantics of the page text content, and define the test input function f semantic (t) to describe the generation process of semantic-based input data;
[0060] S64. Combine the generated semantic input data set to automatically generate an expected result verification rule set. The expected result verification rule set is used to verify the consistency between the page response result and the expected semantics, so that in a complex Web application with multi-language support, the dynamic behavior of the page conforms to the semantic expectations;
[0061] S65. During the test, dynamically adjust the semantic input data set and the expected result verification rule set according to the real-time response result of the page to generate a final semantic consistency report. The final semantic consistency report is used to evaluate the semantic performance of the page and its consistency in different language environments, and optimize the test input generation method according to the results to optimize the semantic consistency of the dynamic page.
[0062] Advantages of the present invention:
[0063] An automated test input generation method based on dynamic page splitting according to the present invention utilizes the Cypress framework combined with the real-time DOM operation ability of dynamic pages to accurately monitor, classify, and mark dynamic content elements in the page, and performs logical grouping based on the real-time layout and structure information of the page to generate multiple page components. Through the structure information of the page components, it automatically generates test input templates that match the current page state, and dynamically obtains test data consistent with the current page state through the integrated GraphQL API, enabling the test input generation process to respond in real time to changes in page content, automatically covering various possible user operation scenarios, significantly improving the accuracy and comprehensiveness of test input generation, and avoiding the limitations of manual operations and static data sets.
[0064] An automated test input generation method based on dynamic page splitting according to the present invention, by introducing a natural language processing module, performs semantic parsing on the text content in the page, automatically generates test input data that conforms to the semantics, and generates an expected result verification rule set based on the semantic model to ensure that in a complex Web application with multi-language support, the dynamic behavior of the page is consistent with the semantic expectations in different language environments. It can not only effectively detect the semantic performance of the page in different language versions, but also deeply analyze the text elements in the page through the semantic model, thereby generating test input data and verification rules that are more in line with the page semantics, significantly improving the test coverage and accuracy.
[0065] An automated test input generation method based on dynamic page splitting according to the present invention utilizes the fast feedback ability of the Cypress framework to record and analyze the response status of the page in real time during the test execution process, and adjusts the test input data set and page response function according to the dynamic changes of the page. Through the analysis and feedback of the preliminary test report, the present invention can dynamically optimize the test input generation process to ensure that the test input data can accurately reflect the latest state and operation scenarios of the page. Such a dynamic adjustment mechanism based on real-time feedback effectively improves the flexibility and adaptability of the test, ensures comprehensive coverage and accurate verification during the test process, and avoids the problem of test script failure caused by page structure changes.
[0066] An automated test input generation method based on dynamic page splitting according to the present invention no longer depends on a fixed page structure and predefined input data sets for automated test input generation, but dynamically generates based on the real-time state of the page, which not only improves the coverage and accuracy of test input, but also reduces the workload of manually writing and maintaining test scripts, and can significantly reduce the test maintenance cost when facing complex dynamic pages. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a flowchart of an automated test input generation method based on dynamic page splitting according to the present invention;
[0068] Figure 2 It is a schematic diagram of dynamic content element monitoring and classification in an automated test input generation method based on dynamic page splitting proposed by the present invention;
[0069] Figure 3 It is a schematic diagram of the structural information and logical grouping of page components in an automated test input generation method based on dynamic page splitting proposed by the present invention. Detailed implementation manners
[0070] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners. It should be understood that the specific implementation manners described herein are only used to explain the present invention and are not used to limit the present invention, that is, the specific implementation manners described are only a part of the implementation manners of the present invention, rather than all of the specific implementation manners. The components of the specific implementation manners of the present invention usually described and shown in the accompanying drawings herein can be arranged and designed in various different configurations, and the present invention can also have other implementation manners.
[0071] Therefore, the detailed description of the specific implementation manners of the present invention provided in the accompanying drawings below is not intended to limit the scope of the claimed invention, but merely represents the selected specific implementation manners of the present invention. All other specific implementation manners obtained by those skilled in the art without creative efforts based on the specific implementation manners of the present invention belong to the scope of protection of the present invention.
[0072] To further understand the content, features and effects of the present invention, the following specific implementation manners are exemplified and combined with the attached Figure 1 - Attached Figure 3 The details are as follows: Specific implementation manner 1:
[0074] An automated test input generation method based on dynamic page splitting includes the following steps:
[0075] S1. Obtain the dynamic web page to be tested, parse the document object model structure of the dynamic web page based on the Cypress framework, and monitor the dynamic content elements in the page in real time. The dynamic content elements include input fields, buttons, dropdown menus, and pop-up windows dynamically generated by user interactions or background data;
[0076] Furthermore, the specific implementation method of step S1 includes the following steps:
[0077] S11. Load the URL of the dynamic web page to be tested through the access function of the Cypress framework, and record the initial loading state of the dynamic web page. The initial loading state includes the DOM structure, CSS style, and JavaScript file of the dynamic web page;
[0078] S12. Based on the DOM structure parsing function of the Cypress framework, monitor the changes of dynamic content elements in real time after the dynamic web page is loaded, and define the monitoring parameter set {P i}, where P i represents the dynamic elements in the dynamic web page, including input fields, buttons, dropdown menus, and pop-up windows;
[0079] S13. After each dynamic web page refresh or interaction, capture and analyze the newly added or changed dynamic content elements in the dynamic web page in real time, add the captured elements to the parameter set {P i}, and record the attributes and behaviors of the captured elements:
[0080]
[0081] Among them, Δt represents the time increment, E m (t + Δt) represents the m-th dynamic element newly added or changed at time t + Δt, and γ(E m (t + Δt)) is an indicator function indicating whether the newly added element is added to the parameter set;
[0082] S14. Combine the event listening function of the Cypress framework to monitor user interaction events and background data updates in real time, capture the events associated with dynamic content elements, including click events, input events, and data update events, and associate the events associated with dynamic content elements with the corresponding dynamic content elements to form an event-element mapping set;
[0083] S15. Through the DOM tree traversal function provided by Cypress, analyze the hierarchical relationship and dependency relationship of each dynamic content element, and establish a dynamic web page element tree, where the nodes of the element tree represent dynamic content elements, and the edges represent the parent-child or sibling relationships between elements;
[0084] S16. Based on the captured and monitored results, generate an initial record of the changes of dynamic content elements in the dynamic web page and store it as the initial record data set D init .
[0085] S2. Utilize the real-time DOM operation ability of Cypress to classify and mark the dynamic content elements monitored in step S1 in real time. According to the real-time layout and structure information of the page, logically group different types of dynamic content elements to form multiple page components, and each page component contains one or more related dynamic content elements;
[0086] Further, the specific implementation method of step S2 includes the following steps:
[0087] S21. Based on the parameter set {P i} and the initial record data set D init of the changes in dynamic content elements, utilize the real-time DOM operation ability of the Cypress framework to classify the monitored dynamic content elements in real time, and divide the dynamic content elements into different subsets of categories {P i,j (t)} according to the element type, interaction method, and hierarchical relationship, where P i,j (t) represents the i-th dynamic content element belonging to category j at time t;
[0088] S22. Utilize the initial records in the initial record data set D init and combine with the real-time layout information of the page to perform position and structure analysis on the dynamic content elements of each category, and use the position vector to represent the coordinate information of the element in the page;
[0089] S23. Combine the spatial relationship of the page layout and the hierarchical structure between elements recorded in the initial record data set D init to logically group the dynamic content elements within the same category to form multiple page components S k (t);
[0090] S24. Mark each page component S k (t), and combine with the data in the initial record data set D init to record the element types, quantities it contains, and its relationships with other page components, forming a page structure tree. The nodes of the page structure tree represent page components, and the edges represent the hierarchical or dependency relationships between page components.
[0091] Further, the generation process of the page structure tree T page (t) in step S24 is represented by the following formula:
[0092]
[0093] Among them, β k represents the node weight of the page component S k (t), and γ k,l(t) is the page component S k (t) and other page components S l The relationship weight between them, f(S k (t), S l (t)) represents the hierarchical or dependency relationship function between page components S k (t) and S l (t), which is defined as:
[0094] f(S k (t), S l (t)) = exp(-λ · d(S k (t), S l (t))) · δ(S k (t), S l (t));
[0095] Among them, λ is an adjustment factor that controls the attenuation rate of the relationship function; d(S k (t), S l (t)) represents the distance function between page components S k (t) and S l (t). This function can be the Euclidean distance, Manhattan distance, or other distance metrics selected according to the page layout; δ(S k (t), S l (t)) is an indicator function that indicates whether there is a hierarchical or dependency relationship between page components S k (t) and S l (t). δ(S k (t), S l (t)) = 1 indicates the existence of a relationship, and δ(S k (t), S l (t)) = 0 indicates no relationship;
[0096] Compare and update the nodes and edges of the page structure tree T page (t) with the records in the initial record dataset to make the hierarchical structure of the page components consistent with the initial records. At the same time, adjust the weight coefficients β k and γ k,l (t) values in real time according to the dynamic changes of the page to reflect the latest status of the relationship between page components.
[0097] S3. Based on the structural information of the page components obtained in step S2, combined with the integration of Cypress and GraphQL API, dynamically obtain test data from the background, and automatically generate a test input template that matches the current state of the page. The test input template includes the input types, corresponding input rules, and GraphQL query results of each dynamic content element in each page component;
[0098] Further, the specific implementation method of step S3 includes the following steps:
[0099] S31. Based on the page structure tree T page (t) and the attributes of its nodes and edges, combined with the integration of Cypress and GraphQL API, dynamically obtain test data that matches the current state of the page from the background, and define a test data set {D test (t)}, where {D test (t)} represents the test data set obtained from the background at time t;
[0100] S32. According to the structural information of each page component S page (t) in the page structure tree T k (t), automatically generate a corresponding test input template T input (t). The test input template includes the input types and corresponding input rules of each dynamic content element P i,j (t) in the page component;
[0101] S33. Combine the query results obtained from the GraphQL API, match the data in the test data set {D test (t)} with the dynamic content elements in the page component, and generate the final test input template T input_final (t).
[0102] S4. According to the test input template obtained in step S3, automatically generate test input data that covers various user operation scenarios. The test input data is obtained through GraphQL queries and is applied to dynamic page testing in real time;
[0103] Further, the specific implementation method of step S4 includes the following steps:
[0104] S41. Based on the final test input template T input_final (t), automatically generate a test input data set {D input (t)} that covers various user operation scenarios according to the structure and element attributes of the page component;
[0105] S42. Combine the real-time query results obtained from the GraphQL API, and match the generated test input data set {Dinput (t) matches with the dynamic content elements in the page components, so that the test input data reflects the current state of the page and its possible changes, and defines the operation scenario function f op (t) is used to describe the user operation scenario:
[0106]
[0107] Among them, μ k (t) is the weight coefficient of the page component S k (t) under a specific operation scenario, and ν i,j (t) is the input weight coefficient of the dynamic content element P i,j (t) under the corresponding operation scenario, and D input,k (t) represents the test input data related to the page component S k (t), and f op (t) represents the input data function for different operation scenarios generated at time t;
[0108] S43. Apply the generated test input data set to the dynamic page test, simulate user interaction operations through the Cypress framework, and monitor and record the response of the page in real time;
[0109] S44. According to the page response data collected during the test, adjust the test input data set in real time, dynamically optimize the operation scenario function f op (t), so that the test input data adapts to the changes of the page and covers all edge scenarios and abnormal situations. The updated operation scenario function is expressed as:
[0110] f op_updated (t) = f op (t) + Δf op (t);
[0111] Among them, Δf op (t) represents the adjustment amount of the operation scenario function according to the test feedback, which is used to reflect the dynamic changes of the page and new test requirements.
[0112] S5. Utilize the fast feedback ability of the Cypress framework, apply the test input data generated in step S4 to the dynamic web page to be tested in real time, execute the test by simulating user interaction, and record and analyze the test results while the page changes to generate a test report;
[0113] Furthermore, the specific implementation method of step S5 includes the following steps:
[0114] S51. Utilize the quick feedback ability of the Cypress framework to apply the test input data set to the dynamic web page to be tested in real time. Execute the test by simulating user interaction operations, and record the page response status R page (t);
[0115] S52. During the process of page dynamic change, monitor and record the status changes of each dynamic content element P i,j (t) in real time, update the status information of the page components and the page structure tree, and define the page response function f resp (t) to describe the response situation of the page under different input conditions;
[0116] S53. Analyze the page response data collected during the test, identify abnormal response situations and potential problems in the page, and generate a preliminary test report, including the page response analysis results of each test step and the information of anomaly detection;
[0117] S54. Based on the data in the preliminary test report, analyze the dynamic behavior of the page, optimize the test input data set and the page response function, and generate a final test report. The final test report includes the response summary of the page under all test conditions and a comprehensive evaluation of the dynamic page behavior.
[0118] S6. Introduce a natural language processing module to parse the text content in the dynamic web page obtained in step S5, and automatically generate a semantic consistency report that conforms to the semantics based on the parsing results, and optimize the test input generation method;
[0119] Furthermore, the specific implementation method of step S6 includes the following steps:
[0120] S61. Introduce a natural language processing module to perform semantic parsing on the text content in the dynamic page and extract the key text elements in the page;
[0121] S62. Based on the semantic analysis ability of the natural language processing module, classify and label the extracted key text elements to generate a text semantic model M semantic (t);
[0122] S63. Utilize the text semantic model M semantic (t) to generate a test input data set {D semantic (t)} that conforms to the current semantics of the page. The test input data set is used to test the semantic consistency of the dynamic elements related to the text content in the page, make the input data match the semantics of the page text content, and define the test input function f semantic (t) to describe the semantic-based input data generation process;
[0123] S64. Automatically generate an expected result verification rule set in combination with the generated semantic input data set. The expected result verification rule set is used to verify the consistency between the page response result and the expected semantics, so that in a complex Web application with multi-language support, the dynamic behavior of the page conforms to the semantic expectations.
[0124] S65. During the testing process, dynamically adjust the semantic input data set and the expected result verification rule set according to the real-time response result of the page to generate a final semantic consistency report. The final semantic consistency report is used to evaluate the semantic performance of the page and its consistency in different language environments, and optimize the test input generation method according to the results to optimize the semantic consistency of the dynamic page.
[0125] S7. Optimize the page splitting strategy, input generation rules, and GraphQL query configuration based on the test report obtained in step S5 and the semantic consistency report obtained in step S6.
[0126] In summary, through intelligent page splitting, real-time data acquisition, and semantic consistency verification, this embodiment significantly improves the test efficiency and coverage of dynamic pages. Especially in complex Web applications with multi-language support, it demonstrates excellent performance and reliability.
[0127] This embodiment uses the Cypress framework combined with the real-time DOM operation ability of dynamic pages to precisely monitor, classify, and mark the dynamic content elements in the page, and perform logical grouping according to the real-time layout and structure information of the page to generate multiple page components. Through the structure information of the page components, automatically generate a test input template that matches the current page state, and dynamically obtain test data consistent with the current page state through the integrated GraphQL API, enabling the test input generation process to respond in real time to changes in page content, automatically covering various possible user operation scenarios, significantly improving the accuracy and comprehensiveness of test input generation, and avoiding the limitations of manual operations and static data sets.
[0128] This embodiment introduces a natural language processing module to perform semantic parsing on the text content in the page, automatically generate test input data that conforms to the semantics, and generate an expected result verification rule set based on the semantic model to ensure that in a complex Web application with multi-language support, the dynamic behavior of the page is consistent with the semantic expectations in different language environments. It can not only effectively detect the semantic performance of the page in different language versions, but also deeply analyze the text elements in the page through the semantic model to generate test input data and verification rules that are more in line with the page semantics, significantly improving the test coverage and accuracy.
[0129] This embodiment utilizes the fast feedback capability of the Cypress framework to record and analyze the response status of the page in real time during test execution, and adjusts the test input data set and page response function according to the dynamic changes of the page. Through the analysis and feedback of the preliminary test report, the present invention can dynamically optimize the test input generation process to ensure that the test input data can accurately reflect the latest status and operation scenarios of the page. Such a dynamic adjustment mechanism based on real-time feedback effectively improves the flexibility and adaptability of the test, ensures comprehensive coverage and accurate verification during the test process, and avoids the problem of test script failure caused by page structure changes.
[0130] Through the method described in this embodiment, automated test input generation no longer depends on a fixed page structure and predefined input data sets, but is dynamically generated based on the real-time status of the page. This not only improves the coverage and accuracy of test inputs, but also reduces the workload of manually writing and maintaining test scripts. When facing complex dynamic pages, it can significantly reduce the test maintenance cost.
[0131] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0132] Although the present application has been described above with reference to specific embodiments, various improvements can be made to it and components can be replaced with equivalents without departing from the scope of the present application. In particular, as long as there is no structural conflict, the various features in the specific embodiments disclosed in the present application can be combined with each other in any way. The reason for not exhaustively describing the situations of these combinations in this specification is only to save space and resources. Therefore, the present application is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. An automated test input generation method based on dynamic page splitting, characterized in that: The steps include: S1. Obtain the dynamic web page to be tested, parse the document object model structure of the dynamic web page based on the Cypress framework, and monitor the dynamic content elements in the page in real time. The dynamic content elements include input fields, buttons, drop-down menus, and pop-up windows dynamically generated by user interaction or background data; S2. Using the real-time DOM operation capability of Cypress, the dynamic content elements monitored in step S1 are classified and marked in real time, and different types of dynamic content elements are logically grouped according to the real-time layout and structure information of the page to form a plurality of page components, each of which contains one or more related dynamic content elements; S3, based on the structural information of the page components obtained in step S2, combined with the integration of Cypress and GraphQL API, dynamically obtain test data from the background, and automatically generate a test input template that matches the current state of the page, wherein the test input template includes the input type of each dynamic content element in each page component, the corresponding input rule, and the GraphQL query result; S4. According to the test input template obtained in step S3, test input data covering various user operation scenarios is automatically generated, and the test input data is obtained through GraphQL query and applied to dynamic page testing in real time; S5. Using the fast feedback capability of the Cypress framework, the test input data generated in step S4 is applied to the dynamic web page to be tested in real time, the test is performed by simulating user interaction, and the test results are recorded and analyzed while the page changes, and a test report is generated; S6, introducing a natural language processing module to parse the text content in the dynamic web page obtained in step S5, and automatically generating a semantic consistency report that conforms to the semantics based on the parsing result, and optimizing the test input generation method; S7. Based on the test report obtained in step S5 and the semantic consistency report obtained in step S6, optimize the page splitting strategy, input generation rules, and GraphQL query configuration.
2. The method for generating automatic test input based on dynamic page splitting according to claim 1, characterized in that: The specific implementation method of step S1 includes the following steps: S11. Load the URL of the dynamic web page to be tested through the access function of the Cypress framework, and record the initial loading state of the dynamic web page, where the initial loading state includes the DOM structure, CSS style, and JavaScript file of the dynamic web page; S12. Based on the DOM structure parsing function of the Cypress framework, real-time monitoring of dynamic content element changes after dynamic web pages are loaded, and definition of monitoring parameter set {P i }, where P i Represents dynamic elements in dynamic web pages, including input fields, buttons, drop-down menus, and pop-up windows; S13, after each dynamic web page refresh or interaction, capture and analyze the newly added or changed dynamic content elements in the dynamic web page in real time, and add the captured elements to the parameter set {P i }, and record the captured element attributes and behaviors: Where Δt represents the time increment, E m (t+Δt) represents the mth dynamic element added or changed at time t+Δt, γ(E m (t+Δt)) is an indicator function, indicating whether the newly added element is added to the parameter set; S14. In combination with the event monitoring function of the Cypress framework, user interaction events and background data updates are monitored in real time, and events associated with dynamic content elements are captured, including click events, input events, and data update events. Events associated with dynamic content elements are associated with corresponding dynamic content elements to form an event-element mapping set. S15. Analyze the hierarchical relationship and dependency relationship of each dynamic content element through the DOM tree traversal function provided by Cypress, and establish a dynamic web page element tree, where the nodes of the element tree represent dynamic content elements, and the edges represent the parent-child or sibling relationship between the elements; S16: Based on the capture and monitoring results, generate an initial record of the dynamic content element changes of the dynamic web page, and store it as an initial record data set D of the dynamic content element changes. init .
3. The method for generating automatic test input based on dynamic page splitting according to claim 2, characterized in that: The specific implementation method of step S2 includes the following steps: S21, based on parameter set {P i } and the initial record data set D of dynamic content element changes init , using the real-time DOM operation capability of the Cypress framework, the monitored dynamic content elements are classified in real time, and the dynamic content elements are divided into subsets of different categories according to the element type, interaction mode and hierarchical relationship. i,j (t)}, where P i,j (t) represents the i-th dynamic content element belonging to category j at time t; S22. Using the initial record data set D init Based on the initial records in the page, the real-time layout information of the page is combined to analyze the position and structure of each category of dynamic content elements, using the position vector Indicates the coordinate information of the element in the page; S23, combining the spatial relationship of the page layout and the initial record data set D init The hierarchical structure between the elements recorded in the , logically grouping dynamic content elements within the same category to form multiple page components S k (t); S24. For each page component S k (t) Mark and combine with the initial record data set D init The data in the structure records the element types, quantity and relationship with other page components, forming a page structure tree. The nodes of the structure represent page components, and the edges represent the hierarchy or dependency relationship between page components.
4. The method for generating automatic test input based on dynamic page splitting according to claim 3, characterized in that: The page structure tree T in step S24 page The generation process of (t) is expressed by the following formula: Among them, β k Indicates the page component S k The node weight of (t), γ k,l (t) is the page component S k (t) and other page components l (t), f(S k (t),S l (t)) represents the page component S k (t) and S l (t), is defined as: f(S k (t),S l (t))=exp(-λ·d(S k (t),S l (t)))·δ(S k (t),S l (t)); Among them, λ is the adjustment factor, which controls the decay rate of the relationship function; d(S k (t),S l (t)) represents the page component S k (t) and S l (t), which can be the Euclidean distance, Manhattan distance or other distance metrics selected according to the page layout; δ(S k (t),S l (t)) is the indicator function, indicating the page component S k (t) and S l (t) Whether there is a hierarchy or dependency relationship, δ(S k (t),S l (t))=1 indicates that there is a relationship, δ(S k (t),S l (t)) = 0 means no relationship; The page structure tree T page The nodes and edges of (t) are compared and updated with the records in the initial record data set to make the hierarchical structure of the page components consistent with the initial records. At the same time, the weight coefficient β of the page structure tree is adjusted in real time according to the dynamic changes of the page. k and γ k,l The value of (t) reflects the latest status of the relationship between the components of the page.
5. The method for generating automatic test input based on dynamic page splitting according to claim 4, characterized in that: The specific implementation method of step S3 includes the following steps: S31, based on the page structure tree T page (t) and the properties of its nodes and edges, combined with the integration of Cypress and GraphQLAPI, dynamically obtain test data that matches the current state of the page from the background, and define the test data set {D test (t)}, where {D test (t)} represents the test data set obtained from the background at time t; S32, according to the page structure tree T page Each page component S in (t) k (t) structure information, automatically generate the corresponding test input template T input (t), the test input template includes each dynamic content element P in the page component i,j (t) Input type and corresponding input rules; S33. Combine the query results obtained from GraphQLAPI and convert the test data set {D test The data in (t)} is matched with the dynamic content elements in the page components to generate the final test input template T input_final (t).
6. The method for generating automatic test input based on dynamic page splitting according to claim 5, characterized in that: The specific implementation method of step S4 includes the following steps: S41, based on the final test input template T input_final (t) According to the structure and element attributes of the page components, a test input dataset covering various user operation scenarios is automatically generated. input (t)}; S42. Combine the real-time query results obtained from the GraphQL API and input the generated test data set {D input (t)} matches the dynamic content elements in the page components, so that the test input data reflects the current state of the page and its possible changes, and defines the operation scenario function f op (t) is used to describe the user operation scenario: Among them, μ k (t) is the page component S k (t) Weight coefficient in a specific operation scenario, ν i,j (t) is the dynamic content element P i,j (t) Input weight coefficient in the corresponding operation scenario, D input,k (t) indicates the page component S k (t) Related test input data, f op (t) represents the input data function for different operation scenarios generated at time t; S43, applying the generated test input data set to dynamic page testing, simulating user interaction operations through the Cypress framework, and monitoring and recording the response of the page in real time; S44, according to the page response data collected during the test, the test input data set is adjusted in real time, and the operation scenario function f op (t) Dynamic optimization is performed to adapt the test input data to the changes in the page and cover all edge scenarios and abnormal situations. The updated operation scenario function is expressed as: f op_updated (t)=f op (t)+Δf op (t); Where Δf op (t) represents the adjustment amount of the operation scenario function based on the test feedback, which is used to reflect the dynamic changes of the page and new test requirements.
7. The method for generating automatic test input based on dynamic page splitting according to claim 6, characterized in that: The specific implementation method of step S5 includes the following steps: S51. Using the fast feedback capability of the Cypress framework, the test input data set is applied to the dynamic web page to be tested in real time, the test is performed by simulating user interaction operations, and the page response status of each test step is recorded. page (t); S52, in the process of dynamic changes of the page, real-time monitoring and recording of each dynamic content element P i,j (t) state changes, updates the state information of the page components and the page structure tree, and defines the page response function f resp (t) is used to describe the response of the page under different input conditions; S53, analyzing the page response data collected during the test, identifying abnormal responses and potential problems in the page, and generating a preliminary test report including the page response analysis results of each test step and abnormality detection information; S54. Based on the data in the preliminary test report, analyze the dynamic behavior of the page, optimize the test input data set and page response function, and generate a final test report. The final test report includes a summary of the page's response under all test conditions and a comprehensive evaluation of the dynamic page behavior.
8. The method for generating automatic test input based on dynamic page splitting according to claim 7, characterized in that: The specific implementation method of step S6 includes the following steps: S61, introducing a natural language processing module to perform semantic analysis on the text content in the dynamic page and extract key text elements in the page; S62. Based on the semantic analysis capability of the natural language processing module, the extracted key text elements are classified and annotated to generate a text semantic model M. semantic (t); S63. Using text semantic model M semantic (t) Generate a test input dataset that conforms to the current semantics of the page {D semantic (t)}, the test input data set is used to test the semantic consistency of dynamic elements related to the text content in the page, so that the input data matches the semantics of the page text content, and the test input function f is defined semantic (t) used to describe the semantic-based input data generation process; S64, automatically generating an expected result verification rule set in combination with the generated semantic input data set, where the expected result verification rule set is used to verify the consistency between the page response result and the expected semantics, so that the dynamic behavior of the page is consistent with the semantic expectations in a complex Web application supporting multiple languages; S65. During the test, the semantic input data set and the expected result verification rule set are dynamically adjusted according to the real-time response results of the page to generate a final semantic consistency report. The final semantic consistency report is used to evaluate the semantic performance of the page and its consistency in different language environments, and optimize the test input generation method based on the results to optimize the semantic consistency of the dynamic page.
Citation Information
Patent Citations
Test method and device
CN118363846A
Methods, systems, and articles of manufacture for testing web services using a behavior-driven development domain specific language framework
US10810110B1