Automated test script execution method and apparatus

CN115708071BActive Publication Date: 2026-10-27CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110961675.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-20
Publication Date
2026-10-27
Estimated Expiration
2041-08-20

AI Technical Summary

Technical Problem

[0005]本发明提供一种自动化测试脚本执行方法及装置,用以解决现有技术中无法确定合适的等待时长,降低自动化测试效率或浪费系统资源的缺陷,实现确定合适的等待时长,提高自动化测试效率,降低系统资源消耗

Benefits of technology

[0034]本发明提供的自动化测试脚本执行方法及装置,通过根据当前测试步骤对应的自动化测试脚本执行后的当前测试页面的图像分析当前页面的加载状态,在判断当前页面处于中间状态的基础上,进一步根据当前页面的加载进度动态调整下一个测试步骤对应的自动化测试脚本的等待时间窗口,从而保证自动化测试过程中合理安排下一测试步骤的等待时长,提高测试效率,降低资源消耗。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115708071B_ABST
    Figure CN115708071B_ABST
Patent Text Reader

Abstract

The application provides an automatic test script execution method and device, the method comprising: after executing an automatic test script corresponding to a current test step of an application, acquiring an image of a current page of the application; in the case that it is determined according to the image that a loading state of the current page is an intermediate state, acquiring a loading progress of the current page according to the image; according to the loading progress of the current page, acquiring a current waiting duration of a next test step of the current test step; after the current waiting duration, re-acquiring an image of a current page of the application, determining a loading state of the current page according to the re-acquired image, until the loading state of the current page is loading success, and executing an automatic test script corresponding to the next test step. The application reasonably arranges a waiting duration of a next test step, improves test efficiency, and reduces resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software automated testing technology, and in particular to an automated test script execution method and apparatus. Background Technology

[0002] In mobile application automated testing, test operations are executed according to test scripts. However, during script execution, the page loading time of the application under test can fluctuate significantly due to factors such as network conditions, terminal operating system, and the performance of the mobile application itself. This can cause the test script to interrupt test execution because it cannot correctly obtain the elements under test on the page. If a pre-set wait time is included in the script, it often results in low test efficiency due to an unreasonable pre-set wait time.

[0003] Controlling the execution time between steps in an automated test script involves two steps: first, determining the current page loading status; second, determining the waiting time for the next operation based on the current page status. Existing technologies employ two methods to determine the waiting time for the next operation. One method sets a fixed waiting time; for example, if the game is determined to be in a dynamic state, a fixed preset time, such as 5 seconds, is waited before taking screenshots and repeating the check. The other method involves cyclically checking whether the page under test has finished loading within a preset time period at a predetermined frequency; for example, if the preset time period is 1 minute and the predetermined frequency is 5 seconds, page elements are retrieved at a 5-second interval, and retrieval stops if more than 1 minute has elapsed.

[0004] The two methods mentioned above cannot determine a suitable waiting time. If the waiting time is too long, it will reduce testing efficiency. For example, if the page needs to load in 5 seconds, the waiting time is set to 1 minute. If the waiting time is too short, it will cause frequent calls to the calculation model and excessive consumption of system resources. For example, if the current environment is a weak network environment, the page loading speed will be very slow. If the interface element is searched once every 5 seconds at the preset frequency, it will waste system resources and affect performance. Summary of the Invention

[0005] This invention provides an automated test script execution method and apparatus to address the shortcomings of existing technologies that cannot determine a suitable waiting time, thereby reducing automated testing efficiency or wasting system resources. The invention aims to determine a suitable waiting time, improve automated testing efficiency, and reduce system resource consumption.

[0006] This invention provides an automated test script execution method, comprising:

[0007] After executing the automated test script corresponding to the current test step of the application, obtain an image of the current page of the application;

[0008] If the loading state of the current page is determined to be intermediate based on the image, the loading progress of the current page is obtained based on the image.

[0009] Based on the current page loading progress, obtain the current waiting time for the next test step of the current test step;

[0010] After the specified waiting time has elapsed, the image of the current page of the application is re-acquired, and the loading status of the current page is determined based on the re-acquired image. This process continues until the loading status of the current page is confirmed as successful, at which point the automated test script corresponding to the next test step is executed.

[0011] According to an automated test script execution method provided by the present invention, the step of obtaining the current waiting time of the next test step based on the loading progress of the current page includes:

[0012] Based on the total waiting time of each test step of the application before the current test step, obtain the average waiting time of all test steps before the current test step;

[0013] Based on the current page loading progress and the average waiting time, obtain the current waiting time for the next test step in the current test step.

[0014] According to an automated test script execution method provided by the present invention, the step of obtaining the current waiting time of the next test step of the current test step based on the loading progress of the current page and the average waiting time includes:

[0015] If the loading progress of the current page is greater than the first preset threshold, the difference between 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step.

[0016] If the loading progress of the current page is less than or equal to the first preset threshold, the sum of 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step.

[0017] According to an automated test script execution method provided by the present invention, when the loading state of the current page is determined to be intermediate based on the image, obtaining the loading progress of the current page based on the image includes:

[0018] If the loading state of the current page is determined to be intermediate based on the image, obtain the total number of times the loading state of the current page corresponding to the current test step is determined to be intermediate.

[0019] If the total number of attempts is less than a second preset threshold, the loading progress of the current page is obtained based on the image.

[0020] According to an automated test script execution method provided by the present invention, before obtaining the loading progress of the current page based on the image when the loading state of the current page is determined to be an intermediate state based on the image, the method further includes:

[0021] The image is classified based on the ResNet-18 algorithm to obtain the loading status of the current page.

[0022] According to an automated test script execution method provided by the present invention, the step of obtaining the loading progress of the current page based on the image includes:

[0023] The image is converted into a grayscale image, and the grayscale image is binarized to obtain the corresponding binary image.

[0024] Perform a closing operation on the binary image to obtain the connected components in the binary image after the closing operation;

[0025] The number of connected components with an area greater than a third preset threshold is counted, and this number is used as the loading progress of the current page.

[0026] The present invention also provides an automated test script execution device, comprising:

[0027] The image acquisition module is used to acquire an image of the current page of the application after executing the automated test script corresponding to the current test step of the application;

[0028] The progress acquisition module is used to acquire the loading progress of the current page based on the image when the loading state of the current page is determined to be an intermediate state based on the image.

[0029] The duration acquisition module is used to obtain the current waiting time of the next test step after the current test step based on the loading progress of the current page.

[0030] The test execution module is used to reacquire the image of the current page of the application after the current waiting time has elapsed, determine the loading status of the current page based on the reacquired image, and execute the automated test script corresponding to the next test step until the loading status of the current page is successful.

[0031] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the above-described automated test script execution methods.

[0032] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the automated test script execution method described above.

[0033] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described automated test script execution methods.

[0034] The automated test script execution method and apparatus provided by this invention analyzes the loading status of the current test page based on the image of the current test page after the execution of the automated test script corresponding to the current test step. Based on the determination that the current page is in an intermediate state, the waiting time window of the automated test script corresponding to the next test step is dynamically adjusted according to the loading progress of the current page. This ensures that the waiting time of the next test step is reasonably arranged during the automated testing process, improves testing efficiency, and reduces resource consumption. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0036] Figure 1 This is one of the flowcharts illustrating the automated test script execution method provided by the present invention;

[0037] Figure 2 This is the second flowchart of the automated test script execution method provided by the present invention;

[0038] Figure 3 This is a schematic diagram of the process for determining the execution waiting time in the automated test script execution method provided by the present invention;

[0039] Figure 4 This is a schematic diagram of the structure of the automated test script execution device provided by the present invention;

[0040] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0042] The following is combined with Figure 1 The present invention describes an automated test script execution method, comprising: step 101, after executing the automated test script corresponding to the current test step of the application, obtaining an image of the current page of the application;

[0043] Optionally, the application in this embodiment is an application on a mobile device. After the application's automated test script is parsed, the automated test script corresponding to each test step is executed sequentially according to the order of the application's test steps.

[0044] After performing a relevant action in the current test step of the application, such as a click action, obtain an image of the application's current page.

[0045] The page loading status is determined by classifying the images on the current page using a page loading status classifier. This embodiment is not limited to any particular type of page loading status classifier.

[0046] The loading status includes intermediate state S01, loading failure S02, and loading success S03. An intermediate state refers to the loading process, where part of the page content has been loaded. When loading is successful, the entire page content has been loaded. When loading fails, the page displays information related to the failure, such as the reason for the failure.

[0047] Step 102: If the loading state of the current page is determined to be an intermediate state based on the image, the loading progress of the current page is obtained based on the image.

[0048] like Figure 2 As shown, optionally, if the current page loading status is determined to be successful, the automated test script corresponding to the next test step of the current test step will continue to be executed.

[0049] If the current page loading status is determined to be a loading failure, and if this is the first time the page is being loaded, refresh the page and reload it, then check the current page status again; if this is not the first time the page is being loaded, terminate the test.

[0050] If the current page loading status is determined to be intermediate, the loading progress of the current page is determined by a page loading progress classifier. This embodiment is not limited to the types of page loading progress classifiers.

[0051] Step 103: Based on the loading progress of the current page, obtain the current waiting time for the next test step of the current test step;

[0052] Optionally, the loading progress of the current page is determined based on the content being loaded on the current page; the more content being loaded, the faster the loading progress.

[0053] Based on the current page loading progress, the waiting time for the next test step is dynamically set using a delay mechanism. Optionally, the greater the loading progress, the shorter the waiting time; the smaller the loading progress, the longer the waiting time.

[0054] Step 104: After the current waiting time has elapsed, reacquire the image of the current page of the application, determine the loading status of the current page based on the reacquired image, and continue until the loading status of the current page is successful, then execute the automated test script corresponding to the next test step.

[0055] After the current waiting time expires, re-acquire the image of the current page. Continue to check the loading status of the current page, iteratively executing steps 102 to 104 until the re-acquired image confirms that the current page has successfully loaded. At this point, execute the automated test script corresponding to the next test step.

[0056] If the page loading status is determined to be intermediate based on the current page image, a waiting time can be determined based on the current page loading progress. After the waiting time has elapsed, the current page loading status is determined again based on the current page image. If the loading status is still intermediate, the waiting time is determined again based on the current page loading progress, and the process continues until the page loading status is successfully completed before proceeding to the next test step.

[0057] This embodiment analyzes the loading status of the current test page based on the image of the current test page after the execution of the automated test script corresponding to the current test step. Based on the determination that the current page is in an intermediate state, it further dynamically adjusts the waiting time window of the automated test script corresponding to the next test step according to the loading progress of the current page. This ensures that the waiting time of the next test step is reasonably arranged during the automated testing process, improves testing efficiency, and reduces resource consumption.

[0058] Based on the above embodiments, the step of obtaining the current waiting time of the next test step according to the loading progress of the current page in this embodiment includes: obtaining the average waiting time of all test steps before the current test step based on the total waiting time of each test step of the application before the current test step;

[0059] Assume that N test steps have been executed before the current test step. Calculate the time difference between the execution times of any two adjacent test steps within those N test steps, and calculate the average waiting time t based on the time difference, i.e., t = (t0 + Δt1 + ... + Δt) / 2. n ) / N. Where t0 is set to a preset value, such as 2s, Δtn=t N -t (N-1) . t N Let t be the execution time point of the Nth test step. (N-1) Let t1 be the execution time of the (N-1)th test step, and t2 be the total waiting time of the Nth test step. Δt1 = t2 - t1, where t1 is the execution time of the first test step, t2 is the execution time of the second test step, and Δt1 is the total waiting time of the second test step.

[0060] Based on the current page loading progress and the average waiting time, obtain the current waiting time for the next test step in the current test step.

[0061] The calculated average waiting time is used as a reference waiting time. Based on the loading progress and the reference waiting time, the waiting time for the next test step in the current test step is obtained. This embodiment is not limited to the specific method for obtaining the current waiting time.

[0062] In this embodiment, the dynamic reference duration is determined based on the waiting time of the previously executed test steps, thereby making the waiting time of the next test step determined based on the reference duration more consistent with actual environmental factors.

[0063] Based on the above embodiments, the step of obtaining the current waiting time for the next test step based on the current page loading progress and the average waiting time in this embodiment includes:

[0064] If the loading progress of the current page is greater than the first preset threshold, the difference between 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step.

[0065] This embodiment uses a page load progress classifier to classify the loading progress of the current page. When the loading progress of the current page exceeds a first preset threshold, the page load progress classifier outputs a classification number T01. The classification number T01 is input into the waiting time calculator to calculate the waiting time T for the next test step, which is T = t × (1 - α%). Where t is the average waiting time. Optionally, the preset constant α is set to 30 based on test execution efficiency as the main metric, after extensive practical data analysis.

[0066] If the loading progress of the current page is less than or equal to the first preset threshold, the sum of 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step.

[0067] When the current page loading progress is less than or equal to the first preset threshold, the page loading progress classifier outputs a classification number T02. The classification number T02 is then input into the waiting time calculator to calculate the current waiting time T = t × (1 + α%) for the next test step.

[0068] This embodiment dynamically determines the current waiting time for the next test step based on the judgment result of the page loading progress classifier. The specific process is as follows: Figure 3 As shown, the waiting time can be adjusted in a timely manner according to the actual loading progress of the current page, avoiding the problems of low testing efficiency and wasted resources caused by setting a fixed waiting time.

[0069] Based on the above embodiments, in this embodiment, when the loading state of the current page is determined to be intermediate based on the image, obtaining the loading progress of the current page based on the image includes:

[0070] If the loading state of the current page is determined to be intermediate based on the image, the total number of times the loading state of the current page corresponding to the current test step is determined to be intermediate is obtained; if the total number is less than a second preset threshold, the loading progress of the current page is obtained based on the image.

[0071] To avoid excessively long page loading times, the test ends if the current page remains in an intermediate state after multiple waiting periods; otherwise, the waiting time is calculated based on the current page loading progress, and the test continues based on the calculated waiting time.

[0072] Based on the above embodiments, this embodiment further includes, before obtaining the loading progress of the current page based on the image when the loading state of the current page is determined to be an intermediate state based on the image, classifying the image based on the ResNet-18 algorithm to obtain the loading state of the current page.

[0073] To be applicable to general applications, versatility is required. This embodiment uses a deep learning algorithm to train a page loading state classifier, thereby achieving classification prediction.

[0074] There are many image-based deep learning algorithms, and practical applications are not limited to just one. Based on the PyTorch framework, five neural networks—VGG16, ResNet18, LeNet, AlexNet, and GoogleNet—were selected and compared in terms of parameter count, model size, accuracy, and prediction time, as shown in Table 1.

[0075] Table 1 Comparison of Page Loading Status Classifier Design Schemes

[0076] GoogleNet 6.8M 80.5M 92.48% 12.78 frames per second AlexNet 60M 58M 88.13% 10.95 frames per second LeNet 60K 1.57M 86.79% 13.01 frames per second VGG16 138M 526M 92.76% 12.94 frames per second ResNet18 33M 42.7M 93.76% 15.87 frames per second

[0077] Considering model training, prediction time, and accuracy, ResNet-18 was selected as the best choice for the page load state classifier. Compared to the other four algorithms, the ResNet-18 model converges faster and utilizes shortcut connections to address the model degradation problem in deep networks. It has a short prediction time of 15.87 frames per second, demonstrating excellent performance in practical applications. The model size is appropriate, allowing deployment on servers or, after model pruning, on mobile devices, while maintaining high prediction accuracy.

[0078] This embodiment uses the ResNet-18 algorithm to train the sample dataset. After convolutional layers, the output parameters are batch-normalized using a BatchNormal layer. ReLU is used as the activation function to further alleviate the gradient vanishing problem. Max pooling layers accelerate feature extraction, and five residual blocks further extract high-dimensional features from the image. Finally, the model enters an average pooling layer and a linear layer. The model is initialized using a staged normal distribution. The model achieves a prediction accuracy of 95.75% and a speed of 15.87 frames per second, meeting the functional and performance requirements of automated application testing.

[0079] The page loading status classifier in this embodiment specifically classifies the page loading status of applications. It utilizes a deep learning algorithm to train the model, thereby forming a targeted and universal determination method. This mode is applicable to determining the page loading status of all applications, and the input is simply a screenshot of the current page.

[0080] Based on the above embodiments, the step of obtaining the loading progress of the current page according to the image in this embodiment includes: converting the image into a grayscale image, performing binarization processing on the grayscale image to obtain a binary image corresponding to the image; performing a closing operation on the binary image to obtain connected components in the binary image after the closing operation; counting the number of connected components with an area greater than a third preset threshold, and using the number as the loading progress of the current page.

[0081] This embodiment enhances image connectivity through closing operations, and the area of ​​each connected component is obtained by analyzing the contour of each connected component in the image. Connected components with an area less than or equal to a third preset threshold are filtered out to reduce interference. The number of connected components with an area greater than the third preset threshold is used as the page loading progress. Optionally, based on extensive practical experience, the first preset threshold is set to 32.

[0082] When the number of connected components with an area greater than the third preset threshold is greater than the first preset threshold, it indicates that a lot of content has been loaded and the loading progress is relatively large. The page loading progress classifier outputs a classification number T01. When the number of connected components with an area greater than the third preset threshold is less than or equal to the first preset threshold, it indicates that a little content has been loaded and the loading progress is relatively small. The page loading progress classifier outputs a classification number T02.

[0083] In this embodiment, the page loading progress classifier further classifies the intermediate states of page loading. It uses an image connected component algorithm to further refine the classification of pages in the intermediate loading state, which facilitates more accurate positioning of pages in loading and thus determines the waiting time.

[0084] To verify the feasibility of this embodiment, the same application on the same test device was tested using the following three test script schemes:

[0085] 1. The script only contains the code for each test step and does not set the waiting time.

[0086] 2. The script contains code for each test step, and the waiting time between each step is set to between 5 and 10 seconds depending on the network conditions.

[0087] 3. The script contains code for each test step, and uses the dynamic setting provided in this embodiment to set the waiting time between each test step.

[0088] Each of the above scripts was tested 30 times, and the success rate and execution time of the scripts were compared to analyze the advantages and disadvantages of the three solutions.

[0089] First, comparing the success rates of the three test schemes, Table 2 shows that under poor network conditions, the script in Scheme 1, which does not include a waiting time, has very poor robustness, with an average execution success rate of only about 6.7%. The script designed using this embodiment has the strongest robustness and the highest success rate.

[0090] Table 2 compares the success rates of test script execution for the three schemes.

[0091] Success (times) 2 26 29 Failures (times) 28 4 1 Success rate 6.7% 86.7% 96.7%

[0092] The execution times of successful executions in Scheme 2 and Scheme 3 were compared. Scheme 2 was successfully executed 26 times, and the time taken for each successful script execution is shown in Table 3. The average time taken for successful script execution was 55.2 seconds.

[0093] Table 3. Time (seconds) for each successful script execution in Scheme 2

[0094] time consuming 54.25 55.66 54.23 56.54 54.87 54.49 55.46 55.27 54.85 54.52 55.83 54.27 56.88 54.02 The Nth time 15 16 17 18 19 20 21 22 23 24 25 26 time consuming 55.43 54.82 56.43 54.29 54.46 55.12 56.86 55.45 54.83 56.08 54.46 55.71

[0095] Scheme 3 was successfully executed 29 times. The time taken for each successful script execution is shown in Table 4. The average time taken for a successful script execution is 36 seconds.

[0096] Table 4. Time (seconds) for each successful script execution in Scheme 3

[0097] time consuming 34.26 37.61 35.25 37.54 36.86 35.45 36.82 37.21 34.89 35.24 34.52 36.8 37.74 35.82 The Nth time 15 16 17 18 19 20 21 22 23 24 25 26 27 28 time consuming 36.41 35.85 37.28 34.72 35.8 37.29 35.82 34.05 37.86 35.72 35.2 34.75 37.41 34.82 The Nth time 29 time consuming 36.14

[0098] By comparing the execution times of the two test schemes, it can be seen that in test scripts that only perform 15 steps, Scheme 3 saves nearly 20 seconds per test compared to Scheme 2. In actual mobile application automated testing, the number of test steps and tests will be much higher than in this experiment, thus demonstrating that this embodiment greatly improves the robustness of the test script and the test execution efficiency.

[0099] The automated test script execution device provided by the present invention is described below. The automated test script execution device described below can be referred to in correspondence with the automated test script execution method described above.

[0100] like Figure 4 As shown, the device includes an image acquisition module 401, a progress acquisition module 402, a duration acquisition module 403, and a test execution module 404, wherein:

[0101] The image acquisition module 401 is used to acquire an image of the current page of the application after executing the automated test script corresponding to the current test step of the application;

[0102] The progress acquisition module 402 is used to acquire the loading progress of the current page based on the image when the loading state of the current page is determined to be an intermediate state based on the image.

[0103] The duration acquisition module 403 is used to acquire the current waiting time of the next test step of the current test step based on the loading progress of the current page;

[0104] The test execution module 404 is used to reacquire the image of the current page of the application after the current waiting time has elapsed, determine the loading status of the current page based on the reacquired image, and execute the automated test script corresponding to the next test step until the loading status of the current page is successful.

[0105] This embodiment analyzes the loading status of the current test page based on the image of the current test page after the execution of the automated test script corresponding to the current test step. Based on the determination that the current page is in an intermediate state, it further dynamically adjusts the waiting time window of the automated test script corresponding to the next test step according to the loading progress of the current page. This ensures that the waiting time of the next test step is reasonably arranged during the automated testing process, improves testing efficiency, and reduces resource consumption.

[0106] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute an automated test script execution method. This method includes: after executing the automated test script corresponding to the current test step of the application, acquiring an image of the current page of the application; if the loading state of the current page is determined to be intermediate based on the image, acquiring the loading progress of the current page based on the image; acquiring the current waiting time for the next test step based on the loading progress of the current page; after the current waiting time has elapsed, reacquiring an image of the current page of the application, determining the loading state of the current page based on the reacquiring image, until the loading state of the current page is successfully loaded, and then executing the automated test script corresponding to the next test step.

[0107] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0108] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the automated test script execution method provided by the above methods. The method includes: after executing the automated test script corresponding to the current test step of the application, acquiring an image of the current page of the application; if the loading state of the current page is determined to be intermediate based on the image, acquiring the loading progress of the current page based on the image; acquiring the current waiting time of the next test step of the current test step based on the loading progress of the current page; after the current waiting time has elapsed, reacquiring the image of the current page of the application, determining the loading state of the current page based on the reacquiring image, until the loading state of the current page is successfully loaded, and then executing the automated test script corresponding to the next test step.

[0109] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements an automated test script execution method provided by the above methods. The method includes: after executing the automated test script corresponding to the current test step of the application, acquiring an image of the current page of the application; if the loading state of the current page is determined to be an intermediate state based on the image, acquiring the loading progress of the current page based on the image; acquiring the current waiting time for the next test step of the current test step based on the loading progress of the current page; after the current waiting time has elapsed, reacquiring an image of the current page of the application, determining the loading state of the current page based on the reacquiring image, until the loading state of the current page is successfully loaded, and then executing the automated test script corresponding to the next test step.

[0110] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0111] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for executing automated test scripts, characterized in that, include: After executing the automated test script corresponding to the current test step of the application, obtain an image of the current page of the application; If the loading state of the current page is determined to be intermediate based on the image, the loading progress of the current page is obtained based on the image. Based on the current page loading progress, obtain the current waiting time for the next test step of the current test step; After the waiting period has elapsed, the image of the current page of the application is re-acquired, and the loading status of the current page is determined based on the re-acquired image. The process continues until the loading status of the current page is successfully loaded, at which point the automated test script corresponding to the next test step is executed. The step of obtaining the current waiting time for the next test step based on the current page loading progress includes: Based on the total waiting time of each test step of the application before the current test step, obtain the average waiting time of all test steps before the current test step; Based on the current page loading progress and the average waiting time, obtain the current waiting time for the next test step of the current test step; The step of obtaining the current waiting time for the next test step based on the current page loading progress and the average waiting time includes: If the loading progress of the current page is greater than the first preset threshold, the difference between 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step. If the loading progress of the current page is less than or equal to the first preset threshold, the sum of 1 and the preset constant is multiplied by the average waiting time to obtain the current waiting time of the next test step of the current test step.

2. The automated test script execution method according to claim 1, characterized in that, When the loading state of the current page is determined to be intermediate based on the image, obtaining the loading progress of the current page based on the image includes: If the loading state of the current page is determined to be intermediate based on the image, obtain the total number of times the loading state of the current page corresponding to the current test step is determined to be intermediate. If the total number of attempts is less than a second preset threshold, the loading progress of the current page is obtained based on the image.

3. The automated test script execution method according to claim 1, characterized in that, Before obtaining the loading progress of the current page based on the image, when the loading state of the current page is determined to be an intermediate state based on the image, the method further includes: The image is classified based on the ResNet-18 algorithm to obtain the loading status of the current page.

4. The automated test script execution method according to claim 1, characterized in that, The step of obtaining the loading progress of the current page based on the image includes: The image is converted into a grayscale image, and the grayscale image is binarized to obtain the corresponding binary image. Perform a closing operation on the binary image to obtain the connected components in the binary image after the closing operation; The number of connected components with an area greater than a third preset threshold is counted, and this number is used as the loading progress of the current page.

5. An automated test script execution device, used to implement the automated test script execution method as described in any one of claims 1 to 4, characterized in that, include: The image acquisition module is used to acquire an image of the current page of the application after executing the automated test script corresponding to the current test step of the application; The progress acquisition module is used to acquire the loading progress of the current page based on the image when the loading state of the current page is determined to be an intermediate state based on the image. The duration acquisition module is used to obtain the current waiting time of the next test step after the current test step based on the loading progress of the current page. The test execution module is used to reacquire the image of the current page of the application after the current waiting time has elapsed, determine the loading status of the current page based on the reacquired image, and execute the automated test script corresponding to the next test step until the loading status of the current page is successful.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the automated test script execution method as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the automated test script execution method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the automated test script execution method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method, device and system for testing browser webpage loading time

    CN103645978A

  • Client equipment performance test method and system

    CN105426278A