Distributed UI automatic testing method and device, equipment, storage medium and program product
The distributed UI automation testing framework built with Playwright and Pytest combines a greedy algorithm and multi-dimensional feature fusion to dynamically adjust test resources, solving the problems of long execution time and resource waste in traditional UI automation testing in large-scale and rapid iterative development, and achieving efficient test task allocation and resource utilization.
Patent Information
- Application Number
- CN202511764331.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-02-27
AI Technical Summary
Traditional UI automated testing suffers from problems such as excessively long execution time and low resource utilization efficiency in large-scale and rapidly iterating software development. Existing distributed testing solutions cannot be dynamically scheduled, resulting in excessive load on some test machines and waste of other resources.
A distributed UI automation testing approach is adopted, and a testing framework is built using Playwright and Pytest. By combining a greedy algorithm and multi-dimensional feature fusion, the scheduling strategy is dynamically adjusted to achieve elastic scaling of test resources and optimize test task allocation.
It significantly improves testing efficiency and resource utilization, adapts to diverse testing scenarios and needs, reduces script maintenance costs, and increases test coverage.
Smart Images

Figure CN121579359A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software automatic testing, in particular to a distributed UI automatic testing method and device, computer equipment, computer readable storage medium and computer program product. BACKGROUND
[0002] With the rapid development of digital technology, software is deeply bound with people's life, and the software industry presents explosive growth. In the process of software development, testing is a key step to guarantee software quality, improve user experience and reduce maintenance cost.
[0003] In the traditional technology, software testing is mostly manual testing. Manual testing has strong adaptability, can adapt to various unexpected situations, is good at verifying complex scenarios, and has good testing effect. However, as the software scale becomes larger and the structure becomes more complex, and the development iteration speed is fast, the testing workload is increasing, and manual testing is difficult to meet the testing demand. The existing user interface (User Interface, UI) automatic testing mostly adopts single machine testing, which takes too long to execute when the test case scale is large, and is difficult to meet the demand of rapid iteration development.
[0004] Therefore, there is an urgent need for a distributed UI automatic testing scheme that can adapt to diversified testing scenarios and requirements. SUMMARY
[0005] Therefore, it is necessary to provide a distributed UI automatic testing method, device, computer equipment, computer readable storage medium and computer program product which can adapt to diversified testing scenarios and requirements in view of the above technical problems.
[0006] In a first aspect, the present application provides a distributed UI automatic testing method, which comprises:
[0007] The test information input is recognized and processed by a test framework, and the corresponding test task is determined according to the recognition result;
[0008] The test task is subjected to multi-dimensional feature extraction processing, and the different dimensional features extracted are fused to obtain fused features;
[0009] Based on a preset algorithm decision, the scheduling strategy is determined according to the prior data of the test task and the fused features;
[0010] The test resource is allocated to the test task according to the scheduling strategy, and the test is executed.
[0011] In one embodiment, the test information input is recognized and processed by a test framework, and the corresponding test task is determined according to the recognition result, comprising:
[0012] receiving test information input by a user, the test information comprising at least one of a test scenario, a task label, and a test path;
[0013] performing identification processing on the test information through the test framework, and determining a corresponding test task according to an identification result, the test task comprising at least one test case and prior data corresponding to the test case, the prior data comprising test time consumption of the test case, a test priority, and a runtime load condition.
[0014] In one of the embodiments, the test task is subjected to multi-dimensional feature extraction processing, and different dimensional features extracted are fused to obtain fused features, comprising:
[0015] The test case and the prior data corresponding to the test case are subjected to multi-dimensional feature extraction to obtain priority features, time features, and load features; the priority features are used to represent a priority of execution of the test case, the time features are used to represent time consumed by execution of the test case, and the load features are used to represent a runtime load condition of the test case;
[0016] The priority features, the time features, and the load features are subjected to fusion processing to obtain fused features.
[0017] In one of the embodiments, the scheduling strategy is determined according to the prior data of the test task and the fused features based on a preset algorithm decision, comprising:
[0018] A scheduling strategy function is constructed according to the fused features, the scheduling strategy function comprising a time consumption function, a load function, and a priority coefficient;
[0019] Based on a greedy algorithm and the prior data of the test case, weights corresponding to the time consumption function, the load function, and the priority coefficient in the strategy function are dynamically adjusted;
[0020] A corresponding scheduling strategy is determined according to a score of the strategy function;
[0021] When the load of the test case exceeds a preset threshold, the test resource is stopped from being scheduled for the test case.
[0022] In one of the embodiments, before the input test information is subjected to identification processing through the test framework, the method further comprises:
[0023] A test framework is constructed based on a Playwright tool and a Pytest; wherein the test framework comprises at least one of the following features:
[0024] Element positioning is performed using text matching and / or role selection methods;
[0025] The page is bound to a test method, used to automatically initialize the page before executing the test, and automatically close the page after ending;
[0026] The assertion method of Playwright is set to perform automatic screenshot saving;
[0027] The report plug-in is integrated to generate a visual report containing screenshots, logs, and execution time;
[0028] The test case is managed and executed by the Pytest plug-in mechanism, and the automatic cleaning and failure retry mechanism is executed.
[0029] In one of the embodiments, the method further comprises:
[0030] The related configuration of the test system is preset through the container image, and the related configuration of the test system includes a browser environment, a test framework, and a test script execution library;
[0031] The real-time load condition of the test task is obtained, and an elastic scaling strategy of the test resource is triggered according to the real-time load condition; the elastic scaling strategy is used to perform automatic expansion and contraction of the test resource; the expansion of the test resource includes increasing test nodes, and the contraction of the test resource includes reducing test nodes;
[0032] When the test task ends, the test resource is automatically released.
[0033] In a second aspect, the application further provides a distributed UI automation testing device, which comprises:
[0034] The recognition module is configured to recognize and process the input test information through a test framework, and determine a corresponding test task according to a recognition result;
[0035] The feature extraction module is configured to perform multi-dimensional feature extraction processing on the test task, and fuse different dimensional features extracted to obtain fused features;
[0036] The scheduling module is configured to determine a scheduling strategy based on a preset algorithm decision, according to prior data of the test task and the fused features;
[0037] The test module is configured to allocate test resources for the test task according to the scheduling strategy, and perform testing.
[0038] In a third aspect, the application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0039] The input test information is recognized by a test framework, and a corresponding test task is determined according to a recognition result;
[0040] Multi-dimensional feature extraction processing is performed on the test task, and different dimensional features extracted are fused to obtain fused features;
[0041] Based on a preset algorithm decision, a scheduling strategy is determined according to prior data of the test task and the fused features;
[0042] Test resources are allocated to the test task according to the scheduling strategy, and testing is performed.
[0043] In a fourth aspect, the present application further provides a computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:
[0044] The input test information is recognized by a test framework, and a corresponding test task is determined according to a recognition result;
[0045] Multi-dimensional feature extraction processing is performed on the test task, and different dimensional features extracted are fused to obtain fused features;
[0046] Based on a preset algorithm decision, a scheduling strategy is determined according to prior data of the test task and the fused features;
[0047] Test resources are allocated to the test task according to the scheduling strategy, and testing is performed.
[0048] In a fifth aspect, the present application further provides a computer program product comprising a computer program, the computer program being executed by a processor to implement the following steps:
[0049] The input test information is recognized by a test framework, and a corresponding test task is determined according to a recognition result;
[0050] Multi-dimensional feature extraction processing is performed on the test task, and different dimensional features extracted are fused to obtain fused features;
[0051] Based on a preset algorithm decision, a scheduling strategy is determined according to prior data of the test task and the fused features;
[0052] Test resources are allocated to the test task according to the scheduling strategy, and testing is performed.
[0053] The distributed UI automation test method, device, computer device, computer readable storage medium and computer program product can recognize and process the input test information through the test framework, and determine the corresponding test task according to the recognition result, so that the method can be applied to various different test scenes and test tasks, and the appropriate test case can be selected for subsequent testing. The test task is subjected to multi-dimensional feature extraction processing, and the different dimensional features extracted are fused to obtain fused features, so that the best scheduling strategy can be determined by analyzing from multiple dimensions. Based on the preset algorithm decision, the scheduling strategy is determined according to the prior data and the fused features of the test task, so that the scheduling strategy of the test task can be dynamically adjusted based on the prior data and the fused features, and the overall test efficiency is improved. The test resources are allocated to the test task according to the scheduling strategy, and the test is performed. Therefore, the diversified test scenes and requirements can be adapted, and the test efficiency and resource utilization efficiency can be significantly improved. BRIEF DESCRIPTION OF DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other related drawings can be obtained by those skilled in the art without creative labor.
[0055] Figure 1 A schematic diagram of the Playwright core function in one embodiment;
[0056] Figure 2 A structural schematic diagram of the test architecture in one embodiment;
[0057] Figure 3 A flowchart of the distributed UI automation test method in one embodiment;
[0058] Figure 4 A flowchart of the determination method of the scheduling strategy in one embodiment of the present application;
[0059] Figure 5 A flowchart of the distributed UI automation test method in another embodiment;
[0060] Figure 6 A schematic diagram of the principle of the elastic scaling process in one embodiment of the present application;
[0061] Figure 7 A schematic diagram of the overall flow of the distributed UI automation test system provided in the embodiment of the present application;
[0062] Figure 8 A structural block diagram of the distributed UI automation test device in one embodiment;
[0063] Figure 9 Figure 1 is a diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0064] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0065] It should be noted that the terms "comprising" and "having" and any variations thereof used herein are intended to cover non-exclusive inclusion. The term "a plurality of" used herein refers to two or more. The term "and / or" used herein refers to one of the options or any combination of the options.
[0066] With the development of software technology, its size and functional complexity are increasing, and any defect or performance problem may cause serious consequences in the process of user use, damage the reputation of enterprises. Therefore, how to find and solve problems in time through complete and efficient testing, and avoid bringing defects into the production environment, has become a prerequisite for ensuring software quality, reliability, security and stability.
[0067] At present, software testing is mostly manual testing. Manual testing has strong adaptability and can adapt to various unexpected situations, is good at verifying complex scenarios, and has good testing effect. However, with the increasing size and complexity of software, and the fast development iteration speed, the testing workload is increasing, and manual testing is difficult to meet the testing needs. Therefore, automated testing emerges as the times require, various testing frameworks are constantly produced, and scripts are developed using automated testing tools to automatically complete software testing by executing scripts, which can liberate manpower, improve testing efficiency and coverage. At the same time, UI automated testing can simulate user behavior from the user's perspective, can realize end-to-end testing of software, improve testing efficiency, and can automatically perform a large number of repetitive testing tasks, which can greatly shorten the testing period, cover more testing points, and can also find testing points that are not easy to find in manual testing, which can meet the needs of rapid software iteration.
[0068] With the continuous expansion of the scale of software applications and the increasing complexity of user interfaces, traditional UI automation testing faces many challenges, especially in cross-platform support, script maintenance, and flexibility. For example, Selenium is compatible with multiple browsers, has a mature community, and can be combined with testing frameworks such as JUnit to support custom test processes and is widely used in UI automation testing. However, it has poor stability, high maintenance costs, and a single-threaded execution mode that results in long execution times and low efficiency. Cypress has built-in assertions that can simplify the writing of test cases, automatic waiting without the need for manual waiting, and the ability to intercept and simulate API requests, allowing for the testing of complex scenarios. However, its cross-browser capabilities are limited and mainly support the Chrome browser.
[0069] In the face of many challenges in traditional UI automation, Playwright stands out by supporting cross-browser and cross-platform UI automation testing, while also having intelligent waiting and powerful element positioning capabilities, which can effectively reduce script maintenance costs. Its multi-threaded parallel mode can significantly improve test efficiency, and its rich API can be combined with testing frameworks to establish a more complete test process.
[0070] Traditional UI automation testing mostly uses single-machine testing, which takes too long to execute when the size of the test cases is large, making it difficult to meet the needs of rapid iterative development. In addition, single-machine resources are limited and cannot handle large concurrency, so when the test task increases, the test efficiency is low. Therefore, using multi-machine distributed testing can handle scenarios with a large number of test tasks. However, existing distributed testing solutions mostly use fixed task allocation strategies and cannot dynamically schedule according to the load of the test machines and the characteristics of the test tasks, which can easily cause some test machines to have too high a load while other resources are limited, resulting in resource waste. At the same time, existing testing frameworks have compatibility issues and lack scalability when combined with distributed scheduling, making it difficult to adapt to diverse testing scenarios and needs.
[0071] To address the problems in the related art, the present application aims to provide a distributed UI automation testing method to implement UI automation testing for a large number of complex test tasks.
[0072] To facilitate understanding of the technical solutions in various embodiments of the present application, first, the following brief description of the professional terms that may appear in various embodiments of the present application is made:
[0073] 1) Playwright is a powerful automation testing tool that supports multi-browser automation operations and can simulate various user behaviors in the browser, such as clicking, inputting, scrolling, etc., providing a rich interface for UI testing.
[0074] 2) Pytest is a simple and efficient Python testing framework that supports from simple unit testing to complex functional testing, with a rich plugin ecosystem and flexible case organization.
[0075] For example, Figure 1 As shown in the schematic diagram of the Playwright core function in one embodiment, Figure 1 It can include: browser control (starting and closing browser instances), recording function (recording test scripts and / or recording test processes), element positioning (Css selector, text selector, and Xpath selector), page operation (click, input, refresh), intelligent assertion (screenshot and intelligent waiting verification).
[0076] For example, Figure 2 As shown in the structural schematic diagram of the test architecture in one embodiment, Figure 2 Login Case represents the test case of the login function, Resource Case represents the resource case, login Method represents the login method, Resource Method represents the resource operation related method, setup teardown represents the setup and teardown, add_cleanup represents the mechanism for registering program / test exit execution cleaning operation in multiple languages, rerun represents re-run, log represents log, Utils represents test tools / utility program library, allure represents a lightweight, multi-language supported automated test report framework, login Page represents the login page, Resource Page represents the resource page, and playwright (Microsoft's open source web automation testing tool, supporting multi-browser, multi-language, used for simulating user operations and generating test scripts).
[0077] In this embodiment, the test architecture based on Playwright can quickly build a test case set and realize UI automation testing for a large number of complex test tasks.
[0078] In one example embodiment, Figure 3 As shown in the schematic diagram, a distributed UI automation testing method is provided, which is applied to the test framework in Figure 2 The following steps S301 to S304 are described. Among them:
[0079] In step S301, the test information input by the user is recognized by the test framework, and the corresponding test task is determined according to the recognition result.
[0080] It should be understood that the test information can be the description information or related information about the test task input by the user, for example, the test scene (including the used browser), the task label (such as login test, resource operation test), and the like. Alternatively, the category or name of the test case can also be directly input, so as to facilitate the test framework to select the appropriate test case.
[0081] In this embodiment, the test information input by the user can be received, and the test information includes at least one of the test scene, the task label, and the test path. The test information is recognized by the test framework, and the corresponding test task is determined according to the recognition result. The test task includes at least one test case and the prior data corresponding to the test case. The prior data includes the test time consumption of the test case, the test priority, and the load condition at the runtime.
[0082] In step S302, multi-dimensional feature extraction processing is performed on the test task, and the different dimensional features extracted are fused to obtain the fused features.
[0083] In this embodiment, multi-dimensional feature extraction is performed on the test case and the prior data corresponding to the test case to obtain the priority feature, the time feature, and the load feature. The priority feature is used to represent the priority of the test case execution, the time feature is used to represent the time consumed by the test case execution, and the load feature is used to represent the load condition at the runtime of the test case. The priority feature, the time feature, and the load feature are fused to obtain the fused features.
[0084] In step S303, based on the preset algorithm decision, the scheduling strategy is determined according to the prior data of the test task and the fused features.
[0085] For example, the scheduling strategy function is constructed according to the fused features. The scheduling strategy function includes the time consumption function, the load function, and the priority coefficient. Based on the greedy algorithm and the prior data of the test case, the weights of the time consumption function, the load function, and the priority coefficient in the strategy function are dynamically adjusted. According to the score of the strategy function, the corresponding scheduling strategy is determined. When the load of the test case exceeds the preset threshold, the test resource is stopped from being scheduled for the test case.
[0086] It should be understood that greedy algorithms combine efficiency and simplicity when handling large-scale distributed testing tasks. Therefore, by integrating greedy algorithms with multi-dimensional features, dynamic adaptive adjustments can be made based on dimensions such as execution time, task load, and task priority. After each execution, data such as execution load and task execution time are saved as prior knowledge for the next scheduling. Furthermore, different strategy weights can be manually set for different scenarios.
[0087] The formula for calculating the policy function is as follows:
[0088]
[0089] In the formula, This is a time-consuming function. For load function, This is the priority coefficient. , , These are configurable weights. This represents the score of the policy function.
[0090] For example, Figure 4 A flowchart of a method for determining a scheduling strategy in one embodiment of this application is shown below. Figure 4 As shown, the test task's multi-dimensional features are first extracted, then the features from different dimensions are fused, and the task is scheduled after a greedy algorithm decision. Simultaneously, a threshold check (whether the real-time load exceeds a preset threshold) is performed before the test task is allocated and executed. Setting a threshold check can effectively prevent the test system from crashing due to excessive load.
[0091] It should be understood that the scheduling strategy (strategy function) can also support manual weight setting in the feature fusion stage, thereby facilitating the artificial enhancement of the weight of a certain feature to meet the testing needs of different scenarios.
[0092] For example, when the goal is to minimize the execution time of a test task, the weight of execution time can be increased, and as many machines as possible can be scheduled to ensure the shortest possible time. Conversely, when the goal is to save on testing costs, the weight of load metrics can be increased, maximizing the load on each machine to achieve cost savings.
[0093] Optionally, for test tasks with different priorities, the priority weights can be adjusted to determine whether higher-priority tasks are executed first.
[0094] Optionally, weights can be dynamically generated based on historical data and real-time status before each scheduled task is executed, in order to achieve more intelligent resource allocation and load balancing.
[0095] In this embodiment, by introducing a load threshold detection mechanism, new task allocation is rejected when the test machine load reaches or is about to exceed the threshold, avoiding node overload. Manual intervention weight parameters are also supported to adapt to diversified scenarios such as shortest execution time, lowest resource cost, and highest priority task priority.
[0096] Step S304, according to the scheduling strategy, test resources are allocated to the test task, and the test is performed.
[0097] In this embodiment, after determining the scheduling strategy, test cases can be allocated to each test node for testing. During the test, the real-time load of each test node can also be monitored, so that the current scheduling strategy can be adjusted. For example, when the real-time load of a test node exceeds a preset threshold, no test task is allocated to the test node.
[0098] In the above-mentioned distributed UI automation testing method, the input test information is recognized and processed by the test framework, and the corresponding test task is determined according to the recognition result; so it can be applied to a variety of different test scenarios and test tasks, and select appropriate test cases for subsequent testing. The test task is subjected to multi-dimensional feature extraction processing, and the different dimensional features extracted are fused to obtain fused features; so that the best scheduling strategy can be determined from multiple dimensions. Based on the preset algorithm decision, the scheduling strategy is determined according to the prior data and the fused features of the test task; so that the scheduling strategy of the test task can be dynamically adjusted based on the prior data and the fused features, and the overall test efficiency is improved. According to the scheduling strategy, test resources are allocated to the test task, and the test is performed. Thus, it can adapt to diversified testing scenarios and requirements, and significantly improve the testing efficiency and resource utilization efficiency.
[0099] In another exemplary embodiment, as shown in Figure 5 , a distributed UI automation testing method is provided, which is applied to a test framework in Figure 2 for example, including the following steps S501 to S505. Among them:
[0100] Step S501, a test framework is constructed based on Playwright tool and Pytest.
[0101] In this embodiment, the test framework includes at least one of the following characteristics:
[0102] 1) Use text matching and / or role selection method for element positioning;
[0103] 2) Page is bound with test method, used to automatically initialize the page before executing the test, and automatically close the page after ending;
[0104] 3) Set the assertion method of Playwright to perform automatic screenshot saving;
[0105] 4) Integrate the report plugin to generate a visual report containing screenshots, logs, and execution time;
[0106] 5) Manage and execute test cases through Pytest, and implement automatic cleanup and failure retry mechanisms.
[0107] In this embodiment, element positioning is performed using text matching, role selection, and other methods, which has good stability and reduces script maintenance costs. By binding the page to the test method, automatic management of the page is achieved, the page is automatically initialized before test execution, and the page is automatically closed after the test is completed, improving the automation level and convenience of the test process. By rewriting the assertion method of Playwright, automatic screenshot saving is achieved during assertion, providing visual data for test result verification and simplifying the manual test process. The test case management capabilities of Pytest (including setUp / Teardown life cycle management, automatic cleanup mechanism, and failure retry mechanism) and the Allure report plugin are integrated to form a complete and extensible test case execution system. In addition, by combining Pytest test case management, execution, and powerful plugin mechanisms, automatic cleanup and failure retry mechanisms are added to build a complete and easy-to-expand UI test framework.
[0108] In step S502, the test information input is recognized and processed by the test framework, and the corresponding test task is determined based on the recognition result.
[0109] In step S503, multi-dimensional feature extraction processing is performed on the test task, and the different dimensional features extracted are fused to obtain fused features.
[0110] In step S504, based on the preset algorithm decision, the prior data and fused features of the test task are determined to determine the scheduling strategy.
[0111] In step S505, the test resource is allocated to the test task according to the scheduling strategy, and the test is executed.
[0112] For the specific implementation process and technical effects of steps S501-S505 in this embodiment, please refer to the related description of steps S301-S304 in the method embodiment shown in Figure 3
[0113] Optionally, the related configurations of the test system are also pre-configured through the container image in the above embodiments, including a browser environment, a test framework, and a test script execution library; real-time load conditions of a test task are obtained, and an elastic scaling strategy of test resources is triggered according to the real-time load conditions; the elastic scaling strategy is used to perform automatic expansion and contraction of the test resources; the expansion of the test resources includes adding test nodes, and the contraction of the test resources includes reducing test nodes; and when the test task ends, the test resources are automatically released.
[0114] In this embodiment, the basic dependencies and configurations (including a browser environment, a Playwright / Pytest framework, and a test script execution library) required for test runtime are pre-configured through the container image, so that a consistent test execution environment can be quickly copied on different computing nodes, further improving the test efficiency and the scalability of the system, and realizing an out-of-box test process.
[0115] For example, Figure 6 The principle diagram of the elastic scaling process in an embodiment of the present application is shown in FIG. 1. Figure 6 As shown in FIG. 1, based on real-time load (such as the number of use cases to be executed and the resource consumption of a single task) of a test task, an elastic scaling strategy is triggered to automatically complete the expansion (add test nodes) or contraction (reduce test nodes) of test resources, and the resources are released immediately after the task ends. Thus, the elastic scaling function of cloud computing can be used to dynamically adjust the test resources to meet business requirements, improve resource utilization, and reduce operating costs.
[0116] For example, Figure 7 The overall process diagram of the distributed UI automated test system provided by the embodiment of the present application is shown in FIG. 2. Figure 7 As shown in FIG. 2, first, a test task (corresponding to test information) is input, and after passing through a test framework layer, test cases and prior data corresponding to the test cases are obtained; then the test cases and the prior data corresponding to the test cases are transmitted to a scheduling layer, multi-dimensional feature extraction and fusion are performed using a greedy algorithm to obtain a corresponding scheduling strategy. In the process of scheduling and test execution, resource scaling control can also be performed to schedule appropriate test resources for the test task.
[0117] Optionally, the test process and the test data after the test ends can also be managed to obtain prior data (historical data) of test case execution, which can be used to adjust the weight during the next scheduling. Thus, the historical execution data (task time consumption, load fluctuation, etc.) and real-time conditions can be combined to dynamically optimize the task allocation strategy, realizing more intelligent and efficient resource allocation and load balancing.
[0118] In the above embodiments, a closed-loop process of "strategy scheduling-resource adjustment-environment deployment-task execution" is constructed to realize dynamic adaptation and efficient utilization of test resources. Through deep integration of the test framework of Playwright and Pytest, and through a multi-dimensional feature (including execution time, resource load, task priority) based on a greedy algorithm, a scheduling algorithm (strategy function) is used to realize dynamic allocation of test tasks, combined with the elastic scaling capability of the cloud platform to automatically manage test resources, and an efficient distributed UI testing system is constructed.
[0119] It should be emphasized that the use of Playwright in combination with Pytest at the test framework level enhances the flexibility of testing and enables rapid construction of test case sets. At the same time, the multi-dimensional feature fusion scheduling algorithm dynamically learns historical data such as resource consumption and execution time of test tasks, optimizes task allocation strategies, and realizes precise scheduling of test resources; and the elastic resource management scheme can dynamically adjust the scale of computing resources according to the characteristics of test tasks, avoiding resource waste and ensuring execution efficiency.
[0120] It should be understood that the test system in the above embodiments is designed from three parts of test framework integration optimization, intelligent scheduling of test tasks, and elastic scaling of test resources, which can effectively meet the UI automation testing needs in complex business scenarios and significantly improve test efficiency and resource utilization efficiency.
[0121] It should be noted that existing technologies such as Selenium have problems such as poor stability and high maintenance cost, and Cypress is limited by cross-browser capabilities. The embodiments of the present application through deep integration of Playwright and Pytest support multi-browser and cross-platform testing of Chrome, Firefox, Edge, etc., simplify the case writing (such as intelligent waiting, enhanced element positioning) and maintenance process (automatic page management, failure retry), improve compatibility, and reduce the maintenance cost of scripts.
[0122] It should be noted that in view of the problems of long execution time of traditional single-machine testing and rigid task allocation of distributed solutions, the present application uses a multi-dimensional feature fusion scheduling algorithm combined with the multi-thread parallel capability of Playwright to realize dynamic load balancing of test tasks. At the same time, through elastic scaling and threshold control, the resource utilization rate is improved and the test cost is reduced.
[0123] It should be noted that the scheduling algorithm of the multi-dimensional feature fusion of the embodiments of the present application can dynamically adjust the strategy according to historical data and real-time conditions, realize more intelligent and more actual demand task allocation, and the configurable weight strategy makes the system also flexible to adapt to different business scenarios. In addition, the assertion automatic screenshot function accurately captures the scene picture when the test fails, thereby providing an intuitive and reliable basis for problem positioning, and can generate a more perfect test report.
[0124] It should be understood that, although each step in the flowchart involved in the above embodiments is displayed in sequence according to the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in the above embodiments can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by the combination are within the scope of protection of the present application.
[0125] Based on the same inventive concept, the embodiments of the present application also provide a distributed UI automation testing device for implementing the above-mentioned distributed UI automation testing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more distributed UI automation testing device embodiments provided below can refer to the limitations of the distributed UI automation testing method in the above text, and will not be repeated here.
[0126] In one exemplary embodiment, as shown in Figure 8 A distributed UI automation testing device is provided, comprising: an identification module 801, a feature extraction module 802, a scheduling module 803 and a test module 804, wherein:
[0127] The identification module 801 is configured to perform identification processing on the input test information through the test framework, and determine the corresponding test task according to the identification result;
[0128] The feature extraction module 802 is configured to perform multi-dimensional feature extraction processing on the test task, and fuse the extracted different dimensional features to obtain fused features;
[0129] The scheduling module 803 is configured to determine a scheduling strategy based on a preset algorithm decision according to the prior data and the fused features of the test task.
[0130] The test module 804 is configured to allocate test resources for the test task according to the scheduling strategy, and perform the test.
[0131] For example, the identification module 801 is specifically configured to receive test information input by a user terminal, the test information including at least one of a test scenario, a task label, and a test path; perform identification processing on the test information through a test framework, and determine a corresponding test task according to an identification result, the test task including at least one test case and prior data corresponding to the test case, the prior data including test time consumption of the test case, a test priority, and a runtime load condition.
[0132] For example, the feature extraction module 802 is specifically configured to perform multi-dimensional feature extraction on the test case and the prior data corresponding to the test case, to obtain priority features, time features, and load features; the priority features are used to represent a priority of execution of the test case, the time features are used to represent time consumed by execution of the test case, and the load features are used to represent a runtime load condition of the test case; and the priority features, the time features, and the load features are fused to obtain fused features.
[0133] For example, the scheduling module 803 is specifically configured to construct a scheduling strategy function according to the fused features, the scheduling strategy function including a time consumption function, a load function, and a priority coefficient; dynamically adjust weights of the time consumption function, the load function, and the priority coefficient in the strategy function based on a greedy algorithm and the prior data of the test case; determine a corresponding scheduling strategy according to a score of the strategy function; and when a load of the test case exceeds a preset threshold, stop scheduling test resources for the test case.
[0134] For example, the apparatus can further include a test framework building module 805 configured to build a test framework based on a Playwright tool and a Pytest; and the test framework includes at least one of the following features:
[0135] An element is located using a text matching and / or role selection manner;
[0136] A page is bound to a test method, and the page is automatically initialized before test execution and automatically closed after test completion;
[0137] An assertion method of the Playwright is set to perform automatic screenshot saving;
[0138] A report plug-in is integrated to generate a visual report including a screenshot, a log, and an execution time;
[0139] The test cases are managed, the plugin mechanism is executed, and the automatic cleaning and failure retry mechanism are executed by Pytest.
[0140] The device can further include a preset module 806 configured to preset configurations of the test system via the container image, the configurations including a browser environment, a test framework, and a test script execution library.
[0141] The device can further include an elastic scaling module 807 configured to acquire a real-time load condition of the test task and trigger an elastic scaling strategy of the test resource according to the real-time load condition, the elastic scaling strategy being configured to perform automatic expansion and contraction of the test resource, the expansion of the test resource including adding test nodes, and the contraction of the test resource including reducing test nodes, wherein the test resource is automatically released when the test task ends.
[0142] The modules of the device can be implemented by software, hardware, or a combination thereof. The modules can be embedded in or independent of a processor of a computer device in hardware form, or stored in a memory of the computer device in software form, so as to be called and executed by the processor.
[0143] In an example embodiment, a computer device, which can be a terminal, is provided, and an internal structure diagram of the computer device can be as shown in FIG. 1. Figure 9The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to perform wired or wireless communication with external terminals, and the wireless communication can be implemented through WIFI, mobile cellular network, Near Field Communication (NFC) or other technologies. The computer program is executed by the processor to implement a distributed UI automation testing method. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or can be a key, a trackball or a touchpad arranged on the shell of the computer device, or can be an external keyboard, a touchpad or a mouse, etc.
[0144] Those skilled in the art can understand that, Figure 9 The skilled in the art can understand that,
[0145] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method steps in the above embodiments.
[0146] In one embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program is executed by a processor to implement the method steps in the above embodiments.
[0147] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by a processor to implement the method steps in the above embodiments.
[0148] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing relevant hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., and is not limited thereto. The processor involved in the embodiments provided in the present application can be a general processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., and is not limited thereto.
[0149] The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combinations of the technical features do not exist contradictory, it should be considered as the scope of the present application.
[0150] The above embodiments only express several implementation ways of the present application, and the description is specific and detailed, but it should not be understood as a limitation to the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A distributed UI automation testing method, characterized in that, The method comprises: The test information input by the test framework is identified and processed, and the corresponding test task is determined according to the identification result; The test task is subjected to multi-dimensional feature extraction processing, and the different dimensional features extracted are fused to obtain fused features; Based on the preset algorithm decision, the scheduling strategy is determined according to the prior data of the test task and the fused features; According to the scheduling strategy, the test resource is allocated to the test task, and the test is executed.
2. The method of claim 1, wherein, The test information input by the test framework is identified and processed, and the corresponding test task is determined according to the identification result, comprising: Receiving test information input by the user end, the test information comprising: at least one of test scene, task label, test path; The test information is identified and processed by the test framework, and the corresponding test task is determined according to the identification result, the test task comprising at least one test case and the prior data corresponding to the test case, the prior data comprising: test time, test priority, and runtime load.
3. The method of claim 2, wherein, The test case and the prior data corresponding to the test case are subjected to multi-dimensional feature extraction to obtain priority features, time features and load features; the priority features are used to represent the priority of the test case execution, the time features are used to represent the time required for the test case execution, and the load features are used to represent the load of the test case at runtime; The priority features, the time features and the load features are fused to obtain fused features. The scheduling strategy is determined according to the prior data of the test task and the fused features based on the preset algorithm decision, comprising:
4. The method of claim 3, wherein, According to the fused features, a scheduling strategy function is constructed, the scheduling strategy function comprising a time-consuming function, a load function and a priority coefficient; Based on the greedy algorithm and the prior data of the test case, the weights corresponding to the time-consuming function, the load function and the priority coefficient in the strategy function are dynamically adjusted; According to the score of the strategy function, the corresponding scheduling strategy is determined; When the load of the test case exceeds a preset threshold, the test resource is stopped for the test case. Before the test information input by the test framework is identified and processed, the method further comprises:
5. The method according to any one of claims 1 to 4, characterized in that, A test framework is constructed based on Playwright tool and Pytest; wherein the test framework comprises at least one of the following characteristics: Text matching and / or role selection method is used for element positioning; The page is bound with the test method, which is used to automatically initialize the page before executing the test and automatically close the page after ending; The assertion method of Playwright is set to perform automatic screenshot saving; The report plug-in is integrated to generate a visual report containing screenshots, logs and execution time; The test case is managed, the execution plug-in mechanism is executed, and the automatic cleaning and failure retry mechanism is executed by Pytest. The method further comprises:
6. The method according to any one of claims 1 to 4, characterized in that, The related configuration of the test system includes a browser environment, a test framework, and a test script execution library. Real-time load conditions of the test task are obtained, and an elastic scaling strategy of test resources is triggered according to the real-time load conditions; the elastic scaling strategy is used to perform automatic expansion and contraction of the test resources; the expansion of the test resources includes increasing test nodes, and the contraction of the test resources includes reducing test nodes; When the test task ends, the test resources are automatically released.
7. A distributed UI automation testing apparatus, characterized by, The device comprises: An identification module is configured to perform identification processing on input test information through a test framework, and determine a corresponding test task according to an identification result; A feature extraction module is configured to perform multi-dimensional feature extraction processing on the test task, and fuse different dimensional features extracted to obtain fused features; A scheduling module is configured to determine a scheduling strategy based on a preset algorithm decision, according to prior data of the test task and the fused features; A test module is configured to allocate test resources for the test task according to the scheduling strategy, and perform testing. 8.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-7. The processor executes the computer program to implement the steps of the method of any one of claims 1 to 6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.