Web automatic testing method and system based on parameterized input
By capturing user browser operations to generate basic scripts, and forming flexible test scripts through parameterization and modular processing, the problems of frequent parameter changes and low use case writing efficiency in web automation testing are solved, and an efficient and stable test process is achieved.
Patent Information
- Application Number
- CN202411888356.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
AI Technical Summary
Parameter changes frequently in existing Web automation testing methods, resulting in low efficiency in writing use cases, high cost of manually updating test scripts, and untimely maintenance.
Using a web automated testing method based on parameterized input, the basic script is generated by capturing user browser operations, analyzing and reconstructing the script to include parameter variables, forming a modular and flexible test script, and verifying the results of multiple scenarios through the test loop.
Reduces the workload of manually writing scripts, improves script flexibility and stability, ensures high test coverage through multi-scenario verification, and reduces maintenance costs and use case writing time.
Smart Images

Figure CN119829437A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software testing, and in particular to a Web automated testing method and system based on parameterized input. Background Art
[0002] Web (WorldWide Web) is a global, dynamic, interactive, cross-platform distributed graphical information system based on hypertext and HTTP. With the rapid development of Internet technology, the complexity of Web applications continues to increase, and manual testing methods can no longer meet the needs of efficient and accurate testing.
[0003] As an effective solution, automated testing can significantly improve testing efficiency and quality. However, the automated testing methods in related technologies require professional testers with automation capabilities to write a large number of test scripts, and when the web is updated, the automated test scripts need to be manually updated synchronously, which not only has high maintenance costs but also may not be updated in time. This leads to parameter changes in the test method and low efficiency in writing test cases. Summary of the invention
[0004] The present application provides a Web automated testing method and system based on parameterized input to solve the problems of parameter changes in the testing method and low efficiency in writing test cases.
[0005] In a first aspect, the present application provides a Web automation testing method based on parameterized input, the method comprising:
[0006] Capturing user operations in the browser to generate basic scripts; the operations include clicking buttons, entering text, scrolling pages, and selecting drop-down menu items;
[0007] Analyzing and reconstructing the basic script to generate a test script containing parameter variables, wherein the test script is used to execute different test scenarios with different parameter values;
[0008] Modifying the test script to obtain a modified test script;
[0009] Setting a number of test cycles, and using the test cycles to test the modified test script to obtain test results;
[0010] A test report is generated according to the test results.
[0011] The present application automatically captures user operations and generates basic scripts, analyzes, reconstructs and optimizes the basic scripts, thereby reducing the workload of manual script writing and enhancing the flexibility and stability of the scripts. Multi-scenario verification is then performed through test cycles to solve the problems of parameter changes in the test method and low efficiency in writing use cases.
[0012] In some feasible embodiments, the step of capturing the user's operation in the browser to generate a basic script includes:
[0013] Select the recording module according to the web application type;
[0014] configuring the recording module to capture the operations of all users;
[0015] Recording operation information of each of the operations;
[0016] Generate a basic script according to the operation information.
[0017] Selecting a recording module based on the type of web application ensures that the test script accurately reflects the actual user behavior, thereby improving the accuracy and efficiency of the test. Configuring the recording module to automatically capture all user operations can reduce the need to manually write test scripts, thereby reducing labor costs and improving work efficiency. Recording the operation information of each operation can provide rich data support for subsequent test script analysis and optimization, thereby improving product functions and user experience. Since the basic script is generated based on the actual user operation, it is easier to understand and modify, making it easier and faster to update the test script, which helps to keep the test case in sync with the application status.
[0018] In some feasible embodiments, the operation information includes location information, timestamp, and attributes of the operation object.
[0019] By recording location information, the user's operation path on the page can be accurately reproduced, which is convenient for locating problems and verifying functions. Timestamps help analyze the time sequence and duration of user behavior. The properties of the operation object can provide rich contextual information, which helps to understand the user's intentions and behavior patterns, facilitate subsequent test script analysis and optimization, and better support complex test scenarios. In addition, timestamps and location information have high traceability. If an error or exception occurs, it can be easily traced back to the specific operation steps and environmental status.
[0020] In some feasible embodiments, the step of analyzing and reconstructing the basic script to generate a test script containing parameter variables includes:
[0021] Using regular expressions to extract fixed values from the basic script; wherein the fixed values include form input and search keywords;
[0022] replacing the fixed value with the parameter variable;
[0023] Split the base script into multiple functions or classes so that each function or class is responsible for one task;
[0024] defining parameters of the parameter variable in the function or class;
[0025] A test script containing parameter variables is generated according to the defined parameter variables and the basic script.
[0026] By using regular expressions to extract fixed values from the base script and replacing the fixed values with parameter variables, it is easy to use different values in different test scenarios to improve the flexibility and reusability of the test script. Splitting the base script into multiple functions or classes, each responsible for a specific task, helps improve the readability and maintainability of the code, making the test script clearer, easier to understand and modify. Defining parameter variables in functions or classes allows test scripts to execute different test scenarios by passing different parameters, which can improve the efficiency of testing. Because test scripts are modular and parameterized, it is easier to adapt to changes in the application. When the application is updated, only the corresponding function or class needs to be modified without rewriting the entire test script.
[0027] In some feasible embodiments, the step of modifying the test script includes:
[0028] Capturing exceptions in the test script according to preset exception types; the preset exception types include network request timeout, element not found, and page loading failure;
[0029] Taking recovery measures matching the exception to recover the exception; the recovery measures include retrying the operation, skipping the current step, and recording an error log;
[0030] Dynamically adjust waiting time to reduce test failures caused by different page loading speeds;
[0031] Use the logging framework to record execution logs.
[0032] By capturing preset exception types in the test script, you can ensure that the test script will not fail directly when encountering these common problems, thereby improving the overall reliability of the test. Taking recovery measures that match the exception can reduce the need for manual intervention, making the test process more automated and efficient, helping to reduce test execution time and improve test coverage. Dynamically adjusting the waiting time according to the different page loading speeds can effectively reduce test failures caused by differences in page loading speeds, and can improve the adaptability of the test script to different network environments and device performance, thereby enhancing the stability of the test. Using the log framework to record execution logs provides rich data support for subsequent problem location and analysis, which helps to quickly identify and solve problems, thereby improving test efficiency.
[0033] In some feasible embodiments, the step of setting a plurality of test cycles and using the test cycles to test the modified test script to obtain the test results includes:
[0034] Set the number of test cycles;
[0035] Different parameter values are passed in through the random function in each test cycle;
[0036] Execute the modified test script after setting up the test loop to get the test results.
[0037] By setting the number of test loops and passing in different parameter values in each loop, you can ensure that the test covers more scenarios and edge cases, which helps to discover potential problems and improve the quality of the software. Using random functions to automatically generate different parameter values can reduce the need to manually write test cases, thereby reducing labor costs and improving work efficiency, making the testing process more automated and efficient. By passing in different parameter values in each test loop, you can easily simulate different user behaviors and operating conditions, which helps to test various possible usage scenarios and ensure that the software works properly in various situations. Executing the modified test script after setting the test loop can obtain detailed test results, which helps to quickly identify and solve problems, thereby improving testing efficiency.
[0038] In some feasible embodiments, the test scenarios include forward testing, reverse testing, and boundary value testing.
[0039] Through a variety of test scenarios, including forward testing, reverse testing, and boundary value testing, it is possible to ensure that the software can work properly under various possible usage situations, which helps to discover potential problems and improve the quality of the software. Different types of test scenarios can also cover more edge cases and abnormal paths, thereby improving test coverage, helping to ensure that the software can run stably under various conditions and reduce the number of subsequent problems.
[0040] In some feasible embodiments, the step of generating a test report according to the test result includes:
[0041] Verify the consistency between the test result and the actual result through the assertion mechanism to generate a verification result; the verification result includes the test result, execution log and exception information;
[0042] A test report is generated according to the verification result.
[0043] By using the assertion mechanism, the consistency of test results with expected results can be ensured. Automatically generating test reports based on verification results can not only reduce the workload of manual report writing and improve the efficiency and accuracy of the test process, but also make it easier to cover more test cases, thereby improving the overall quality and reliability of the software.
[0044] In a second aspect, the present application provides a Web automated testing system based on parameterized input, which is used to execute the Web automated testing method based on parameterized input described in the first aspect, and the testing system includes: a recording module, a parameterized processing module, a script generation module, a loop execution module and a result analysis module;
[0045] The recording module is used to capture the user's operations in the browser to generate a basic script;
[0046] The parameterized processing module is used to analyze and reconstruct the basic script;
[0047] The script generation module is used to generate a test script containing parameter variables according to the analyzed and reconstructed basic script; and is also used to modify the test script to obtain a modified test script;
[0048] The loop execution module is used to set a number of test loops and use the test loops to test the modified test script to obtain test results;
[0049] The result analysis module is used to generate the test report according to the test results.
[0050] The present application automatically captures user operations and generates basic scripts, analyzes, reconstructs and optimizes the basic scripts, thereby reducing the workload of manual script writing and enhancing the flexibility and stability of the scripts. Multi-scenario verification is then performed through test cycles to solve the problems of parameter changes in the test method and low efficiency in writing use cases.
[0051] In some feasible embodiments, the test system further includes a parameter configuration module;
[0052] The parameter configuration module is used to pass different parameter values through a random function in each test cycle.
[0053] The parameter configuration module ensures that the test covers more scenarios and edge cases by passing different parameter values in each test cycle, which helps to find potential problems and improve the quality of the software. Using random functions to automatically generate different parameter values can reduce the need to manually write test cases, thereby reducing labor costs and improving work efficiency, making the testing process more automated and efficient. By passing different parameter values in each test cycle, different user behaviors and operating conditions can be easily simulated, which helps to test various possible usage scenarios and ensure that the software works properly in various situations.
[0054] It can be seen from the above technical solutions that the present application provides a Web automation testing method and system based on parameterized input, which generates a basic script by capturing the user's operations in the browser; analyzes and reconstructs the basic script to generate a test script containing parameter variables, which is used to execute different test scenarios through different parameter values; modifies the test script to obtain a modified test script; sets several test loops, and uses the test loop to test the modified test script to obtain test results; and generates a test report based on the test results. The present application automatically captures user operations and generates a basic script, analyzes, reconstructs and optimizes the basic script, which can reduce the workload of manual script writing and enhance the flexibility and stability of the script, and then performs multi-scenario verification through test loops to solve the problems of parameter changes in the test method and low efficiency in writing use cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0056] Figure 1 A schematic diagram of a process flow of a Web automated testing method based on parameterized input described in an embodiment of the present application;
[0057] Figure 2 A schematic diagram of a process for generating a basic script in a Web automated testing method based on parameterized input according to an embodiment of the present application;
[0058] Figure 3 A schematic diagram of a process for generating a test script containing parameter variables in a Web automated testing method based on parameterized input according to an embodiment of the present application;
[0059] Figure 4 A schematic diagram of a process of modifying a test script in a Web automated testing method based on parameterized input according to an embodiment of the present application;
[0060] Figure 5 A schematic diagram of a process for obtaining test results in a Web automated testing method based on parameterized input according to an embodiment of the present application;
[0061] Figure 6 A schematic diagram of a process for generating a test report in a Web automated testing method based on parameterized input according to an embodiment of the present application;
[0062] Figure 7 This is a flow chart of a Web automated testing system based on parameterized input as described in an embodiment of the present application. DETAILED DESCRIPTION
[0063] The embodiments will be described in detail below, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation methods described in the following embodiments do not represent all implementation methods consistent with the present application. They are only examples of systems and methods consistent with some aspects of the present application.
[0064] In order to solve the problem of parameter changes in the test method and low efficiency in writing test cases, some embodiments of the present application provide a Web automated testing method based on parameterized input, see Figure 1 , methods include:
[0065] S100: Capture the user's operations in the browser to generate a basic script.
[0066] Actions include clicking buttons, entering text, scrolling pages, and selecting drop-down menu items.
[0067] In some embodiments, see Figure 2 ,The steps to capture the user's operations in the browser and generate the basic script include:
[0068] S110: Select a recording module according to the Web application type.
[0069] The recording module has a user-friendly interface and can be used with Selenium IDE and Katalon Studio. The recording module supports multiple browsers, such as Chrome, Firefox, and Edge. You can select a recording module based on the type of web application and customize it for different application features. For example, for pages with complex form input or a lot of dynamic content loading, you can select a specific recording module to capture these operations.
[0070] S120: Configuring a recording module to capture operations of all users.
[0071] It should be understood that when configuring the recording module, it is also necessary to configure the output format of the recording module so that it generates a basic script that meets the standard. For example, the output format of the recording module is configured as Python language.
[0072] S130: Recording operation information of each operation.
[0073] The operation information includes the location information, timestamp, and attributes of the operation object (such as ID, Class, and XPath) of each operation.
[0074] By recording location information, the user's operation path on the page can be accurately reproduced, which is convenient for locating problems and verifying functions. Timestamps help analyze the time sequence and duration of user behavior. The properties of the operation object can provide rich contextual information, which helps to understand the user's intentions and behavior patterns, facilitate subsequent test script analysis and optimization, and better support complex test scenarios. In addition, timestamps and location information have high traceability. If an error or exception occurs, it can be easily traced back to the specific operation steps and environmental status.
[0075] S140: Generate a basic script according to the operation information.
[0076] It should be understood that the basic script should conform to the standard format of the selected programming language to ensure readability and maintainability. The basic script should be divided into multiple units, each unit is responsible for a specific operation or function, to facilitate subsequent modification and expansion.
[0077] Selecting a recording module based on the type of web application ensures that the test script accurately reflects the actual user behavior, thereby improving the accuracy and efficiency of the test. Configuring the recording module to automatically capture all user operations can reduce the need to manually write test scripts, thereby reducing labor costs and improving work efficiency. Recording the operation information of each operation can provide rich data support for subsequent test script analysis and optimization, thereby improving product functions and user experience. Since the basic script is generated based on the actual user operation, it is easier to understand and modify, making it easier and faster to update the test script, which helps to keep the test case in sync with the application status.
[0078] S200: Analyze and reconstruct the basic script to generate a test script containing parameter variables.
[0079] Test scripts are used to execute different test scenarios with different parameter values.
[0080] In some embodiments, see Figure 3 ,The steps of analyzing and refactoring the base script to generate a test script containing parameter variables include:
[0081] S210: Extract fixed values from the base script using regular expressions.
[0082] Fixed values include form input and search keywords. It should be understood that a regular expression is a string that describes a character pattern. It uses specific symbols and syntax to define rules for matching, finding, and replacing text. All element components that need to be located extracted from the basic script using regular expressions are fixed values, such as whitelist enablement, name, address, etc.
[0083] S220: Replace the fixed value with the parameter variable.
[0084] For example, use a dictionary to pass in multiple parameters to replace the previous fixed value 1.1.1.1.
[0085] S230: Split the basic script into multiple functions or classes, so that each function or class is responsible for one task.
[0086] For example, split the whitelist task into creating and editing.
[0087] S240: Define parameters of parameter variables in a function or class.
[0088] Different test scenarios can be implemented by passing different parameters when calling.
[0089] S250: Generate a test script containing parameter variables according to the defined parameter variables and the basic script.
[0090] By using regular expressions to extract fixed values from the base script and replacing the fixed values with parameter variables, it is easy to use different values in different test scenarios to improve the flexibility and reusability of the test script. Splitting the base script into multiple functions or classes, each responsible for a specific task, helps improve the readability and maintainability of the code, making the test script clearer, easier to understand and modify. Defining parameter variables in functions or classes allows test scripts to execute different test scenarios by passing different parameters, which can improve the efficiency of testing. Because test scripts are modular and parameterized, it is easier to adapt to changes in the application. When the application is updated, only the corresponding function or class needs to be modified without rewriting the entire test script.
[0091] S300: Modify the test script to obtain a modified test script.
[0092] In some embodiments, see Figure 4 , the steps to modify the test script include:
[0093] S310: Capture an exception in the test script according to a preset exception type.
[0094] The preset exception types include network request timeout, element not found, and page loading failure. Exceptions can be caught using the try-except statement. In Python programming, the try-except statement is an important mechanism for handling exceptions (i.e. errors that occur during program execution). It allows developers to capture and handle exceptions that may occur during code execution, thereby avoiding program crashes and providing more friendly error messages or recovery strategies.
[0095] S320: Take recovery measures that match the exception to recover from the exception.
[0096] Recovery measures include retrying, skipping the current step, and recording error logs. For example, when the exception type is network request timeout, the recovery measure is retrying; when the exception type is element not found, the recovery measure is skipping the current step; when the exception type is page loading failure, the recovery measure is recording error logs.
[0097] S330: Dynamically adjust the waiting time to reduce test failures caused by different page loading speeds.
[0098] Dynamically adjust the waiting time and try to use intelligent waiting to avoid directly calling the sleep function for a long wait.
[0099] S340: Use the log framework to record the execution log.
[0100] It should be understood that a logging framework (such as Python's logging module) is used to record detailed information of each step of the operation.
[0101] By capturing preset exception types in the test script, you can ensure that the test script will not fail directly when encountering these common problems, thereby improving the overall reliability of the test. Taking recovery measures that match the exception can reduce the need for manual intervention, making the test process more automated and efficient, helping to reduce test execution time and improve test coverage. Dynamically adjusting the waiting time according to the different page loading speeds can effectively reduce test failures caused by differences in page loading speeds, and can improve the adaptability of the test script to different network environments and device performance, thereby enhancing the stability of the test. Using the log framework to record execution logs provides rich data support for subsequent problem location and analysis, which helps to quickly identify and solve problems, thereby improving test efficiency.
[0102] S400: setting a number of test cycles, and using the test cycles to test and modify the test script to obtain test results.
[0103] In some embodiments, see Figure 5 , setting several test cycles, and modifying the test script using the test cycle test to obtain the test results include:
[0104] S410: Set the number of test cycles.
[0105] It should be understood that the number of cycles is set according to the test requirements. For example, the test requirements may be conditional factors such as the maximum number of attempts or time limit; the number of cycles may be selected as 10 times, 100 times, etc.
[0106] S420: In each test cycle, different parameter values are passed in through a random function.
[0107] It should be understood that the random function is an important programming tool that can generate random numbers or pseudo-random numbers as needed to pass in different parameter values.
[0108] S430: Execute the modified test script after setting the test cycle to obtain the test result.
[0109] It should be understood that the test results include the execution status, pass / fail status, and error information of each test case.
[0110] By setting the number of test loops and passing in different parameter values in each loop, you can ensure that the test covers more scenarios and edge cases, which helps to discover potential problems and improve the quality of the software. Using random functions to automatically generate different parameter values can reduce the need to manually write test cases, thereby reducing labor costs and improving work efficiency, making the testing process more automated and efficient. By passing in different parameter values in each test loop, you can easily simulate different user behaviors and operating conditions, which helps to test various possible usage scenarios and ensure that the software works properly in various situations. Executing the modified test script after setting the test loop can obtain detailed test results, which helps to quickly identify and solve problems, thereby improving testing efficiency.
[0111] S500: Generate a test report according to the test results.
[0112] In some embodiments, see Figure 6 , the steps of generating a test report based on the test results include:
[0113] S510: Verify the consistency between the test result and the actual result through the assertion mechanism to generate a verification result.
[0114] Verification results include test results, execution logs, and exception information. Assertion mechanism is an important technology in programming, which is used to verify whether the assumptions in the program are true. If the condition is false, an exception or error message is triggered, which can help developers quickly find and locate problems.
[0115] S520: Generate a test report according to the verification result.
[0116] It should be understood that the tool for generating the test report adopts an automated test report tool, such as Allure or ExtentReports.
[0117] By using the assertion mechanism, the consistency of test results with expected results can be ensured. Automatically generating test reports based on verification results can not only reduce the workload of manual report writing and improve the efficiency and accuracy of the test process, but also make it easier to cover more test cases, thereby improving the overall quality and reliability of the software.
[0118] This application automatically captures user operations and generates basic scripts, analyzes, reconstructs and optimizes the basic scripts, which can reduce the workload of manual script writing and enhance the flexibility and stability of the scripts. It then performs multi-scenario verification through test cycles to solve the problems of parameter changes in test methods and low efficiency in writing use cases.
[0119] In some embodiments, the test scenarios include forward testing, reverse testing, and boundary value testing.
[0120] It should be understood that forward testing is also called functional testing or valid input testing, and its purpose is to verify whether the system behaves as expected under normal circumstances. Reverse testing is also called invalid input testing, and its purpose is to verify whether the system behaves as expected under abnormal circumstances. Reverse testing is often used to check the robustness and error handling capabilities of the system. Boundary value testing is a testing method specifically for the boundaries of the input range, and its purpose is to verify whether the system behaves as expected under boundary conditions. Boundary values include minimum values, maximum values, and conditions slightly less than and slightly greater than these values.
[0121] Through a variety of test scenarios, including forward testing, reverse testing, and boundary value testing, it is possible to ensure that the software can work properly under various possible usage situations, which helps to discover potential problems and improve the quality of the software. Different types of test scenarios can also cover more edge cases and abnormal paths, thereby improving test coverage, helping to ensure that the software can run stably under various conditions and reduce the number of subsequent problems.
[0122] See also Figure 7 ,Some embodiments of the present application also provide a Web automated testing system based on parameterized input, which is used to execute the Web automated testing method based on parameterized input of the above embodiment, and the testing system includes: a recording module, a parameterized processing module, a script generation module, a loop execution module and a result analysis module;
[0123] The recording module is used to capture the user's operations in the browser to generate basic scripts.
[0124] The parameterized processing module is used to analyze and reconstruct the basic scripts.
[0125] The script generation module is used to generate a test script containing parameter variables according to the analyzed and reconstructed basic script; and is also used to modify the test script to obtain a modified test script.
[0126] The loop execution module is used to set several test loops and use the test loop tests to modify the test scripts to obtain test results.
[0127] The result analysis module is used to generate a test report based on the test results.
[0128] This application automatically captures user operations and generates basic scripts, analyzes, reconstructs and optimizes the basic scripts, which can reduce the workload of manual script writing and enhance the flexibility and stability of the scripts. It then performs multi-scenario verification through test cycles to solve the problems of parameter changes in test methods and low efficiency in writing use cases.
[0129] In some embodiments, see again Figure 7 ,The test system also includes a parameter configuration module; the parameter configuration module is used to ,input different parameter values through a random function in each test cycle.
[0130] It should be understood that after generating a test script containing parameter variables, it is necessary to determine whether to configure the parameters. If no parameters need to be configured, the test script can be modified by directly setting several test loops through the loop execution module to obtain test results. If parameters need to be configured, different parameter values are passed in through a random function through the parameter configuration module in each test loop, and then the test script is modified by setting several test loops through the loop execution module to obtain test results.
[0131] The parameter configuration module ensures that the test covers more scenarios and edge cases by passing different parameter values in each test cycle, which helps to find potential problems and improve the quality of the software. Using random functions to automatically generate different parameter values can reduce the need to manually write test cases, thereby reducing labor costs and improving work efficiency, making the testing process more automated and efficient. By passing different parameter values in each test cycle, different user behaviors and operating conditions can be easily simulated, which helps to test various possible usage scenarios and ensure that the software works properly in various situations.
[0132] It can be seen from the above technical solutions that the embodiment of the present application provides a Web automation testing method and system based on parameterized input, which generates a basic script by capturing the user's operation in the browser; analyzes and reconstructs the basic script to generate a test script containing parameter variables, which is used to execute different test scenarios through different parameter values; modifies the test script to obtain a modified test script; sets several test loops, and uses the test loop to test the modified test script to obtain the test results; and generates a test report based on the test results. The present application automatically captures user operations and generates a basic script, analyzes, reconstructs and optimizes the basic script, which can reduce the workload of manual script writing and enhance the flexibility and stability of the script, and then performs multi-scenario verification through the test loop to solve the problem of parameter changes in the test method and low efficiency in writing use cases.
[0133] Similar parts between the embodiments provided in this application can be referenced to each other. The specific implementation methods provided above are only a few examples under the general concept of this application and do not constitute a limitation on the protection scope of this application. For those skilled in the art, any other implementation methods expanded based on the scheme of this application without creative work belong to the protection scope of this application.
Claims
1. A Web automation testing method based on parameterized input, characterized in that: The method comprises: Capturing user operations in the browser to generate basic scripts; the operations include clicking buttons, entering text, scrolling pages, and selecting drop-down menu items; Analyzing and reconstructing the basic script to generate a test script containing parameter variables, wherein the test script is used to execute different test scenarios with different parameter values; Modifying the test script to obtain a modified test script; Setting a number of test cycles, and using the test cycles to test the modified test script to obtain test results; A test report is generated according to the test results.
2. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The step of capturing the user's operation in the browser to generate a basic script includes: Select the recording module according to the web application type; configuring the recording module to capture the operations of all users; Recording operation information of each of the operations; Generate a basic script according to the operation information.
3. The Web automated testing method based on parameterized input according to claim 2 is characterized in that: The operation information includes location information, timestamp, and attributes of the operation object.
4. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The steps of analyzing and reconstructing the basic script to generate a test script containing parameter variables include: Using regular expressions to extract fixed values from the basic script; wherein the fixed values include form input and search keywords; replacing the fixed value with the parameter variable; Split the base script into multiple functions or classes so that each function or class is responsible for one task; defining parameters of the parameter variable in the function or class; A test script containing parameter variables is generated according to the defined parameter variables and the basic script.
5. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The step of modifying the test script comprises: Capturing exceptions in the test script according to preset exception types; the preset exception types include network request timeout, element not found, and page loading failure; Taking recovery measures matching the exception to recover the exception; the recovery measures include retrying the operation, skipping the current step, and recording an error log; Dynamically adjust waiting time to reduce test failures caused by different page loading speeds; Use the logging framework to record execution logs.
6. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The step of setting a plurality of test cycles and using the test cycles to test the modified test script to obtain the test results includes: Set the number of test cycles; Different parameter values are passed in through the random function in each test cycle; Execute the modified test script after setting up the test loop to get the test results.
7. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The test scenarios include forward testing, reverse testing and boundary value testing.
8. The Web automated testing method based on parameterized input according to claim 1, characterized in that: The step of generating a test report according to the test results comprises: Verify the consistency between the test result and the actual result through the assertion mechanism to generate a verification result; the verification result includes the test result, execution log and exception information; A test report is generated according to the verification result.
9. A Web automated testing system based on parameterized input, characterized in that: Used to execute the Web automated testing method based on parameterized input according to any one of claims 1 to 8, the testing system comprises: a recording module, a parameterized processing module, a script generation module, a loop execution module and a result analysis module; The recording module is used to capture the user's operations in the browser to generate a basic script; The parameterized processing module is used to analyze and reconstruct the basic script; The script generation module is used to generate a test script containing parameter variables according to the analyzed and reconstructed basic script; and is also used to modify the test script to obtain a modified test script; The loop execution module is used to set a number of test loops and use the test loops to test the modified test script to obtain test results; The result analysis module is used to generate the test report according to the test results.
10. The Web automated testing system based on parameterized input according to claim 9, characterized in that: Also includes parameter configuration module; The parameter configuration module is used to pass different parameter values through a random function in each test cycle.
Citation Information
Cited By
Automatic testing and dynamic variable modification method and system based on multiple scripts
CN120256315A
Automated Testing Based on Multiple Scripts and Method and System for Modifying Dynamic Variables
CN120256315B
Financial payment transaction test method based on recording and playback
CN120336199A
A financial payment transaction testing method based on recording and playback
CN120336199B