Automatic webpage testing method and device, electronic equipment and storage medium
By obtaining the reasons for the failure of web automation tests, determining customized retry strategies and optimizing test scripts, the problems of frequent test failures and complex manual analysis in the existing technology are solved, which improves testing efficiency and stability and reduces maintenance costs.
Patent Information
- Application Number
- CN202411801364.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-05-06
AI Technical Summary
When executing test cases, existing web page automation testing tools often fail to test due to network problems, resource competition, page element loading failure, login cookie failure and other problems. The number of retries is preset, and the cause of failure and the number of retries is required to manually analyze the cause of failure and the number of retries, which is inefficient and costly.
Provides a web page automated testing method, which can determine a customized retry strategy by obtaining the cause of the test failure, retry the current test case, and optimize the test script based on the script configuration information that was successfully used after the retry is successful.
Improves the reliability and stability of tests, eliminates inefficient or unstable script configurations, reduces test failures and duplicate work caused by script errors or inefficiency, and reduces maintenance costs.
Smart Images

Figure CN119938515A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of web page testing, and more specifically, to a web page automated testing method, device, electronic equipment and storage medium. Background Art
[0002] Web page testing is the process of verifying whether a Web application can run normally in different environments. Through comprehensive testing, it aims to ensure that all web page functions work as expected, such as form submission, link jump, search function, etc., to ensure the high quality, high reliability and high user satisfaction of Web applications. When executing test cases, existing web page automation testing tools often fail due to network problems, resource competition, page element loading failure, login cookie invalidation and other problems.
[0003] Chinese patent application number 202111530851.3, application date 2021.12.14, discloses an automated exception handling method, system, device and medium for program testing, running a test script to sequentially execute at least one test program in the test script; if the test result corresponding to the test program is a failure, the failure reason is obtained, and it is determined whether the number of executions of the test program is less than a preset threshold; if so, the test program is repeatedly executed. Although the patent solution performs multiple retries and identifies the cause of the test failure after the test fails, it only performs a preset number of retries, and only records the cause of the test failure. The tester still needs to manually discover whether the test script needs to be optimized through the recorded cause of the test failure and the number of retries, which results in low efficiency of the entire test and increased labor costs. Summary of the invention
[0004] In view of this, the present invention provides a web page automated testing method, device, electronic device and storage medium, which can improve the efficiency of web page automated testing and reduce human maintenance costs.
[0005] In order to achieve the above object, the present invention adopts the following technical scheme:
[0006] In a first aspect, the present invention provides a web page automated testing method, the method comprising:
[0007] When the current test case fails, the electronic device obtains the reason for the test failure;
[0008] The electronic device determines a retry strategy based on the test failure cause, and retests the current test case at least once based on the retry strategy;
[0009] After the current test case is successfully retried, the electronic device optimizes the test script corresponding to the current test case based on the script configuration information used in the successful retry.
[0010] The method provided by the present invention customizes the retry strategy according to the cause of the test failure, can more effectively deal with different types of test failures, improves the reliability and stability of the test, and after the retry is successful, optimizes the test script based on the successfully used script configuration information, can eliminate inefficient or unstable script configurations, improve the efficiency and stability of script testing, and help form a more robust and efficient test script library, providing a solid foundation for future testing work. At the same time, through the continuous optimization of test scripts, test failures and repeated work caused by script errors or inefficiencies are reduced, the need for manual intervention is reduced, and maintenance costs are further reduced.
[0011] In a possible implementation, the electronic device determines a retry strategy based on a test failure cause, and retests the current test case at least once based on the retry strategy, including:
[0012] The electronic device determines a test stop condition based on the test failure reason;
[0013] The electronic device determines whether the test stop condition is met;
[0014] If the test stop condition is met, the electronic device stops testing the current test case;
[0015] If the test stop condition is not met, the electronic device obtains new script configuration information;
[0016] The electronic device retests the current test case based on the new script configuration information;
[0017] If the retest result of the current test case is failure, repeating the step of the electronic device determining whether the test stop condition is met until the test stop condition is met;
[0018] If the retest result of the current test case is successful, the electronic device stops testing the current test case.
[0019] In a possible implementation, the electronic device determines the test stop condition based on the test failure reason, including:
[0020] If the reason for the test failure is a page element loading timeout, the electronic device determines that the test stop condition is that the current global waiting time of the current test case reaches the maximum waiting time;
[0021] If the reason for the test failure is a page element positioning error, the electronic device determines that the test stop condition is that there is no unselected candidate element positioning information in the candidate element positioning information set corresponding to the current test case.
[0022] In a possible implementation, if the test stop condition is not met, the electronic device obtains new script configuration information including:
[0023] If the current global waiting time does not reach the maximum waiting time, the electronic device increases the current global waiting time and determines the increased current global waiting time as new script configuration information;
[0024] If there is unselected candidate element positioning information in the candidate element positioning information set, the electronic device selects a piece of candidate element positioning information from the unselected candidate element positioning information as new script configuration information.
[0025] In a possible implementation manner, the electronic device increases the current global waiting time, and determines the increased current global waiting time as new script configuration information, including:
[0026] The electronic device obtains a preset increase time;
[0027] The electronic device determines whether the sum of the preset increase time and the current global waiting time reaches the maximum waiting time;
[0028] If the sum of the preset increase time and the current global waiting time reaches the maximum waiting time, the electronic device reduces the sum of the preset increase time and the current global waiting time so that the sum of the reduced preset increase time and the current global waiting time is less than the maximum waiting time;
[0029] The electronic device determines the sum of the reduced preset increase time and the current global waiting time as new script configuration information.
[0030] In a possible implementation manner, the candidate element positioning information includes a candidate element positioning mode and a candidate positioning parameter corresponding to the candidate element positioning mode.
[0031] In a possible implementation, the electronic device optimizes the test script corresponding to the current test case based on the script configuration information used for the successful retry, including:
[0032] The electronic device updates the corresponding configuration information in the test script based on the script configuration information used in the successful retry, and generates an optimized test script.
[0033] In a second aspect, the present invention provides a web page automated testing device, comprising: a cause acquisition module, a retry module and an optimization module; wherein:
[0034] The reason acquisition module is connected to the retry module and is used for the electronic device to obtain the reason for the test failure when the current test case fails;
[0035] A retry module, connected to the cause acquisition module and the optimization module respectively, is used for the electronic device to determine a retry strategy based on the cause of the test failure, and to retest the current test case at least once based on the retry strategy;
[0036] The optimization module is connected to the retry module and is used for optimizing the test script corresponding to the current test case based on the script configuration information used for the successful retry after the current test case is successfully retried.
[0037] In a third aspect, the present invention provides an electronic device comprising a processor and a memory; the memory stores a computer program or computer instructions that can be loaded by the processor and executed such as the web page automation testing method of the first aspect and any possible implementation thereof.
[0038] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program or computer instructions that can be loaded by a processor and executed by a web page automation testing method such as the first aspect and any possible implementation thereof.
[0039] In a fifth aspect, the present invention provides a computer program product, including a computer program or computer instructions, which, when loaded and executed by a processor, implement the steps of the web page automation testing method as in the first aspect and any possible implementation thereof.
[0040] For the specific description of the second to fifth aspects and their various implementations in the present invention, reference can be made to the detailed description in the first aspect and its various implementations; and for the beneficial effects of the second to fifth aspects and their various implementations, reference can be made to the analysis of the beneficial effects in the first aspect and its various implementations, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0042] Figure 1 It is a flowchart of a web page automation testing method according to an embodiment of the present invention;
[0043] Figure 2 It is a flowchart of the sub-steps of step S102 in a webpage automated testing method according to an embodiment of the present invention;
[0044] Figure 3 It is a flowchart of a specific application of a web page automation testing method according to an embodiment of the present invention;
[0045] Figure 4is a flowchart of another specific application of a web page automation testing method according to an embodiment of the present invention;
[0046] Figure 5 It is a structural block diagram of a web page automatic testing device according to an embodiment of the present invention;
[0047] Figure 6 It is a block diagram of the internal structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0048] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0049] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0050] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0051] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0052] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0053] In order to facilitate understanding of the technical solution of the present invention, the terms involved in the present invention are briefly introduced below.
[0054] Embodiment 1:
[0055] The embodiment of the present invention provides a method for automated testing of web pages. Figure 1 , which is a flow chart of the web page automation testing method provided by the embodiment of the present invention. Figure 1 As shown, the web page automated testing method provided by the present invention mainly includes the following steps (steps S101 to S103):
[0056] Step S101, when the current test case fails, the electronic device obtains the reason for the test failure;
[0057] Step S102, the electronic device determines a retry strategy based on the test failure reason, and retests the current test case at least once based on the retry strategy;
[0058] Step S103, after the current test case is successfully retried, the electronic device optimizes the test script corresponding to the current test case based on the script configuration information used in the successful retry.
[0059] In this embodiment, the reason for the test failure can be identified by analyzing the page loading log, such as page element loading timeout, page element positioning error, etc.
[0060] The test framework of this embodiment uses Playwright as a simulated browser to run UI automation testing. Playwright is an open source web page automation testing framework.
[0061] This embodiment does not stop the test of the current test case by retrying the number of times, but sets a retry strategy corresponding to the cause of the test failure, which can more effectively deal with different types of test failures and improve the reliability and stability of the test. After the retry is successful, the test script is optimized based on the successfully used script configuration information, which can eliminate inefficient or unstable script configurations, improve the efficiency and stability of script testing, and help form a more robust and efficient test script library. In addition, through the continuous optimization of test scripts, test failures and repeated work caused by script errors or inefficiencies are reduced, the need for manual intervention is reduced, and maintenance costs are further reduced.
[0062] In some optional embodiments, for step S102, as Figure 2 As shown, the following steps may be specifically included:
[0063] Step S1021, the electronic device determines a test stop condition based on the test failure reason;
[0064] Step S1022, the electronic device determines whether the test stop condition is met; if so, step S1023 is executed, otherwise, step S1024 is executed;
[0065] Step S1023, the electronic device stops testing the current test case;
[0066] Step S1024, the electronic device obtains new script configuration information;
[0067] Step S1025, the electronic device retests the current test case based on the new script configuration information;
[0068] Step S1026, if the retest result of the current test case is failure, repeat step S1021 until the test stop condition is met;
[0069] Step S1027: If the retest result of the current test case is successful, execute step S1023.
[0070] In step S103, the electronic device updates corresponding configuration information in the test script based on the script configuration information used for the successful retry, and generates an optimized test script.
[0071] It should be noted that each retry will iterate the version number of the test script. When the last retry succeeds, the iterated version number is the version number of the final optimized test script. Subsequent tests of this test case will call the test script with this version number.
[0072] Regardless of whether the retry of the current test case succeeds or fails, a complete test report will be generated, which summarizes the running status, exception details and optimization status of each version of the test script, making it convenient for testers to review.
[0073] Embodiment 2:
[0074] In actual applications, the above-mentioned embodiment 1 and the preferred embodiment can be integrated according to actual application requirements. In order to facilitate technical personnel in this field to understand how to implement the actual application and how to combine with the preferred embodiment, the above-mentioned web page automation testing method is described in detail below using the specific application scenario of page element loading timeout as an example.
[0075] For the specific implementation process, please refer to Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a specific application of a web page automation testing method according to an embodiment of the present invention. Figure 3 As shown, the method mainly includes the following steps (steps S301 to S307):
[0076] Step S301, when the current test case fails, the electronic device obtains the test failure reason as page element loading timeout;
[0077] Step S302, the electronic device determines whether the current global waiting time of the current test case reaches the maximum waiting time; if it reaches, execute step S303, otherwise execute step S304;
[0078] Step S303, the electronic device stops testing the current test case;
[0079] Step S304, the electronic device increases the current global waiting time to form a new current global waiting time;
[0080] Step S305, the electronic device retests the current test case based on the new current global waiting time;
[0081] Step S306, if the retest result of the current test case is failure, repeat step S302 until the current global waiting time reaches the maximum waiting time;
[0082] Step S307, if the retest result of the current test case is successful, the electronic device stops testing the current test case, and updates the corresponding configuration information of the test script with the current global waiting time obtained in this retry, and generates an optimized test script for the current test case.
[0083] In this embodiment, page element loading timeout means that the page element of the current test case cannot be successfully loaded within the global waiting time set in the test script. As long as the loading rate does not reach 100%, it is considered a loading timeout, indicating that the original global waiting time in the test script is set too short, resulting in page element loading timeout. Therefore, by adjusting the global waiting time to retry the current test case, it can help find a suitable global waiting time and use this time to optimize the test script.
[0084] It should be noted that each retry requires the current global waiting time to be increased, and the current global waiting time of each retry is getting closer and closer to the maximum waiting time. The current test case cannot be retried infinitely, and the maximum waiting time needs to be set, for example, 10000ms. The maximum waiting time is greater than the original global waiting time of the test script, that is, the page element loading waiting time of the current test case cannot exceed the maximum waiting time.
[0085] Furthermore, the global waiting time increased during each retry cannot reach the maximum waiting time, because once the maximum waiting time is reached, the test will be stopped.
[0086] In some optional embodiments, for step S304, the electronic device obtains a preset increase time, and determines whether the sum of the preset increase time and the current global waiting time reaches the maximum waiting time. If the sum of the preset increase time and the current global waiting time reaches the maximum waiting time, the sum of the preset increase time and the current global waiting time is reduced so that the sum of the reduced preset increase time and the current global waiting time is less than the maximum waiting time, and the sum of the reduced preset increase time and the current global waiting time is determined as the new current global waiting time.
[0087] It should be noted that the preset increase time used for each retry may be the same or different. Preferably, for different situations, the preset increase time may be gradually increased as the number of retries increases.
[0088] Embodiment three:
[0089] In actual applications, the above-mentioned embodiment 1 and the preferred embodiment can be integrated according to actual application requirements. In order to facilitate technical personnel in this field to understand how to implement the actual application and how to combine with the preferred embodiment, the above-mentioned web page automation testing method is described in detail below using the specific application scenario of page element positioning error as an example.
[0090] For the specific implementation process, please refer to Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a specific application of a web page automation testing method according to an embodiment of the present invention. Figure 4 As shown, the method mainly includes the following steps (steps S401 to S407):
[0091] Step S401, when the current test case fails, the electronic device obtains the test failure reason as a page element positioning error;
[0092] Step S402, the electronic device determines whether there is unselected candidate element location information in the candidate element location information set corresponding to the current test case; if yes, execute step S404, otherwise execute step S403;
[0093] Step S403, the electronic device stops testing the current test case;
[0094] Step S404, the electronic device selects a piece of candidate element location information from the unselected candidate element location information as current candidate element location information;
[0095] Step S405, the electronic device retests the current test case based on the current candidate element location information;
[0096] Step S406, if the retest result of the current test case is failure, repeat step S402 until there is no unselected candidate element location information in the candidate element location information set;
[0097] Step S407, if the retest result of the current test case is successful, the electronic device stops testing the current test case, and updates the corresponding configuration information of the test script with the current candidate element location information selected in this retry, and generates an optimized test script for the current test case.
[0098] In this embodiment, the candidate element positioning information includes a candidate element positioning method and a candidate positioning parameter corresponding to the candidate element positioning method. The candidate element positioning methods include but are not limited to ID positioning, class name positioning, tag name positioning, CSS selector positioning and attribute positioning. Each candidate element positioning method can be set with one or more candidate positioning parameters, which are pre-set parameters that the front-end developer may use. A page element positioning error means that the page element positioning method set in the test script is different from the page element positioning method set by the front-end developer, or the page element positioning methods are the same, but the parameters are different.
[0099] In some optional embodiments, when there are multiple unselected candidate element location information, the candidate element location information may be selected according to the preset priorities of the respective candidate element location information.
[0100] Embodiment 4:
[0101] Based on the same inventive concept, an embodiment of the present invention further provides a web page automated testing device for implementing the web page automated testing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more web page automated testing device embodiments provided below can refer to the limitations of the web page automated testing method above, and will not be repeated here.
[0102] Figure 5 FIG. 5 shows a structural block diagram of a web page automation testing device 500. Figure 5 As shown, the web page automated testing device 500 includes: a cause acquisition module 501 , a retry module 502 and an optimization module 503 .
[0103] The reason acquisition module 501 is connected to the retry module 502 and is used for the electronic device to acquire the reason for the test failure when the current test case fails;
[0104] A retry module 502, connected to the cause acquisition module 501 and the optimization module 503, respectively, is used for the electronic device to determine a retry strategy based on the cause of the test failure, and to retest the current test case at least once based on the retry strategy;
[0105] The optimization module 503 is connected to the retry module 502 and is used for optimizing the test script corresponding to the current test case based on the script configuration information used for the successful retry after the current test case is successfully retried.
[0106] In some optional embodiments, the retry module 502 includes:
[0107] A condition determination module, used for the electronic device to determine a test stop condition based on a test failure reason;
[0108] A judgment module, used for the electronic device to judge whether the test stop condition is met;
[0109] A test stop module, used for stopping the test of the current test case by the electronic device if the test stop condition is met;
[0110] A configuration information acquisition module, used for the electronic device to acquire new script configuration information if the test stop condition is not met;
[0111] A case test module, used for the electronic device to retest the current test case based on the new script configuration information;
[0112] A retry failure module is used to repeat the step of the electronic device determining whether the test stop condition is met if the retest result of the current test case is a failure, until the test stop condition is met;
[0113] The retry success module is used for the electronic device to stop the test of the current test case if the retest result of the current test case is successful.
[0114] In some optional embodiments, the condition determination module is specifically used to, if the cause of test failure is page element loading timeout, then the electronic device determines the test stop condition as the current global waiting time of the current test case reaching the maximum waiting time; if the cause of test failure is page element positioning error, then the electronic device determines the test stop condition as the absence of unselected candidate element positioning information in the candidate element positioning information set corresponding to the current test case.
[0115] Furthermore, the configuration information acquisition module includes:
[0116] A configuration determination module, configured to increase the current global waiting time by the electronic device if the current global waiting time does not reach the maximum waiting time, and determine the increased current global waiting time as new script configuration information;
[0117] The selection module is used for selecting a candidate element location information from the unselected candidate element location information as new script configuration information by the electronic device if there is unselected candidate element location information in the candidate element location information set.
[0118] Furthermore, a configuration determination module is specifically used for the electronic device to obtain a preset increase time; the electronic device determines whether the sum of the preset increase time and the current global waiting time reaches the maximum waiting time; if the sum of the preset increase time and the current global waiting time reaches the maximum waiting time, the electronic device reduces the sum of the preset increase time and the current global waiting time so that the sum of the reduced preset increase time and the current global waiting time is less than the maximum waiting time; the electronic device determines the sum of the reduced preset increase time and the current global waiting time as the new script configuration information.
[0119] In some optional embodiments, the candidate element positioning information includes a candidate element positioning method and a candidate positioning parameter corresponding to the candidate element positioning method.
[0120] In some optional embodiments, the optimization module 503 is specifically used for the electronic device to update the corresponding configuration information in the test script based on the script configuration information used for the successful retry, so as to generate an optimized test script.
[0121] It should be noted that the above-mentioned functional modules can be integrated together to form an independent unit, for example, integrated into a processing unit, or each module can exist physically separately, or two or more modules can be integrated to form an independent unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0122] Embodiment five:
[0123] Based on the same inventive concept, the embodiment of the present invention further provides an electronic device 600, the internal structure of the electronic device 600 is as follows: Figure 6 The electronic device 600 includes a memory 601 , a processor 602 and a communication bus 603 ; the memory 601 and the processor 602 are connected via the communication bus 603 .
[0124] The memory 601 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 601 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the webpage automated testing method provided in the above embodiment, etc.; the data storage area may store data involved in a webpage automated testing method provided in the above embodiment, etc.
[0125] The processor 602 may include one or more processing cores. The processor 602 executes various functions and processes data of the present invention by running or executing instructions, programs, code sets or instruction sets stored in the memory 601, calling the data stored in the memory 601. The processor 602 may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor function may also be other, and the embodiment of the present invention is not specifically limited.
[0126] The communication bus 603 may include a path to transmit information between the above components. The communication bus 603 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 603 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one double arrow is used in the diagram, but it does not mean that there is only one bus or one type of bus. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0127] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the electronic device to which the scheme of the present invention is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] Embodiment six:
[0129] In particular, according to an embodiment of the present invention, the process described in the above flowchart may be implemented as a computer software program.
[0130] The technical solution of the present invention, in essence, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, that is, the embodiment of the present invention also provides a computer-readable storage medium, which includes a number of computer programs or computer instructions, which are used to enable an electronic device (which can be a personal computer, server or network device, etc.) or a processor to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory, random access memory, disk or optical disk, etc., various media that can store program codes.
[0131] Embodiment seven:
[0132] An embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer readable medium, the computer program including a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), various functions defined in the present invention are performed.
[0133] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will be appreciated by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A web page automated testing method, characterized in that: include: When the current test case fails, the electronic device obtains the reason for the test failure; The electronic device determines a retry strategy based on the test failure cause, and retests the current test case at least once based on the retry strategy; After the current test case is successfully retried, the electronic device optimizes the test script corresponding to the current test case based on the script configuration information used in the successful retry.
2. The webpage automated testing method according to claim 1, characterized in that: The electronic device determines a retry strategy based on the test failure cause, and retests the current test case at least once based on the retry strategy, including: The electronic device determines a test stop condition based on the test failure reason; The electronic device determines whether the test stop condition is met; If the test stop condition is met, the electronic device stops the test of the current test case; If the test stop condition is not met, the electronic device obtains new script configuration information; The electronic device retests the current test case based on the new script configuration information; If the retest result of the current test case is failure, repeating the step of the electronic device determining whether the test stop condition is satisfied until the test stop condition is satisfied; If the retest result of the current test case is success, the electronic device stops testing the current test case.
3. The webpage automated testing method according to claim 2, characterized in that: The electronic device determining the test stop condition based on the test failure reason includes: If the reason for the test failure is page element loading timeout, the electronic device determines that the test stop condition is that the current global waiting time of the current test case reaches the maximum waiting time; If the reason for the test failure is a page element positioning error, the electronic device determines that the test stop condition is that there is no unselected candidate element positioning information in the candidate element positioning information set corresponding to the current test case.
4. The webpage automated testing method according to claim 3, characterized in that: If the test stop condition is not met, the electronic device acquires new script configuration information including: If the current global waiting time does not reach the maximum waiting time, the electronic device increases the current global waiting time and determines the increased current global waiting time as the new script configuration information; If there is unselected candidate element location information in the candidate element location information set, the electronic device selects a piece of candidate element location information from the unselected candidate element location information as the new script configuration information.
5. The webpage automated testing method according to claim 4, characterized in that: The electronic device increases the current global waiting time, and determines the increased current global waiting time as the new script configuration information includes: The electronic device acquires a preset increase time; The electronic device determines whether the sum of the preset increase time and the current global waiting time reaches the maximum waiting time; If the sum of the preset increase time and the current global waiting time reaches the maximum waiting time, the electronic device reduces the sum of the preset increase time and the current global waiting time so that the sum of the reduced preset increase time and the current global waiting time is less than the maximum waiting time; The electronic device determines the sum of the reduced preset increase time and the current global waiting time as the new script configuration information.
6. The webpage automated testing method according to claim 3 or 4, characterized in that: The candidate element positioning information includes a candidate element positioning method and a candidate positioning parameter corresponding to the candidate element positioning method.
7. The webpage automated testing method according to claim 1, characterized in that: The electronic device optimizing the test script corresponding to the current test case based on the script configuration information used for the successful retry includes: The electronic device updates corresponding configuration information in the test script based on the script configuration information used for a successful retry, and generates an optimized test script.
8. A web page automated testing device, characterized in that: include: Reason acquisition module, retry module and optimization module; among them, The reason acquisition module is connected to the retry module and is used for the electronic device to acquire the reason for the test failure when the current test case fails; The retry module is connected to the cause acquisition module and the optimization module respectively, and is used for the electronic device to determine a retry strategy based on the test failure cause, and retest the current test case at least once based on the retry strategy; The optimization module is connected to the retry module, and is used for optimizing the test script corresponding to the current test case based on the script configuration information used for the successful retry after the current test case is successfully retried.
9. An electronic device, characterized in that: including a processor and a memory; The memory stores a computer program or computer instruction that can be loaded by the processor and executed by the web page automated testing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or computer instructions that can be loaded by a processor and execute the web page automated testing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Automatic exception handling method, system and equipment for program testing and medium
CN116263738A
Cited By
Automatic test grading retry control method, system, equipment and medium
CN120407425A