A method for UI automation testing

By simulating user operation behavior and setting parameters for icon drag and drop, UI automated test scripts are generated, which solves the problem of low testing efficiency in the existing technology, and realizes efficient automated testing, reducing programming complexity and dependence on browser driver software.

CN113946519BActive Publication Date: 2024-11-05四川启睿克科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111328076.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2024-11-05
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

The existing UI automation testing is inefficient, requires cumbersome editing scripts and error-prone, and requires additional browser driver software to be installed.

Method used

By simulating user operation behavior, generating user operation information data, analyzing and running mouse and keyboard operations, using icon drag and drop and setting parameters to generate test scripts, realizing automated UI testing.

Benefits of technology

It improves the efficiency of UI automation testing, simplifies the script generation process, is close to the actual operation scenarios of users, and reduces the dependence of programming languages ​​and the installation needs of browser driver software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113946519B_ABST
    Figure CN113946519B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for UI automated testing. By dividing the operation actions of a UI tester into four categories: mouse operation, keyboard operation, result comparison operation, and time waiting operation, and combining the method of dragging and positioning icons, a test case script can be quickly generated, and then the mouse and keyboard are called to complete the test steps, which also meets the purpose of the test being close to the user's actual operation scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of UI automation technology, and in particular to a UI automation testing method. Background Art

[0002] Currently, most UI automation tests are mainly implemented based on selenium. The script calls the selenium interface function to pass commands to the driver software, and the driver software returns the results after executing the commands. The script automation is inefficient and needs to locate and obtain the identification mark of the operation object in the browser first. The operation is cumbersome and error-prone, and requires additional programming languages ​​to write scripts, which is time-consuming and labor-intensive, and requires the additional installation of specified browser driver software. Summary of the invention

[0003] The purpose of the present invention is to provide a method for UI automated testing in order to solve the above problems. The present invention simulates user operation behavior, generates user operation information data and saves it in a file after clicking and dragging the tool icon to the target position and setting it. The user operation information data is parsed and run one by one during runtime, and the user's mouse and keyboard operations are simulated, and the expected picture and the actual result picture are compared. The test script is generated by clicking the tool button, generating the corresponding tool icon, dragging the tool icon to the target position, setting the operation action and parameters, and saving to obtain the target coordinates, operation type, and operation parameters on the screen, solving the problem of low efficiency caused by editing scripts in the prior art for UI automated testing.

[0004] The present invention achieves the above-mentioned purpose through the following technical solutions:

[0005] A method for UI automation testing includes the following steps:

[0006] Click the function button in the tool module;

[0007] The test tool generates corresponding function icons;

[0008] Drag the icon to the target location and set the parameters;

[0009] The test tool parses the target location and saves it with parameter information into a cache or file to generate a single test step information;

[0010] Repeat the above operations to generate a test case script;

[0011] Select the generated test case script and click Run;

[0012] The test tool will read the test step information from the script;

[0013] After parsing, the corresponding function is executed, and the mouse, keyboard, image comparison, and waiting operations are called to complete the automated UI test.

[0014] A further solution is to select a mouse function button, the test tool generates a mouse function icon, drag the icon to the target position with the mouse, select the desired mouse button, select the operation action type, and enter the operation parameters; the test tool generates a single test step information, which includes the function type, target coordinates, mouse button, operation type, and parameters.

[0015] A further solution is to select the input function button, the test tool generates an input function icon, drag the icon to the target position with the mouse, select the desired input type, input parameters, and the test tool generates a single test step, which includes the function type, target coordinates, input type, and input parameter value.

[0016] A further solution is to select the image comparison function button, the test tool generates a non-completely transparent layer on the screen desktop, click the mouse on the layer to select the comparison area, and then upload the expected image by locally uploading or copying and pasting the screenshot, set the timeout time, and the test tool generates a single test step, which includes the function type, comparison area coordinates, expected image, and timeout time.

[0017] A further solution is to select the time waiting function button, the test tool generates a time waiting icon, set the waiting time, and the test tool generates a single test step information, which includes the function type and the waiting time value.

[0018] A further solution is that the testing method further includes:

[0019] Select the generated test script and click Run;

[0020] The test tool reads the script information in the order of the test sequence, parses out the test step set, and executes the test steps in sequence.

[0021] A further solution is that when the function type of the test step is mouse operation, the mouse method library is called, the mouse is moved to the target position according to the target coordinates, the function is called according to the mouse button object, the parameters are passed in, and the mouse operation on the screen is completed.

[0022] A further solution is that when the function type of the test step is an input operation, the mouse is called to obtain focus at the target coordinates, the keyboard method library is called, the function is called according to the input type, parameters are passed in, and the keyboard input operation is completed.

[0023] A further solution is that when the function type of the test step is time waiting, a sleep waiting operation is performed.

[0024] A further solution is that when the function type of the test step is a picture comparison operation, according to the coordinates of the comparison area, the screenshot function is called to take a screenshot in the area, and then the picture comparison function is called to calculate the similarity between the screenshot and the expected picture, and the comparison result is returned. The beneficial effects of the present invention in the test are:

[0025] A UI automation testing method of the present invention divides the operation actions of the UI tester into four categories: mouse operation, keyboard operation, result comparison operation, and time waiting operation. Combined with the icon dragging and positioning method, a test case script can be quickly generated, and then the mouse and keyboard are called to complete the test steps, which also meets the purpose of the test being close to the user's actual operation scenario. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 A flowchart of a method for implementing UI automation testing by dragging icons according to an embodiment of the present invention;

[0028] Figure 2 A flowchart of a method for generating a UI test script by dragging an icon to locate the UI according to an embodiment of the present invention;

[0029] Figure 3 A flowchart of a method for running a UI test script according to an embodiment of the present invention;

[0030] Figure 4 A schematic diagram of effective points for icon positioning according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.

[0032] In any embodiment, if Figure 1-4 As shown, a UI automation testing method of the present invention includes:

[0033] The tester clicks the function button in the tool module;

[0034] The test tool generates corresponding function icons;

[0035] The tester drags the mobile icon to the target location and sets the parameters;

[0036] The test tool parses the target location and saves it with parameter information into a cache or file to generate a single test step information;

[0037] Repeat the above operations to generate a test case script;

[0038] The tester selects the generated test case script and clicks Run;

[0039] The test tool will read the test step information from the script;

[0040] After parsing, the corresponding function is executed, and operations such as mouse, keyboard, image comparison, and waiting are called to complete the automated UI test.

[0041] like Figure 2 The method flow of generating a UI test script by dragging an icon to locate the UI test script according to an embodiment of the present invention is shown, and may include the following specific execution steps:

[0042] Optionally, the tester selects a mouse function button, the test tool generates a mouse function icon, the tester drags the icon to the target location with the mouse, selects a desired mouse button, such as the left mouse button, the right mouse button, the pulley, etc., selects the operation action type, such as click, press, release, move, etc., and inputs operation parameters, such as the number of clicks, the sliding distance, the moving coordinate value, etc. The test tool generates a single test step information, which includes available information such as function type, target coordinates, mouse button, operation type, parameters, etc.

[0043] Optionally, the tester selects the input function button, the test tool generates an input function icon, the tester drags the icon to the target position with the mouse, selects the desired input type, such as character input, keyboard keys, etc., and inputs parameters, such as the string to be input, keyboard key identification characters, etc. The test tool generates a single test step, which contains available information such as function type, target coordinates, input type, input parameter values, etc.

[0044] Optionally, the tester selects the image comparison function button, and the test tool generates a non-completely transparent layer on the screen desktop. The tester clicks the mouse on the layer to select the comparison area, and then uploads the expected image by locally uploading or copying and pasting the screenshot, sets the timeout period, and the test tool generates a single test step, which includes available information such as function type, comparison area coordinates, expected image, timeout period, etc.

[0045] Optionally, the tester selects the time waiting function button, the test tool generates a time waiting icon, sets the waiting time, and the test tool generates a single test step information, which includes available information such as function type and waiting time value.

[0046] like Figure 3 The method flow of running a UI test script according to an embodiment of the present invention is shown, which may include the following execution steps:

[0047] The tester selects the test script generated in the above steps and clicks Run;

[0048] The test tool reads the script information in the order of the test sequence, parses the test step set, and executes the test steps in sequence;

[0049] Optionally, when the function type of the test step is mouse operation, the mouse method library is called, the mouse is moved to the target position according to the target coordinates, the function is called according to the mouse button object, parameters are passed in, and the mouse operation on the screen is completed.

[0050] Optionally, when the function type of the test step is an input operation, the mouse is called to obtain focus at the target coordinates, the keyboard method library is called, the function is called according to the input type, parameters are passed in, and the keyboard input operation is completed.

[0051] Optionally, when the function type of the test step is time waiting, a sleep waiting operation is performed.

[0052] Optionally, when the function type of the test step is a picture comparison operation, the screenshot function is called to take a screenshot in the area according to the comparison area coordinates, and then the picture comparison function is called to calculate the similarity between the screenshot and the expected picture, and the comparison result is returned to implement the result judgment in the test.

[0053] In a specific embodiment, Figure 1-4 As shown, a UI automation testing method of the present invention comprises the following steps:

[0054] The tester selects and clicks a function button from the tool module to generate a corresponding function icon. Because the icon is an area range and cannot effectively express the target position (point), a valid point is selected on the icon, and the coordinate position of the valid point relative to the screen is used as the target position.

[0055] Formula 1: Target position coordinates (x, y) = coordinates of the icon on the screen (x1, y1) + coordinates of the valid point on the icon (x2, y2)

[0056] Drag the function icon to the desired target location and set the function parameters. The test tool will collect and save information such as the target location coordinates and function parameters and generate a single test step.

[0057] Repeat the above steps several times to obtain a set of test steps, generate a complete test case, and save it to a file to form a test script for a single test case.

[0058] The mouse function button is used to simulate the action information setting of the user operating each mouse button. After clicking the button, an icon is generated. Drag the icon to the target position and set the button object to the left mouse button, right mouse button or pulley; set the operation type to click, move, drag, and slide; set the number of clicks, moving direction and distance, dragging direction and distance, and sliding direction and distance; after the settings are completed, the mouse operation steps will be generated.

[0059] The input function button is used to simulate the action information setting of user operation of keyboard and character input. Click the button to generate an icon. Drag the icon to the target position, set the input type to character input or hotkey input; set the input parameters or hotkey name; generate the user input operation steps after the settings are completed.

[0060] The comparison function button is used by testers to compare the expected results and actual results on the UI. Click this button to enter the comparison area selection mode. After selecting the comparison area by clicking and moving the mouse, upload the expected result image. You can upload it through a local image or obtain it from the clipboard. Set the timeout period. After completion, generate the result comparison test steps.

[0061] The time waiting function button is used to simulate the user's non-operation waiting time setting. Click it to set the waiting time, and generate the waiting test steps after completion.

[0062] Execution of mouse operation steps: parse the mouse operation steps obtained in the above steps, call the corresponding function according to the operation object and operation type in the data, pass in the parameter value in the data, execute the function, call the mouse to complete the action, and simulate the tester's single mouse operation actions such as clicking, moving, dragging, sliding, etc. at the target position.

[0063] Execution of input operation steps: Get the focus according to the coordinate information in the test step, and then call the function according to the input type and parameters to implement character input and keyboard key pressing and releasing operations, thus simulating the tester's input operation.

[0064] Comparison operation steps: Loop local capture of pictures based on the coordinate information of the comparison area, and compare and calculate the similarity with the expected picture. If the expected similarity is reached or above within the specified time, the actual result is judged to be consistent with the expected result, otherwise it is inconsistent. Realize the operation action of the simulation tester to compare the results

[0065] Time waiting operation step execution: Wait according to the waiting time parameter in the step. After the time is up, continue to execute the script to realize the waiting operation action of the simulated tester.

[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims. It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present invention will not further explain various possible combinations. In addition, the various different embodiments of the present invention can also be combined arbitrarily, as long as they do not violate the concept of the present invention, they should also be regarded as the contents disclosed by the present invention.

Claims

1. A method of UI automation testing, It is characterized in that The following steps are involved: Click the function button in the tool module; The test tool generates corresponding function icons; Drag the icon to the target location and set the parameters; select the mouse function button, the test tool generates the mouse function icon, drag the icon to the target location with the mouse, select the desired mouse button, select the operation action type, and enter the operation parameters; the test tool generates a single test step information, which includes the function type, target coordinates, mouse button, operation type, and parameters; The test tool parses the target location and saves it with parameter information into a cache or file to generate a single test step information; Repeat the above operations to generate a test case script; Select the generated test case script and click Run; The test tool will read the test step information from the script; Select the time waiting function button, the test tool generates a time waiting icon, set the waiting time, and the test tool generates a single test step information, which includes the function type and waiting time value; select the input function button, the test tool generates an input function icon, drag the icon to the target position with the mouse, select the desired input type, input parameters, and the test tool generates a single test step, which includes the function type, target coordinates, input type, and input parameter values; select the picture comparison function button, the test tool generates a non-completely transparent layer on the screen desktop, click the mouse on the layer to select the comparison area, and then upload the expected picture by locally uploading or copying and pasting the screenshot, set the timeout time, and the test tool generates a single test step, which includes the function type, comparison area coordinates, expected picture, and timeout time; After parsing, the corresponding function is executed, and the mouse, keyboard, image comparison, and waiting operations are called to complete the automated UI test.

2. A UI automation testing method as claimed in claim 1, It is characterized in that The testing methods also include: Select the generated test script and click Run; The test tool reads the script information in the order of the test sequence, parses out the test step set, and executes the test steps in sequence.

3. A UI automation testing method as claimed in claim 1, It is characterized in that When the function type of the test step is mouse operation, the mouse method library is called, the mouse is moved to the target position according to the target coordinates, the function is called according to the mouse button object, the parameters are passed in, and the mouse operation on the screen is completed.

4. A UI automation testing method as claimed in claim 1, It is characterized in that When the function type of the test step is input operation, the mouse is called to obtain focus at the target coordinates, the keyboard method library is called, the function is called according to the input type, the parameters are passed in, and the keyboard input operation is completed.

5. A UI automation testing method as claimed in claim 1, It is characterized in that When the function type of the test step is time waiting, the sleep waiting operation is performed.

6. A UI automation testing method as claimed in claim 1, It is characterized in that When the function type of the test step is a picture comparison operation, the screenshot function is called to take a screenshot in the area according to the coordinates of the comparison area, and then the picture comparison function is called to calculate the similarity between the screenshot and the expected picture, and the comparison result is returned to realize the result judgment in the test.