User interface automation testing method and device, computer device and storage medium
By configuring the test environment and obtaining page control information, and using preset tools to convert it into scripts, the inefficiency of existing UI automation testing tools in the context of rapid iteration in Internet projects is solved, thus achieving efficient UI automation testing.
Patent Information
- Application Number
- CN202310336237.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-03-28
AI Technical Summary
Existing UI automation testing tools are difficult to maintain in the context of rapid iteration in internet projects, resulting in low automation coverage and low testing efficiency.
Configure the test environment of the target device using the preset environment configuration tool, use the test project file to determine whether the environment meets the conditions, use the preset test service tool to obtain page control information and write it into the target text, and convert it into the target script through the implementation module to achieve automated testing.
It improves the efficiency of UI automation testing, ensures that the test environment is compatible with the current target device for obtaining page control information and script conversion, and realizes automated testing of the target device.
Smart Images

Figure CN116303077B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing, and more particularly to a method, apparatus, computer device, and storage medium for automated testing of user interfaces. Background Technology
[0002] Over the past few years, with the widespread adoption of automated testing, many companies have gradually increased the priority of UI (User Interface) automation, and many new UI automation testing tools have emerged on the market. Most UI automation tests are implemented based on Python and Selenium (a browser automation testing framework), using web crawlers to solve JavaScript rendering problems and simulate browsers for webpage loading.
[0003] Most existing UI automation implementations are based on the open-source tool Selenium, building upon existing frameworks or recording tools. The rapid iteration of internet projects makes UI automation difficult and results in low automation coverage. Large companies often experience frequent UI changes and short project delivery cycles, lacking sufficient time and manpower for UI automation, frequently encountering challenges such as maintenance difficulties. Therefore, improving the efficiency of UI automation testing has become a pressing technical problem. Summary of the Invention
[0004] This application provides a method, apparatus, computer device, and storage medium for automated user interface testing, in order to improve the efficiency of UI automated testing.
[0005] Firstly, this application provides an automated user interface testing method, which includes:
[0006] Configure the test environment of the target device based on the preset environment configuration tool, and determine whether the test environment meets the preset conditions through the test project file;
[0007] When verifying that the test environment meets the preset conditions, the target device is located through a preset test service tool, and the page control information corresponding to the target device is obtained.
[0008] Based on preset writing instructions, the page control information is written into the target text.
[0009] The target text is converted into a target script by the implementation module in the preset test environment to achieve automated testing of the target device.
[0010] Furthermore, determining whether the test environment meets preset conditions through test project files includes:
[0011] Based on the aforementioned test environment, the test project file is generated;
[0012] Connect to the target device and generate a target signature file based on the target device;
[0013] Based on the test project file and the signature file, obtain the page control information corresponding to the test project file, and convert the page control information into a test script;
[0014] The test script is used to determine whether the test environment meets the preset conditions.
[0015] Further, determining whether the test environment meets preset conditions through the test script includes:
[0016] Upon receiving the instruction to convert the test script, the test script is synchronized to the test environment through the preset environment configuration tool;
[0017] Based on the test script, generate the test signature file corresponding to the test script;
[0018] Run the test signature file in the test environment, and when the run flag is a success flag, determine that the test environment meets the preset conditions.
[0019] Furthermore, the target device is located using a preset testing service tool, and the page control information corresponding to the target device is obtained, including:
[0020] The storage path of the target device is determined using the test service tool in the test environment.
[0021] Based on the storage path, obtain the page control information of the target device.
[0022] Furthermore, based on preset writing instructions, the page control information is written into the target text, including:
[0023] Upon receiving the preset write instruction, the page control information is used to generate a user interface (UI) test file, and the UI test file is transmitted to the target device.
[0024] The command-line tool HDC_STD converts the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device, and converts the page control information into the target text.
[0025] Furthermore, the target text is converted into a target script through the implementation module in the preset test environment to achieve automated testing of the target device, including:
[0026] The UI test file is transferred to the target device;
[0027] Create a new target test script for the target device in the preset environment configuration tool, and initialize the target test script;
[0028] Based on the target test script, the target device executes the instructions corresponding to the target test script to achieve automated testing of the target device.
[0029] Furthermore, the implementation modules include: a positioning module, a user input receiving module, a UI window module, an attribute matching module, a window adjustment module, a window mode module, and / or a driver module.
[0030] Secondly, this application also provides an automated user interface testing device, the automated user interface testing device comprising:
[0031] The test environment determination module is used to configure the test environment of the target device based on the preset environment configuration tool, and to determine whether the test environment meets the preset conditions through the test project file.
[0032] The control information acquisition module is used to locate the target device through a preset test service tool and acquire the page control information corresponding to the target device when verifying that the test environment meets the preset conditions.
[0033] The write instruction module is used to write the page control information into the target text based on a preset write instruction;
[0034] The script conversion module is used to convert the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device.
[0035] Thirdly, this application also provides a computer device, the computer device including a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and, when executing the computer program, implement the user interface automated testing method as described above.
[0036] Fourthly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the user interface automated testing method described above.
[0037] This application discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes configuring a test environment for a target device based on a preset environment configuration tool, and determining whether the test environment meets preset conditions through a test project file; when verifying that the test environment meets the preset conditions, locating the target device through a preset test service tool and obtaining the page control information corresponding to the target device; writing the page control information into target text based on preset write instructions; and converting the target text into a target script through an implementation module in the preset test environment to achieve automated testing of the target device. Through the above method, this application, when determining that the test environment conforms to the current target device, obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing. Attached Figure Description
[0038] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 A schematic flowchart of an automated user interface testing method provided for the first embodiment of this application;
[0040] Figure 2 A schematic flowchart of a user interface automated testing method provided for a second embodiment of this application;
[0041] Figure 3 A schematic flowchart illustrating an automated user interface testing method provided in the third embodiment of this application;
[0042] Figure 4 A schematic flowchart of an automated user interface testing method provided for the fourth embodiment of this application;
[0043] Figure 5 A schematic flowchart of an automated user interface testing method provided in the fifth embodiment of this application;
[0044] Figure 6 A schematic flowchart of an automated user interface testing method provided in the sixth embodiment of this application;
[0045] Figure 7 A schematic block diagram of an automated user interface testing apparatus provided for embodiments of this application;
[0046] Figure 8 A schematic block diagram of the structure of a computer device provided for an embodiment of this application. Detailed Implementation
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0049] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0050] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0051] This application provides an automated user interface testing method, apparatus, computer device, and storage medium. The automated user interface testing method can be applied to a server. When the test environment is determined to be compatible with the target device, it acquires the page control information of the target device, writes the page control information into target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing. The server can be a standalone server or a server cluster.
[0052] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0053] Please see Figure 1 , Figure 1This is a schematic flowchart of a user interface automated testing method provided in the first embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0054] like Figure 1 As shown, the user interface automated testing method specifically includes steps S10 to S40.
[0055] S10. Configure the test environment of the target device based on the preset environment configuration tool, and determine whether the test environment meets the preset conditions through the test project file;
[0056] S20. When verifying that the test environment meets the preset conditions, locate the target device through a preset test service tool and obtain the page control information corresponding to the target device;
[0057] S30. Based on a preset writing instruction, write the page control information into the target text;
[0058] S40. The target text is converted into a target script by the implementation module in the preset test environment to achieve automated testing of the target device.
[0059] In a specific embodiment, due to the widespread adoption of automated testing over the past few years, many companies have gradually increased the priority of UI automation, and many new UI automation testing tools have emerged on the market. Most UI automation tests are implemented using Python and Selenium, employing web crawlers to solve JavaScript rendering issues and simulating browser loading. However, due to the unique nature of the OH system itself, the front-end pages of our business scenarios are entirely implemented using ETS (extended TypeScript) and JavaScript, differing from the traditional front-end three-piece suite implementation. Therefore, existing testing tools are incompatible with the existing automated testing frameworks of the OH system and cannot be used in our business scenario.
[0060] Specifically, this embodiment can be understood as the following technical steps:
[0061] 1. Install DevEco Studio and configure the environment;
[0062] 2. Create a new project and run the example file to verify if the environment is available;
[0063] 3. Use DevEco Testing to locate the control and Uitest to obtain detailed property information of the control;
[0064] 4. Use code to implement single text test cases into scripts.
[0065] DevEco Studio is a preset environment configuration tool that creates test project files to verify whether the current test environment is available, locates the target device, and obtains information about all controls on the page.
[0066] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes configuring a test environment for a target device based on a preset environment configuration tool, and determining whether the test environment meets preset conditions through a test project file; when verifying that the test environment meets the preset conditions, locating the target device through a preset test service tool and obtaining the page control information corresponding to the target device; writing the page control information into target text based on preset write instructions; and converting the target text into a target script through an implementation module in the preset test environment to achieve automated testing of the target device. Through the above method, this application, when determining that the test environment conforms to the current target device, obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing.
[0067] Please see Figure 2 , Figure 2 This is a schematic flowchart illustrating a user interface automated testing method provided in the second embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0068] based on Figure 1 The embodiment shown in this embodiment is as follows: Figure 2 As shown, step S10 includes steps S101 to S104.
[0069] S101. Based on the test environment, generate the test project file;
[0070] S102. Connect to the target device and generate a target signature file based on the target device;
[0071] S103. Obtain the page control information corresponding to the test project file based on the test project file and the signature file, and convert the page control information into a test script;
[0072] S104. Determine whether the test environment meets the preset conditions through the test script.
[0073] In a specific embodiment, the detailed technical solution corresponding to this embodiment is as follows:
[0074] 1. Choose a location other than drive C for installation;
[0075] 2. Select the installation option:
[0076] (1) Create a desktop shortcut;
[0077] (2) Update the path variable to add the "bin" folder to the path;
[0078] (3) Update the environment menu so that folders can be opened as project files in DevEco Studio.
[0079] 3. When you first enter DevEco Studio, choose not to import settings;
[0080] 4. Use the default option Huawei as the starting folder;
[0081] 5. Configure the npm registry and use the pre-built repository in DevEco Studio;
[0082] 6. Download and install Node.js from the specified download source online;
[0083] 7. Set the download paths for OpenHarmony SDK and HarmonyOS SDK. They cannot be the same path and must be distinguished. The download paths cannot contain Chinese characters.
[0084] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes generating a test project file based on the test environment; connecting to the target device and generating a target signature file based on the target device; obtaining page control information corresponding to the test project file based on the test project file and the signature file, and converting the page control information into a test script; and determining whether the test environment meets preset conditions through the test script. Through the above method, when it is determined that the test environment meets the current target device, this application obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script that can be executed by the target device, thereby realizing automated UI testing of the target device and improving the efficiency of automated UI testing.
[0085] Please see Figure 3 , Figure 3 This is a schematic flowchart illustrating a user interface automated testing method provided in the third embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0086] based on Figure 2 The embodiment shown in this embodiment is as follows: Figure 3 As shown, step S104 includes steps S1041 to S1043.
[0087] S1041. After receiving the instruction to convert the test script, synchronize the test script to the test environment through the preset environment configuration tool;
[0088] S1042. Based on the test script, generate a test signature file corresponding to the test script;
[0089] S1043. Run the test signature file in the test environment, and when the run flag is a success flag, determine that the test environment meets the preset conditions.
[0090] In a specific embodiment, the detailed technical solution corresponding to this embodiment is as follows:
[0091] 1. After creating an OHOS project, DevEco Studio will automatically synchronize the project;
[0092] 2. Configure automatic signing of files;
[0093] 3. Conduct trial operation via USB connection;
[0094] 4. If the device page displays "Hello World", it means the environment is ready and "Hello World" is a success indicator.
[0095] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes, after receiving an instruction to convert the test script, synchronizing the test script to the test environment through a preset environment configuration tool; generating a test signature file corresponding to the test script based on the test script; running the test signature file in the test environment; and determining that the test environment meets the preset conditions when the running flag is a success flag. Through the above method, this application, when determining that the test environment is compatible with the current target device, obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing.
[0096] Please see Figure 4 , Figure 4 This is a schematic flowchart illustrating a user interface automated testing method provided in the fourth embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0097] based on Figure 1 The embodiment shown in this embodiment is as follows: Figure 4 As shown, step S20 includes steps S201 to S202.
[0098] S201. Determine the storage path of the target device in the test environment using the test service tool;
[0099] S202. Based on the storage path, obtain the page control information of the target device.
[0100] In a specific embodiment, the detailed technical solution corresponding to this embodiment is as follows:
[0101] 1. Obtain the DevEco Testing installation package and complete the installation;
[0102] 2. Use the UiViewer utility to view control information, and click on a specific control to get detailed control information.
[0103] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes determining the storage path of the target device in the test environment using the test service tool; and obtaining the page control information of the target device based on the storage path. Through this method, when the test environment is determined to be compatible with the current target device, this application obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing.
[0104] Please see Figure 5 , Figure 5 This is a schematic flowchart illustrating a user interface automated testing method provided in the fifth embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0105] based on Figure 1 The embodiment shown in this embodiment is as follows: Figure 5 As shown, step S30 includes steps S301 to S302.
[0106] S301. Upon receiving the preset write instruction, generate a user interface (UI) test file from the page control information and transmit the UI test file to the target device;
[0107] S302. Using the command-line tool HDC_STD, the implementation module in the preset test environment converts the target text into a target script to realize the automated testing of the target device, which is then converted into the preset writing instruction, and the page control information is written into the target text.
[0108] In a specific embodiment, the detailed technical solution corresponding to this embodiment is as follows:
[0109] 1. Transfer the uitest file to the device;
[0110] 2. Use the command `hdc_std shell uitest dumpLayout>ui.txt` to write the page control information on the current device to the text file `ui.txt`;
[0111] 3. Relatively position the searched single control by using the information of the preceding and following controls.
[0112] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes, upon receiving a preset write instruction, generating a user interface (UI) test file from the page control information and transmitting the UI test file to the target device; using the command-line tool HDC_STD, converting the target text into a target script through an implementation module in the preset test environment to achieve automated testing of the target device, and writing the page control information into the target text. Through this method, when the test environment is determined to be compatible with the current target device, this application obtains the page control information of the target device, writes the page control information into the target text, and converts it into a target script executable by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing.
[0113] Please see Figure 6 , Figure 6 This is a schematic flowchart illustrating a user interface automated testing method provided in the sixth embodiment of this application. This user interface automated testing method can be applied to a server to obtain page control information of the target device when the test environment is determined to be compatible with the current target device. The page control information is then written into target text and converted into a target script executable by the target device, thereby achieving UI automated testing of the target device and improving the efficiency of UI automated testing.
[0114] based on Figure 5 The embodiment shown in this embodiment is as follows: Figure 6 As shown, step S40 includes steps S401 to S403.
[0115] S401. Transfer the UI test file to the target device;
[0116] S402. Create a target test script for the target device in the preset environment configuration tool and initialize the target test script;
[0117] S403. Based on the target test script, the target device executes the instructions corresponding to the target test script to achieve automated testing of the target device.
[0118] In a specific embodiment, the detailed technical solution corresponding to this embodiment is as follows:
[0119] 1. Push the uitest file to the device;
[0120] 2. Create a new project in DevEco Studio and write test scripts;
[0121] 3. Clear all background applications on the device to initialize the environment, and run the test script;
[0122] 4. The device performs clicks, swipes, and other operations on the page according to the code content, realizing functions such as button clicks and page switching.
[0123] Based on all the above embodiments, in this embodiment, the implementation modules include: a positioning module, a user input receiving module, a UI window module, an attribute matching module, a window adjustment module, a window mode module, and / or a driver module.
[0124] Specifically, the By module is a positioning module that provides a control feature description API for filtering controls to match / find target controls.
[0125] The API capabilities in By have the following characteristics:
[0126] 1. Supports single-attribute matching and multi-attribute combination matching.
[0127] 2. The control properties support multiple matching modes.
[0128] 3. Supports absolute and relative positioning of controls, and can use APIs such as isBefore and isAfter to define the characteristics of nearby controls for auxiliary positioning.
[0129] All APIs provided by the By class are synchronized interfaces. It is recommended to create By objects in a chain using the static constructor BY, as shown in Table 1.
[0130] Table 1
[0131]
[0132] The UiComponent module is for receiving user input. It represents a control on the UI interface and provides APIs for getting control properties, clicking the control, swiping to find, and injecting text, as detailed in Table 2.
[0133] Table 2
[0134]
[0135]
[0136] In addition, it includes the MatchPattern module (attribute matching module), the ResizeDirection module (window adjustment module), and the WindowMode module (window mode module).
[0137] This embodiment discloses a method, apparatus, computer device, and storage medium for automated user interface testing. The automated user interface testing method includes transferring the UI test file to the target device; creating a target test script for the target device in a preset environment configuration tool and initializing the target test script; and executing the instructions corresponding to the target test script through the target device to achieve automated testing of the target device. Through this method, when it is determined that the test environment matches the current target device, this application obtains the page control information of the target device, writes the page control information into target text, and converts it into a target script that can be executed by the target device, thereby achieving automated UI testing of the target device and improving the efficiency of automated UI testing.
[0138] Please see Figure 7 , Figure 7 This is a schematic block diagram of a user interface automated testing apparatus provided in an embodiment of this application. This user interface automated testing apparatus is used to perform the aforementioned user interface automated testing method. The user interface automated testing apparatus can be configured on a server.
[0139] like Figure 7 As shown, the user interface automated testing device 400 includes:
[0140] The test environment judgment module 10 is used to configure the test environment of the target device based on the preset environment configuration tool, and to determine whether the test environment meets the preset conditions through the test project file.
[0141] The control information acquisition module 20 is used to locate the target device through a preset test service tool and acquire the page control information corresponding to the target device when verifying that the test environment meets the preset conditions.
[0142] The writing instruction module 30 is used to write the page control information into the target text based on a preset writing instruction;
[0143] The script conversion module 40 is used to convert the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device.
[0144] Furthermore, the test environment determination module 10 specifically includes:
[0145] A test project file generation unit is used to generate the test project file based on the test environment;
[0146] A signature file generation unit is used to connect to the target device and generate a target signature file based on the target device;
[0147] The test script generation unit is used to obtain the page control information corresponding to the test project file based on the test project file and the signature file, and convert the page control information into a test script;
[0148] The test environment determination unit is used to determine whether the test environment meets preset conditions through the test script.
[0149] Furthermore, the test environment determination unit specifically includes:
[0150] The test script configuration subunit is used to synchronize the test script to the test environment through the preset environment configuration tool after receiving the instruction to convert the test script;
[0151] The test signature file generation subunit is used to generate a test signature file corresponding to the test script based on the test script.
[0152] The signature file verification subunit is used to run the test signature file in the test environment and determine that the test environment meets the preset conditions when the running flag is a success flag.
[0153] Furthermore, the control information acquisition module 20 specifically includes:
[0154] A storage path determination unit is used to determine the storage path of the target device in the test environment using the test service tool.
[0155] The page control information acquisition unit is used to acquire the page control information of the target device based on the storage path.
[0156] Furthermore, the write instruction module 30 specifically includes:
[0157] The UI test file generation unit is used to generate a user interface (UI) test file from the page control information when the preset write instruction is received, and to transmit the UI test file to the target device.
[0158] The write instruction unit is used to convert the target text into a target script by the implementation module in the preset test environment to realize the automated testing of the target device through the command line tool HDC_STD, and write the page control information into the target text.
[0159] Furthermore, the script conversion module 40 specifically includes:
[0160] The UI test file transmission unit is used to transmit the UI test file to the target device;
[0161] The target test script creation unit is used to create a target test script for the target device in the preset environment configuration tool and initialize the target test script.
[0162] An execution unit is used to execute the instructions corresponding to the target test script through the target device based on the target test script, thereby realizing automated testing of the target device.
[0163] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and modules can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0164] The aforementioned device can be implemented as a computer program, which can be used in, for example... Figure 8 It runs on the computer device shown.
[0165] Please see Figure 8 , Figure 8 This is a schematic block diagram illustrating the structure of a computer device according to an embodiment of this application. The computer device may be a server.
[0166] See Figure 8 The computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.
[0167] Non-volatile storage media can store operating systems and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any user interface automation test method.
[0168] The processor provides computing and control capabilities, supporting the operation of the entire computer device.
[0169] Internal memory provides an environment for the execution of computer programs stored in non-volatile storage media. When these computer programs are executed by the processor, the processor can perform any kind of user interface automation testing method.
[0170] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0171] It should be understood that the processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.
[0172] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps:
[0173] Configure the test environment of the target device based on the preset environment configuration tool, and determine whether the test environment meets the preset conditions through the test project file;
[0174] When verifying that the test environment meets the preset conditions, the target device is located through a preset test service tool, and the page control information corresponding to the target device is obtained.
[0175] Based on preset writing instructions, the page control information is written into the target text.
[0176] The target text is converted into a target script by the implementation module in the preset test environment to achieve automated testing of the target device.
[0177] In one embodiment, determining whether the test environment meets preset conditions through test project files is used to achieve the following:
[0178] Based on the aforementioned test environment, the test project file is generated;
[0179] Connect to the target device and generate a target signature file based on the target device;
[0180] Based on the test project file and the signature file, obtain the page control information corresponding to the test project file, and convert the page control information into a test script;
[0181] The test script is used to determine whether the test environment meets the preset conditions.
[0182] In one embodiment, the test script determines whether the test environment meets preset conditions, which is used to achieve:
[0183] Upon receiving the instruction to convert the test script, the test script is synchronized to the test environment through the preset environment configuration tool;
[0184] Based on the test script, generate the test signature file corresponding to the test script;
[0185] Run the test signature file in the test environment, and when the run flag is a success flag, determine that the test environment meets the preset conditions.
[0186] In one embodiment, the target device is located using a preset testing service tool, and the page control information corresponding to the target device is obtained, for the purpose of:
[0187] The storage path of the target device is determined using the test service tool in the test environment.
[0188] Based on the storage path, obtain the page control information of the target device.
[0189] In one embodiment, the page control information is written into the target text based on a preset writing instruction, to achieve the following:
[0190] Upon receiving the preset write instruction, the page control information is used to generate a user interface (UI) test file, and the UI test file is transmitted to the target device.
[0191] The command-line tool HDC_STD converts the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device, and converts the page control information into the target text.
[0192] In one embodiment, the target text is converted into a target script by an implementation module in the preset test environment to achieve automated testing of the target device, for the following purposes:
[0193] The UI test file is transferred to the target device;
[0194] Create a new target test script for the target device in the preset environment configuration tool, and initialize the target test script;
[0195] Based on the target test script, the target device executes the instructions corresponding to the target test script to achieve automated testing of the target device.
[0196] The embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions, and the processor executing the program instructions to implement any of the user interface automated testing methods provided in the embodiments of this application.
[0197] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.
[0198] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for automated testing of user interfaces, characterized in that, include: Configure the test environment of the target device based on the preset environment configuration tool, and determine whether the test environment meets the preset conditions through the test project file; When verifying that the test environment meets the preset conditions, the target device is located through a preset test service tool, and the page control information corresponding to the target device is obtained. Based on preset writing instructions, the page control information is written into the target text. The target text is converted into a target script by the implementation module in the preset test environment to achieve automated testing of the target device; The step of determining whether the test environment meets the preset conditions through the test project file includes: Based on the aforementioned test environment, the test project file is generated; Connect to the target device and generate a target signature file based on the target device; Based on the test project file and the signature file, obtain the page control information corresponding to the test project file, and convert the page control information into a test script; The test script is used to determine whether the test environment meets the preset conditions. The step of determining whether the test environment meets the preset conditions through the test script includes: Upon receiving the instruction to convert the test script, the test script is synchronized to the test environment through the preset environment configuration tool; Based on the test script, generate the test signature file corresponding to the test script; Run the test signature file in the test environment, and when the run flag is a success flag, determine that the test environment meets the preset conditions; The step of writing the page control information into the target text based on a preset writing instruction includes: Upon receiving the preset write instruction, the page control information is used to generate a user interface (UI) test file, and the UI test file is transmitted to the target device. The command-line tool HDC_STD converts the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device, and converts the page control information into the target text.
2. The user interface automated testing method according to claim 1, characterized in that, The step of locating the target device using a preset testing service tool and obtaining the page control information corresponding to the target device includes: The storage path of the target device is determined using the test service tool in the test environment. Based on the storage path, obtain the page control information of the target device.
3. The user interface automated testing method according to claim 1, characterized in that, The step of converting the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device includes: The UI test file is transferred to the target device; Create a new target test script for the target device in the preset environment configuration tool, and initialize the target test script; Based on the target test script, the target device executes the instructions corresponding to the target test script to achieve automated testing of the target device.
4. The user interface automated testing method according to any one of claims 1 to 3, characterized in that, The implementation modules include: a positioning module, a user input receiving module, a UI window module, an attribute matching module, a window adjustment module, a window mode module, and / or a driver module.
5. An automated user interface testing device, characterized in that, The automated user interface testing device includes: The test environment determination module is used to configure the test environment of the target device based on the preset environment configuration tool, and to determine whether the test environment meets the preset conditions through the test project file. The control information acquisition module is used to locate the target device through a preset test service tool and acquire the page control information corresponding to the target device when verifying that the test environment meets the preset conditions. The write instruction module is used to write the page control information into the target text based on a preset write instruction; The script conversion module is used to convert the target text into a target script through the implementation module in the preset test environment to achieve automated testing of the target device; The test environment determination module specifically includes: A test project file generation unit is used to generate the test project file based on the test environment; A signature file generation unit is used to connect to the target device and generate a target signature file based on the target device; The test script generation unit is used to obtain the page control information corresponding to the test project file based on the test project file and the signature file, and convert the page control information into a test script; A test environment determination unit is used to determine whether the test environment meets preset conditions through the test script; The test environment determination unit specifically includes: The test script configuration subunit is used to synchronize the test script to the test environment through the preset environment configuration tool after receiving the instruction to convert the test script; The test signature file generation subunit is used to generate a test signature file corresponding to the test script based on the test script. The signature file verification subunit is used to run the test signature file in the test environment and determine that the test environment meets the preset conditions when the running flag is a success flag. Specifically, the write instruction module includes: The UI test file generation unit is used to generate a user interface (UI) test file from the page control information when the preset write instruction is received, and to transmit the UI test file to the target device. The write instruction unit is used to convert the target text into a target script by the implementation module in the preset test environment to realize the automated testing of the target device through the command line tool HDC_STD, and write the page control information into the target text.
6. A computer device, characterized in that, The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and, in executing the computer program, implement the user interface automated testing method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to implement the user interface automated testing method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Automatic click method and system based on coordinates and automatic test framework
CN115408288A
Automatic test system and method, electronic equipment and storage medium
CN115576817A