A gaussian function-based user interface automation testing method and system
By adopting an automated user interface testing method based on Gaussian functions, this method solves the problems of insufficient element positioning accuracy, interaction verification robustness, and anomaly detection coverage in traditional testing methods. It achieves more accurate element positioning and interaction verification and supports UI testing on multiple platforms.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- POWERCHINA HUADONG ENG CORP LTD
- Filing Date
- 2026-02-05
- Publication Date
- 2026-06-19
Smart Images

Figure CN122240465A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software testing technology, specifically relating to an automated testing method and system for user interfaces based on Gaussian functions. Background Technology
[0002] With the explosive growth of the software industry, the design of digital software user interfaces is becoming increasingly complex, and the demand for multi-terminal adaptation is rising. Traditional user interface automated testing methods face three core problems:
[0003] 1. Insufficient element positioning accuracy: Traditional user interface automated testing is based on element coordinate positioning or attribute positioning (such as ID, XPath). When the position of interface elements is fine-tuned, the resolution is switched, or elements overlap, positioning deviations are prone to occur, which will cause the test script to fail to execute.
[0004] 2. Poor robustness of interaction verification: The verification of interaction feedback of UI elements, such as the color change of buttons after clicking and the delay of pop-up windows, relies heavily on fixed threshold judgment (such as "check if the element exists after waiting 2 seconds"), which cannot adapt to the fluctuation of interaction delay under different device performance and is prone to misjudgment.
[0005] 3. Incomplete anomaly detection coverage: Traditional methods can only detect explicit anomalies such as "element does not exist" and "operation is unresponsive". They lack a quantitative evaluation mechanism for implicit anomalies such as "element position offset is within an acceptable range but test judgment fails" and "interaction delay slightly exceeds the threshold but user does not perceive it".
[0006] In existing technologies, some solutions attempt to optimize element positioning through machine learning (such as UI testing based on image recognition), but these solutions suffer from high model training costs and sensitivity to changes in interface style. Other solutions introduce fuzz testing to improve anomaly coverage, but they cannot accurately quantify the "spatial rationality" and "interaction response smoothness" of UI elements. Summary of the Invention
[0007] The first objective of this invention is to provide an automated testing method for user interfaces based on Gaussian functions, addressing the aforementioned problems.
[0008] Therefore, the above-mentioned objective of the present invention is achieved through the following technical solution:
[0009] An automated testing method for user interfaces based on Gaussian functions includes the following steps:
[0010] S1. UI Element Feature Acquisition and Preprocessing: Capture the element features of the target UI interface, including spatial coordinate features, visual attribute features, and interactive attribute features, and standardize the coordinate data.
[0011] S2. Construction of UI element positioning model based on Gaussian function: Based on the spatial coordinate characteristics of the element, a two-dimensional Gaussian function is constructed as the positioning weight model. The weight distribution of the area to be positioned is calculated to determine the effective positioning area of the target element.
[0012] S3. Interactive response verification based on Gaussian function: Based on the standard time of element interactive response, a one-dimensional Gaussian function is constructed as a response evaluation model. The evaluation value is calculated through the actual response time to determine whether the interactive response is normal.
[0013] S4. Test Result Quantification and Anomaly Classification: Calculate the comprehensive test score based on the location weight value and response evaluation value, classify the test results according to the score, and generate anomaly reports.
[0014] While adopting the above technical solutions, the present invention may also adopt or combine the following technical solutions:
[0015] As a preferred technical solution of the present invention, step S1 specifically includes the following steps:
[0016] S101. Start the test environment and use the test tool to capture the DOM tree structure or view hierarchy data of the target UI interface and extract the basic features of the elements to be tested.
[0017] S102. Extract spatial coordinate features;
[0018] S103. Extract visual attribute features;
[0019] S104. Extract interactive attribute features;
[0020] S105. Remove invalid data;
[0021] S106. Standardize the coordinate data to convert coordinates at different resolutions into normalized coordinates relative to the screen size.
[0022] As a preferred technical solution of the present invention: in step S101, the spatial coordinate features include the coordinates of the upper left corner of the element ( ), lower right corner coordinates ( ), calculate the center coordinates of the elements and the width of the element High of elements .
[0023] As a preferred technical solution of the present invention: In step S106, the standardization processing formula is as follows:
[0024] ,
[0025] In the formula, For screen width, This is the screen height.
[0026] As a preferred embodiment of the present invention: In step S2, the formula for the two-dimensional Gaussian function is:
[0027]
[0028] In the formula, The coordinates of the location to be detected. The coordinates of the element's center are , These are the standard deviations along the x-axis and y-axis, respectively.
[0029] As a preferred technical solution of the present invention: in step S2, the effective positioning area is the area with a weight value ≥ 0.6.
[0030] As a preferred embodiment of the present invention: In step S3, the formula for the one-dimensional Gaussian function is:
[0031]
[0032] In the formula, t is the actual interactive response time. For standard response time, To allow for fluctuation standard deviation; if G(t)≥0.5, the response is considered normal; otherwise, it is considered abnormal.
[0033] As a preferred embodiment of the present invention: In step S4, the overall test score is:
[0034]
[0035] In the formula, G(x,y) is the Gaussian weight value of the positioning region.
[0036] As a preferred technical solution of the present invention: in step S4, the test result level includes excellent S≥0.8, qualified 0.6≤S<0.8, slightly abnormal 0.4≤S<0.6, and seriously abnormal S<0.4.
[0037] The second objective of this invention is to provide an automated testing system based on a Gaussian function user interface, comprising the following modules:
[0038] The feature acquisition module is used to capture and preprocess UI element features;
[0039] The Gaussian localization modeling module is used to build a two-dimensional Gaussian localization model and output accurate localization results.
[0040] The interactive verification module is used to build a one-dimensional Gaussian response evaluation model to determine whether the interactive response is normal.
[0041] The results analysis and alarm module is used to score the results and generate reports, and to determine whether the results are abnormal.
[0042] The storage and management module is used to store element feature data, Gaussian function parameters, test logs, and exception reports.
[0043] Compared with the prior art, the present invention has the following beneficial effects:
[0044] 1. Improved positioning accuracy: By modeling the spatial distribution of elements using a Gaussian function, "point positioning" is upgraded to "regional weighted positioning," solving the deviation problem of traditional coordinate positioning in scenarios with element fine-tuning and overlap, thus improving the positioning success rate;
[0045] 2. Enhanced robustness of interactive verification: Response latency is dynamically evaluated based on a Gaussian function to adapt to fluctuations in the performance of different devices, avoiding misjudgments caused by fixed thresholds and improving the accuracy of interactive verification;
[0046] 3. More scientific anomaly quantification and classification: The test results are quantitatively evaluated through comprehensive scoring, rather than the traditional binary judgment of "success / failure". This can accurately identify hidden anomalies and improve the anomaly detection coverage.
[0047] 4. High versatility: Supports UI testing on multiple platforms such as Web and mobile (iOS / Android). The Gaussian function parameters can be dynamically adjusted according to the element type (button, input box, pop-up) to adapt to different UI design styles. Attached Figure Description
[0048] Figure 1 The flowchart shows the automated testing method for user interfaces based on Gaussian functions provided by this invention.
[0049] Figure 2 This is a flowchart of step S1.
[0050] Figure 3 This is a diagram illustrating the splitting function in the system.
[0051] Figure 4 This is a schematic diagram of Gaussian localization modeling for the "login button" in the embodiment. Detailed Implementation
[0052] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0053] like Figure 1-2 As shown, an automated testing method for user interfaces based on Gaussian functions specifically includes the following steps:
[0054] S1. UI Element Feature Acquisition and Preprocessing: Capture the element features of the target UI interface, including spatial coordinate features, visual attribute features, and interactive attribute features, and standardize the coordinate data.
[0055] S101. Start the test environment and use the Selenium testing tool to capture the DOM tree structure or view hierarchy data of the target UI interface and extract the basic features of the elements to be tested.
[0056] S102. Extract spatial coordinate features: including the coordinates of the top left corner of the element ( ), lower right corner coordinates ( ), calculate the center coordinates of the elements and the width of the element High of elements ;
[0057] S103. Extract visual attribute features: including element color RGB values, transparency, and text content;
[0058] S104. Extract interactive attribute features: including clickable status and whether input is possible;
[0059] S105. Remove invalid data, such as hidden elements and non-interactive elements;
[0060] S106. Standardize the coordinate data by converting coordinates at different resolutions into normalized coordinates relative to the screen size to ensure data consistency across devices. The formula is as follows:
[0061] ,
[0062] In the formula, For screen width, This is the screen height.
[0063] S2. Construction of UI element positioning model based on Gaussian function: Based on the spatial coordinate characteristics of UI elements, a two-dimensional Gaussian function is constructed as the positioning weight model. The weight distribution of the area to be positioned is calculated to determine the effective positioning area of the target element. The effective positioning area is the area with a weight value ≥ 0.6.
[0064] The formula for the two-dimensional Gaussian function is:
[0065]
[0066] In the formula, The coordinates of the location to be detected. The coordinates of the element's center are , These are the standard deviations along the x and y axes, respectively, and the calculation rules are dynamically set based on the element's width and height. , This ensures that the Gaussian function value of the region where the element is located is in the high-weight range.
[0067] When the test script performs element localization, it calculates the weight value of each pixel in the area to be located based on the Gaussian function mentioned above. The area with a weight value greater than or equal to the preset threshold is determined as the "effective localization area of the target element", rather than the traditional "fixed coordinate point" localization. If multiple elements overlap, the element with the highest weight is selected as the target localization object by comparing the weight values of the Gaussian function of each element in the overlapping area, thus resolving the problem of element overlap localization conflict.
[0068] S3. Interaction response verification based on Gaussian function: Based on the standard time of UI element interaction response, a one-dimensional Gaussian function is constructed as a response evaluation model. The evaluation value is calculated through the actual response time to determine whether the interaction response is normal.
[0069] The formula for the one-dimensional Gaussian function is:
[0070]
[0071] In the formula, t is the actual interaction response time, such as the time it takes for a pop-up window to appear after clicking a button, or the time it takes for validation feedback after entering text; The standard response time is generally set based on historical test data or product requirements. To allow for fluctuation standard deviation, it is generally set according to the equipment performance level, such as high-performance equipment. Low-performance equipment .
[0072] After the interactive operation is performed, the actual response time t is collected in real time and substituted into the Gaussian function to calculate the response evaluation value G(t): if G(t)≥0.5, the interactive response is judged to be normal, that is, the actual delay is within the acceptable fluctuation range; if G(t)<0.5, the response is judged to be abnormal, an alarm is triggered and abnormal data is recorded.
[0073] S4. Test Result Quantification and Anomaly Classification: The comprehensive test score is calculated based on the positioning weight value and response evaluation value. The test result is classified into levels according to the score. The test result levels include excellent (S≥0.8), qualified (0.6≤S<0.8), minor anomaly (0.4≤S<0.6), and serious anomaly (S<0.4). For "minor anomalies" and "serious anomalies", an anomaly report is automatically generated, which includes the anomaly type (positioning deviation / response delay) and Gaussian function evaluation curve.
[0074] The overall test score is:
[0075]
[0076] In the formula, G(x,y) is the Gaussian weight value of the positioning region.
[0077] This invention also provides an automated testing system based on a Gaussian function user interface, such as... Figure 3 As shown, it includes the following modules:
[0078] The feature acquisition module is used to capture and preprocess UI element features, including a DOM parsing unit, a visual feature extraction unit, and a data preprocessing unit.
[0079] DOM parsing unit: By interfacing with the Selenium testing tool, it obtains the DOM tree or view hierarchy data of the UI interface;
[0080] Visual feature extraction unit: Captures visual attributes of elements such as color and transparency based on image recognition technology;
[0081] Data preprocessing unit: Standardizes coordinate data, removes invalid elements, and outputs a standardized set of element features.
[0082] The Gaussian localization modeling module is used to construct a two-dimensional Gaussian localization model and output accurate localization results. It includes a parameter calculation unit, a weight generation unit, and a conflict resolution unit.
[0083] Parameter calculation unit: Calculates the Gaussian function based on the element width and height. , and center coordinates ;
[0084] Weight generation unit: Based on the two-dimensional Gaussian function formula, it generates the weight distribution matrix of the region to be located;
[0085] Conflict resolution unit: Compares the weight values of overlapping elements, selects the element with the highest weight as the positioning target, and outputs accurate positioning results.
[0086] The interactive verification module is used to build a one-dimensional Gaussian response evaluation model and determine whether the interactive response is normal. It includes a response time acquisition unit, a Gaussian evaluation unit, and a result determination unit.
[0087] Response time acquisition unit: Records the time difference between interactive operations (clicks, inputs) and feedback through a timer;
[0088] Gaussian evaluation unit: Substitute the one-dimensional Gaussian function to calculate the response evaluation value G(t);
[0089] Result determination unit: Determines whether the response is normal based on the threshold of G(t) and outputs the verification result.
[0090] The results analysis and alarm module is used to score the results and generate reports, and to determine whether the results are abnormal. It includes a comprehensive scoring unit, an anomaly classification unit, and a report generation unit.
[0091] Comprehensive scoring unit: Calculates the overall test score based on the positioning weight value and the response evaluation value;
[0092] Anomaly Classification Unit: The test results are classified into levels based on the scores;
[0093] Report generation unit: Generates reports containing Gaussian curves and anomaly details for abnormal results, and triggers alerts via email or test management platform.
[0094] The storage and management module is used to store element feature data, Gaussian function parameters, test logs and exception reports. It supports data querying, backtracking and statistical analysis, providing data support for subsequent test optimization.
[0095] Example
[0096] 1) Feature acquisition and preprocessing
[0097] The feature acquisition module obtains the DOM tree of the login page through Selenium, such as... Figure 4 As shown, extract the spatial coordinates of the "Login Button": top left corner ( 500), bottom right corner ( ), calculate center coordinates ,Width ,high Visual attributes: RGB values (0, 122, 255); Text: "Login";
[0098] The data preprocessing unit standardizes the coordinates: screen width Screen height Normalized center coordinates: , The standard deviations in the x-axis and y-axis directions are: , .
[0099] 2) Gaussian localization modeling and localization
[0100] The parameter calculation unit of the Gaussian localization modeling module sets the parameters of the two-dimensional Gaussian function: , , .
[0101] Based on the two-dimensional Gaussian function positioning weight model formula: The weight matrix generated by the weight generation unit for the positioning area (700-1100, 450-600) is calculated, and the weight value of the central area (850-950, 500-550) is calculated to be ≥0.8.
[0102] When the test script executes the "locate login button" operation, it selects areas with weights ≥ 0.6 based on the weight matrix, accurately locating the "login button," even if the button shifts due to minor page adjustments. It can still be successfully located through weight matching.
[0103] 3) Interactive response verification
[0104] Preset standard response time for the pop-up window after clicking the "Login" button s, high-performance PC The one-dimensional Gaussian function is .
[0105] The interactive verification module executes the "click login button" operation. The response time acquisition unit records the actual delay t=1.1s. Substituting into the Gaussian function, we get G(t)≈0.98 (≥0.5), which indicates that the response is normal.
[0106] 4) Results Analysis and Reporting
[0107] Calculation of comprehensive scoring unit: G(t) = 0.98, overall score: S = 0.6 × 0.9 + 0.4 × 0.98 ≈ 0.93, the result is "excellent".
[0108] The storage and management module records test data, and the results analysis module generates test reports without any abnormal alarms.
[0109] 5) Abnormal scenario verification
[0110] If the "Login button" is offset to ( ) due to a CSS style error center coordinates The maximum Gaussian weight value of the positioning area G(x,y) = 0.3 (<0.6), and the comprehensive score S = 0.6×0.3 + 0.4×0.98 ≈ 0.57, which is judged as "minor anomaly". The report generation unit outputs a "positioning deviation" anomaly report, and it is recommended to check the button position property in the CSS style.
[0111] The technical solution of the present invention has been described in conjunction with the specific experimental procedures shown in the accompanying drawings. However, the scope of protection of the present invention is not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions resulting from such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. An automated testing method for user interfaces based on Gaussian functions, characterized in that, Includes the following steps: S1. UI Element Feature Acquisition and Preprocessing: Capture the element features of the target UI interface, including spatial coordinate features, visual attribute features, and interactive attribute features, and standardize the coordinate data. S2. Construction of UI element positioning model based on Gaussian function: Based on the spatial coordinate characteristics of the element, a two-dimensional Gaussian function is constructed as the positioning weight model. The weight distribution of the area to be positioned is calculated to determine the effective positioning area of the target element. S3. Interactive response verification based on Gaussian function: Based on the standard time of element interactive response, a one-dimensional Gaussian function is constructed as a response evaluation model. The evaluation value is calculated through the actual response time to determine whether the interactive response is normal. S4. Test Result Quantification and Anomaly Classification: Calculate the comprehensive test score based on the location weight value and response evaluation value, classify the test results according to the score, and generate anomaly reports.
2. The method according to claim 1, characterized in that: Step S1 specifically includes the following steps: S101. Start the test environment and use the test tool to capture the DOM tree structure or view hierarchy data of the target UI interface and extract the basic features of the elements to be tested. S102. Extract spatial coordinate features; S103. Extract visual attribute features; S104. Extract interactive attribute features; S105. Remove invalid data; S106. Standardize the coordinate data to convert coordinates at different resolutions into normalized coordinates relative to the screen size.
3. The method according to claim 2, characterized in that: In step S101, the spatial coordinate features include the coordinates of the top left corner of the element ( ), lower right corner coordinates ( ), calculate the center coordinates of the elements and the width of the element High of elements .
4. The method according to claim 2, characterized in that: In step S106, the standardization formula is as follows: , In the formula, For screen width, This is the screen height.
5. The method according to claim 1, characterized in that: In step S2, the formula for the two-dimensional Gaussian function is: In the formula, The coordinates of the location to be detected. The coordinates of the element's center are , These are the standard deviations along the x-axis and y-axis, respectively.
6. The method according to claim 1, characterized in that: In step S2, the effective positioning area is the area with a weight value ≥ 0.
6.
7. The method according to claim 1, characterized in that: In step S3, the formula for the one-dimensional Gaussian function is: In the formula, t is the actual interactive response time. For standard response time, To allow for fluctuation standard deviation; if G(t)≥0.5, the response is considered normal; otherwise, it is considered abnormal.
8. The method according to claim 1, characterized in that: In step S4, the overall test score is: In the formula, G(x,y) is the Gaussian weight value of the positioning region.
9. The method according to claim 1, characterized in that: In step S4, the test result levels include excellent (S≥0.8), qualified (0.6≤S<0.8), slightly abnormal (0.4≤S<0.6), and seriously abnormal (S<0.4).
10. An automated testing system based on a Gaussian function user interface, characterized in that, The system is based on the method as described in any one of claims 1-9, and includes the following modules: The feature acquisition module is used to capture and preprocess UI element features; The Gaussian localization modeling module is used to build a two-dimensional Gaussian localization model and output accurate localization results. The interactive verification module is used to build a one-dimensional Gaussian response evaluation model to determine whether the interactive response is normal. The results analysis and alarm module is used to score the results and generate reports, and to determine whether the results are abnormal. The storage and management module is used to store element feature data, Gaussian function parameters, test logs, and exception reports.