Automated testing method and device based on AutoHotKeyd and electronic equipment
Through the automated testing method based on AutoHotKey, users write automated operation steps to generate script files, parse and execute these instructions to control the testing software to complete automated operation steps, solving the problem of inefficient product testing in automation factories, realizing automated testing, improving efficiency and saving costs.
Patent Information
- Application Number
- CN202411741018.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-28
AI Technical Summary
In an automation factory, product testing is still in the manual operation stage, which is inefficient and error-prone. How to achieve automated testing of products to improve efficiency is an urgent problem to be solved at present.
Using the automated testing method based on AutoHotKey, a script file is generated by the user writing automated operation steps, parsing the script file to obtain automated operation instructions recognized by AutoHotKey, and executing these instructions to control the test software to complete the automated operation steps.
It realizes automation of product testing, saves labor, improves product testing efficiency, and reduces manual operation costs.
Smart Images

Figure CN119718915A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of product testing, and in particular relates to an automatic testing method, device and electronic equipment based on AutoHotKeyd. Background Art
[0002] After the production of products in automated factories is completed, they will face the problem of product index testing. In some industries, this process is still in the manual operation stage, which is inefficient and prone to errors. How to automatically complete product testing is an urgent problem to be solved in the current scenario. In the product testing scenario, testers often have to manually operate the test software to test the product. The testing process is cumbersome and complicated, and the test station and the assembly station are often not on the same assembly line, which invisibly increases the time cost. Summary of the invention
[0003] In order to solve the above problems, the present invention provides an automatic testing method, device and electronic equipment based on AutoHotKeyd, which can control the testing software to perform automatic testing on the product, save labor and improve the product testing efficiency.
[0004] In a first aspect, the present invention provides an automated testing method based on AutoHotKeyd, comprising:
[0005] Generate a script file based on the automated operation steps written by the user, wherein the automated operation steps are the steps that need to be executed when the target test software performs product testing;
[0006] Parsing the script file to obtain an automated operation instruction recognizable by AutoHotKey, and storing the automated operation instruction in a pre-established automated operation execution list; wherein the automated operation instruction corresponds to the automated operation step;
[0007] Execute the automation operation instructions in the automation operation execution list, and call the execution function corresponding to the automation operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps.
[0008] In an optional implementation, the script file is a text file based on the Json data exchange format.
[0009] In an optional implementation, the generating of the script file based on the automated operation steps written by the user includes:
[0010] Acquire the automated operation steps input by the user, and generate a Json string based on the Json data exchange format according to the automated operation steps and a pre-built command template library; wherein the Json string includes parameter information of the automated operation steps;
[0011] In response to generating a script file, the script file is generated according to all the generated Json strings, wherein the script file is an executable automation script file.
[0012] In an optional implementation, the parameter information of the automated operation step includes name information, operation parameter information, operation time information and descriptive text information.
[0013] In an optional implementation, the automated operation instructions include opening the target test software, closing the target test software, clicking on a picture in the target test software, and clicking on coordinates in the target test software.
[0014] In an optional implementation, parsing the script file to obtain an automated operation instruction recognizable by AutoHotKey, and storing the automated operation instruction in a pre-established automated operation execution list includes:
[0015] Obtain the script file;
[0016] The Json strings in the script file are sequentially parsed into corresponding automated operation instructions, and the operation class corresponding to each automated operation instruction is determined based on the operation class template pre-set in the target test software; wherein the operation class encapsulates the automated operation behavior corresponding to the automated operation instruction;
[0017] Using the operation class to generate an operation instance corresponding to each of the automated operation instructions;
[0018] The automation operation instructions and the corresponding operation instances are sequentially stored in a pre-built automation operation execution list.
[0019] In an optional implementation, executing the automation operation instructions in the automation operation execution list and calling the execution function corresponding to the automation operation instruction so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps includes:
[0020] Calling corresponding execution functions in sequence according to the operation instances in the automation operation execution list;
[0021] The execution function is used to sequentially call the corresponding AutoHotKey operation method to perform the automated operation on the target test software.
[0022] In an optional embodiment, the performing of the automated operation on the target test software includes:
[0023] Performing image recognition operations on the target image;
[0024] In response to the image recognition operation time exceeding a preset time threshold, increasing the recognition range of the target image and / or defining a local recognition frame for the target image; and,
[0025] In response to a target image recognition failure, the similarity between pixels in a local recognition frame of the target image and all pixels of the target image is determined, and when the similarity exceeds a preset pixel comparison threshold, the recognition is successful.
[0026] In a second aspect, the present invention provides an automated testing device based on AutoHotKeyd, comprising:
[0027] A script file writing module, used to generate a script file based on the automated operation steps written by the user, wherein the automated operation steps are the steps that need to be executed when the target test software performs product testing;
[0028] A script file parsing module, used to parse the script file, obtain an automated operation instruction recognizable by AutoHotKey, and store the automated operation instruction in a pre-established automated operation execution list; wherein the automated operation instruction corresponds to the automated operation step;
[0029] The automation operation execution module is used to execute the automation operation instructions in the automation operation execution list and call the execution function corresponding to the automation operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps.
[0030] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the aforementioned implementations when executing the computer program.
[0031] In a fourth aspect, the present invention provides a computer-readable medium having a non-volatile program code executable by a processor, wherein the program code enables the processor to execute the method described in any one of the aforementioned embodiments.
[0032] The beneficial effects of the technical solution provided by the embodiments of the present invention are as follows: an automated testing method, device and electronic device based on AutoHotKeyd of the present invention first generates a script file based on the automated operation steps written by the user, then parses the script file to obtain automated operation instructions recognizable by AutoHotKey, and stores the automated operation instructions in a pre-established automated operation execution list; finally, the automated operation instructions in the automated operation execution list are executed, and the execution function corresponding to the automated operation instruction is called, so that the execution function calls the corresponding AutoHotKey operation method, and controls the target test software to complete the automated operation steps; the present invention uses AutoHotkey to realize many quick and automated operations, realizes automated testing of products, improves work efficiency, and saves labor. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of a flow chart of an automated testing method based on AutoHotKeyd provided in an embodiment of the present invention;
[0034] Figure 2 A schematic diagram of a user operation window provided by an embodiment of the present invention;
[0035] Figure 3 A flowchart of a possible implementation of step S110 provided in an embodiment of the present invention;
[0036] Figure 4 A flowchart of a possible implementation of step S120 provided in an embodiment of the present invention;
[0037] Figure 5 A flowchart of a possible implementation of step S130 provided in an embodiment of the present invention;
[0038] Figure 6 A schematic diagram of the method principle for illustrating a method for determining an operation example provided for an embodiment of the present invention;
[0039] Figure 7 Another schematic flow chart of an automated testing method based on AutoHotKeyd provided by an embodiment of the present invention;
[0040] Figure 8 A system schematic diagram of an automated testing device based on AutoHotKeyd provided by an embodiment of the present invention;
[0041] Fig. 9 A system schematic diagram of an electronic device provided by an embodiment of the present invention.
[0042] In the figure: 100 - script file writing module; 200 - script file parsing module; 300 - automated operation execution module; 400 - electronic device; 401 - communication interface; 402 - processor; 403 - memory; 404 - bus. DETAILED DESCRIPTION
[0043] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0044] In an automated production line, after the product is assembled, a series of index tests need to be performed. This index test is currently completed by manually operating the test software, which has a low degree of automation, a cumbersome manual test process, and increases time costs. The efficiency is low and needs to be solved urgently. However, the existing automated operation software tools often exist in the form of another software, and the environment is relatively closed, and it is impossible to work well with the automated system used for production in the factory. Based on this, this embodiment provides an automated testing method, device, and electronic device based on AutoHotKeyd. The method, device, and electronic device allow users to customize the operating procedures of the target test software to achieve automated testing of the product; it can be embedded in the overall automated production line production process, and can be well integrated with the automated system used for production to achieve collaborative work.
[0045] Reference Figure 1 , an automated testing method based on AutoHotKeyd proposed in this embodiment includes the following steps S110 to S130. Each step is encapsulated into an executable file, that is, step S110 is an executable file for implementing script file writing, step S120 is an executable file for implementing script file parsing, and step S130 is an executable file for implementing automated operation execution. In this way, the test tool corresponding to the entire automated testing method based on AutoHotKeyd can be used as a separate software, or can be embedded in other product testing software as a third-party library.
[0046] Step S110, generating a script file based on the automated operation steps written by the user, wherein the automated operation steps are the steps that need to be executed when the target test software performs product testing.
[0047] Here, for testing a product using the target testing software, before executing the method of this embodiment, the user needs to pre-write the automated operation steps for testing the product using the target testing software.
[0048] In some possible embodiments, step S110 specifically includes the following steps (1) to (2).
[0049] Step (1), obtaining the automated operation steps input by the user, and generating a Json string based on the Json data exchange format according to the automated operation steps and a pre-built command template library; wherein the Json string includes parameter information of the automated operation steps.
[0050] Json stands for JavaScript Object Notation. It is a lightweight data exchange format based on a subset of ECMAScript (js specification developed by the European Computer Association) and uses a text format that is completely independent of programming languages to store and represent data. Json is a string representation of JavaScript objects and arrays. It uses text to represent the information of JavaScript objects or arrays. Therefore, the essence of Json is a string. Json contains two structures, objects and arrays. Through the mutual nesting of these two structures, various complex data structures can be represented. The object structure is represented as "{}" in Json, and the array structure is represented as "[]". The data in Json consists of keys and values. The keys and values are separated by colons (:), and multiple key-value pairs or array elements are separated by commas (,). The key-value pairs in objects are separated by commas, and the elements in arrays are also separated by commas.
[0051] Step (2), in response to generating a script file, generates a script file according to all generated Json strings, wherein the script file is an executable automated script file.
[0052] Here, the script file finally generated is a text file (txt file) based on the Json data exchange format. This embodiment uses a text file and the Json data exchange format to write a script file. The text file is simple to use. Json is a commonly used information exchange format in programming. It is easy to learn and has a low learning cost. Therefore, the user can quickly learn to write the script file of this embodiment. The series of automated operation instructions supported by the script file can be opening software, closing software, clicking on pictures, clicking on coordinates, etc., and different automated operation instructions can also be continuously updated during subsequent use.
[0053] The methods corresponding to steps (1) to (2) are packaged into an independent, automatically run executable file. In some possible embodiments, for example, Figure 2As shown, the executable file provides an operation window for the user. The executable file is pre-built with a command template library, and the command template library is configured with parameter information of the automated operation steps when using the target test software to perform product testing operations. For example, the parameter information corresponding to the automated operation step open command is: {"act":open",obj":"c:\\windowsl\\system32notpad.exe","check":"","timeout":10,"_note":"Open the program obj and maximize the window. Within the given time timeout, a feedback picture check should appear, otherwise false. The act parameter is the command name and cannot be modified. obj is the path of the program to be opened"}.
[0054] Here, the parameter information on the right includes the following information ①~④.
[0055] ①Name information: "act":open".
[0056] ②Running parameter information: obj":"c:\\windowsl\\system32notepad.exe", "check":"".
[0057] ③Running time information: "timeout":10.
[0058] ④ And description text information: "_note":"Open the program obj and maximize the window. Within the given timeout, a feedback image check should appear, otherwise false. The act parameter is the command name and cannot be modified. obj is the path of the program to be opened."
[0059] When the user selects a command, the corresponding parameter options will appear. After the engineer fills in the actual parameters, the executable file will automatically generate it as a Json string. After all the operation steps are written in order, an automation script file will be generated. For example, in this operation window, the user selects the command in the command list on the left as needed, and clicks "Get Command List" below to obtain the operation instructions (i.e., the commands in the command list) and parameter information corresponding to the automation operation step. Click "Modify Parameters" below to modify the parameter information in the right window. When the user has edited all the automation operation steps, the user clicks "Generate File" to automatically generate a script file, which can be run automatically. In addition, the target test software is also equipped with a "test automation file" function.
[0060] Step S110 and more detailed steps (1) to (2) of this embodiment are respectively used to write automated operation steps and generate script files. The script files exist in the form of text files and use the Json data exchange format. Each Json string contains parameter information such as the name, operation parameters, operation time, and description text of the current automated operation step. All Json strings containing automated operation information are combined together to form a complete and executable automated script file.
[0061] Step S120, parsing the script file to obtain the automation operation instructions recognizable by AutoHotKey, and storing the automation operation instructions in a pre-established automation operation execution list; wherein the automation operation instructions correspond to the automation operation steps.
[0062] Here, this step is used to parse the script file generated in the previous step into separate automated operation instructions and store them in the automated operation execution list. For example, the automated operation instructions may include opening the target test software, closing the target test software, clicking on the image in the target test software, clicking on the coordinates in the target test software, etc.
[0063] Step S120 first reads the script file and parses the Json string into the operation class pre-set in the automated test tool. Different operation class instances are generated according to different automated operation instructions, and stored in the automated operation execution list in sequence. Step S120 may specifically include the following steps (3) to (6).
[0064] Step (3), obtain the script file.
[0065] Step (4), parse the Json string in the script file into corresponding automated operation instructions in sequence, and determine the operation class corresponding to each automated operation instruction based on the operation class template pre-set in the target test software; wherein the operation class encapsulates the automated operation behavior corresponding to the automated operation instruction.
[0066] Step (5), using the operation class to generate an operation instance corresponding to each automated operation instruction.
[0067] Step (6), storing the automation operation instructions and the corresponding operation instances in sequence into a pre-built automation operation execution list.
[0068] Specifically, the method corresponding to step S120 or step (3) to step (6) of this embodiment can be encapsulated into an executable file. The executable file receives the aforementioned script file, and parses the script file through steps (4) to (6), parses the Json string into automated operation instructions and corresponding operation classes, and finally obtains operation instances according to the automated operation instructions and corresponding operation classes, and stores all the parsed automated operation instructions and operation instances in the automated operation execution list in order, and the automated operation instructions in the automated operation execution list are instructions that can be recognized by AutoHotKey.
[0069] The following examples illustrate the automation operation instructions, operation classes and operation instances. Figure 6 , if the script file generated in step (2) corresponds to two automated operation steps, the generated Json string 1 is {"act":open,"para":xxx}, and the Json string 2 is {"act":close,"para":yyy}, after parsing in step (4), the automated operation instruction 1 {"act":open,"para":xxx} and the automated operation instruction 2 {"act":close,"para":yyy} are obtained, and the operation class 1open and the operation class 2close are obtained. After the operation class obtains the specific output parameters, the corresponding operation instance can be generated. Here, the operation instance 1open is generated according to the parameter xxx, and the operation instance 2close is generated according to the parameter yyy.
[0070] Steps (4) to (6) of this embodiment are used to parse the script file into individual automated operation instructions and store them in the automated operation execution list. Parse the Json string in the script file into the operation class pre-set in the automated testing tool, and generate different operation class instances according to different automated operation instructions.
[0071] Step S130, executing the automation operation instructions in the automation operation execution list, and calling the execution function corresponding to the automation operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps.
[0072] This step selects the corresponding execution function according to the operation class order in the automation operation execution list, and the execution function calls the corresponding AutoHotKey operation method to control the computer to complete the target automation operation. When all the automation operations in the automation operation execution list are executed, the current script file is executed. The algorithm corresponding to step S130 is encapsulated as an executable file, which has AutoHotKey.dll built in it, and can execute a series of computer automation operations such as mouse clicks, software opening and closing, and image recognition.
[0073] In specific implementation, this step S130 can be the following steps (7) to (8).
[0074] Step (7), calling corresponding execution functions in sequence according to the operation instances in the automated operation execution list.
[0075] Step (8), using the execution function to sequentially call the corresponding AutoHotKey operation method to perform automated operations on the target test software.
[0076] Here, the algorithms corresponding to steps (1) to (8) are encapsulated into an executable file, which also has AutoHotKey.dll built in. The automated operation execution list in step (6) contains a series of instances of automated operation instructions, and each operation instance corresponds to a specific automated operation, such as opening software, image recognition, etc. Each operation instance is associated with a specific execution function, and the mapping relationship between the operation instance and the execution function and the execution function are encapsulated in the executable files corresponding to steps (7) to (8). According to the order in the automated operation execution list, the execution function corresponding to each operation instance is called in turn through loops, recursion and other algorithmic principles, and the automated operation of the target test software is realized in each class.
[0077] AutoHotKey is a powerful hotkey scripting language program that can realize various automated operations, such as mouse clicks, keyboard input, window management, etc. Each execution function is responsible for calling one or more AutoHotKey operation methods. When the execution function is called, it will select the corresponding AutoHotKey operation method based on the parameters and instructions in the operation instance. Then, the execution function will call this AutoHotKey operation method and pass the necessary parameters. The AutoHotKey operation method will perform the corresponding automated operation based on the passed parameters, such as opening the specified software, clicking a specific button, etc.
[0078] In this embodiment, step S130, step (7) to step (8) perform a series of automated operations on the target test software. The automated operations are determined according to the script files written and generated in advance in the aforementioned steps (1) to (2), which can simulate the manual operation process of the tester. Of course, the script file is parsed in steps (3) to (6) to generate an automated execution list, and the automated operation execution list is interpreted by steps (7) to (8) to simulate the manual operation process of the tester and realize automated control of the target test software.
[0079] In some embodiments, the execution of the automated operation step for the target test software in step (8) involves the execution of an image recognition operation for the target image. Since this embodiment is developed based on AutoHotKey (AHK), and AHK itself has weak image processing performance, it takes a long time or fails to recognize the image. Therefore, the problem is solved by the following steps (81) and (82). Among them, step (81) solves the problem of long image recognition time, and step (82) solves the problem of image recognition failure. One or both of the two steps are selected for execution according to the specific problem.
[0080] Step (81) increases the recognition range of the target image and / or defines a local recognition frame for the target image in response to the image recognition operation time exceeding the preset time threshold. This step introduces external parameters for image recognition, increases the image recognition range, or defines a recognition frame to only recognize local image information, thereby avoiding full-screen recognition that causes the recognition time to be too long.
[0081] Step (82), in response to the target image recognition failure, determine the similarity between the pixels in the local recognition frame of the target image and all the pixels of the target image, and when the similarity exceeds the preset pixel comparison threshold, the recognition is successful. This step increases the pixel comparison percentage judgment, and when the success rate of the image pixels in the local recognition frame and the target image pixels reaches a certain ratio (such as 80%, the ratio is adjustable), it is considered that the target image is recognized, thereby improving the image recognition success rate and improving the overall operation efficiency.
[0082] The above steps are further explained below in conjunction with a specific embodiment. A factory produces product A, and after production is completed, performance testing is required. The test is performed using a third-party test software configured in the automated test equipment. The third-party test software is the target test software, and its test process is to place the product on the automated test equipment, and the automated test equipment completes automatic posture adjustment, wiring and other operations. After completing the above operations, the automated test tool developed according to the method of this embodiment will control the target test software to complete the test process according to the established steps. The automated operation steps include (but are not limited to) operations such as "mouse click", "open test software", "recognize pictures", and "close test software". Next, taking this product as an example, combined with steps S31 to S55, the principle of the method of this embodiment and its use principle are described in detail.
[0083] An automated test tool is written in advance according to the above steps. The automated test is used to test product A. The automated test tool is installed in the terminal where the test software of product A is located. The automated test tool includes three executable files, namely: a script file writing executable file (written based on the principle of step S110 or based on the principle of steps (1) to (2)), a script file parsing executable file (written based on the principle of step S120 or based on the principle of steps (3) to (6)) and an automated operation execution executable file (written based on the principle of step S130 or based on the principle of steps (7) to (8)).
[0084] Before using the automated testing tool, the user first obtains the operating procedures of the test software for product A to be pre-written. For example, the operating procedures for product A are to open the test software and click the burn button, and then close the burning software after the burning operation is completed. Then, the user needs to split the operating procedures into multiple automated operation steps. For example, the test procedure for product A can be split into opening the test software, clicking the burn button, judging that the burning operation is completed, and closing the test software. After that, the user selects the operation window (which can be Figure 2 When writing an automated operation step such as "Open test software" for product A, the user needs to select the Open software command in the operation window and enter relevant parameters in the operation window, such as: test software name, test software exe file address, waiting time after executing the operation, etc.
[0085] After the user completes inputting the parameters, the script file is used to write an executable file to automatically execute the following steps S31 to S34.
[0086] Step S31: Obtain the automated operation steps input by the user. For example, the automated operation steps of product A include "open test software", "click the burn button", "wait for burn completion", and "close test software".
[0087] Step S32: Convert the automated operation steps into a Json string. For example, convert the current automated operation steps of product A input by the user into a Json string in real time. Save the Json string of each automated operation step input by the user and its conversion number.
[0088] Step S33: Determine whether all the automated operation steps have been written. If not, return to step S31; if yes, continue to step S34. This step is used to confirm whether all the automated operation steps have been written. If not, return to step S31 to re-acquire new automated operation steps. If completed, it means that all the automated operation steps for product A have been written.
[0089] Step S34: Generate a script file based on the Json string of all automated operation steps, that is, generate a script file of product A after completing all operation writing.
[0090] Reference Figure 4 After the script file is written, the script file parsing executable file will parse the script file to obtain an automated operation execution list. The specific principle is shown in the following steps S41 to S46.
[0091] Step S41: Reading a script file. After the script file of product A is written by writing an executable file through a script file, the script file will be read first when the script file is parsed and the executable file is started.
[0092] Step S42: Parse the script file to obtain multiple automated operation instructions and operation examples.
[0093] Step S43: multiple automated operation instructions and operation examples thereof are obtained in sequence. For example, among multiple automated operation steps for product A, the automated operation instruction “open test software” and its operation example are first obtained.
[0094] Step S44: storing the plurality of automated operation instructions and their operation instances in the automated operation execution list in order. For example, among the plurality of automated operation instructions and their operation instances of product A, the "open test software" operation instruction and its operation instance are first stored in the automated operation execution list.
[0095] Step S45: confirm whether all operation instructions and operation instances thereof are stored in the automated operation execution list. If not completed, the process returns to step S43 to repeat the previous steps, otherwise, the process continues to step S46.
[0096] Step S46: Generate an automated operation execution list. This completes the script file parsing.
[0097] After obtaining the automated operation execution list, the automated operation execution executable file will complete the automated operation according to the following steps S51 to S55 and the automated operation list. Figure 5 .
[0098] Step S51: Obtaining an automated operation execution list. After the automated operation execution list of product A is generated by parsing the executable file through the script file, the automated operation execution executable file will first obtain the list.
[0099] Step S52: Read the instructions in the automated operation execution list. For example, for product A, the automated operation step of "opening the test software" will be read first.
[0100] Step S53: Select the corresponding method to perform the automated operation. For example, for product A, the current automated operation step is "open the test software". At this time, the computer will execute the operation method of opening the test software, and control the computer to automatically open the test software according to the input parameters, and wait for the specified time. For the specific principle, please refer to the above steps (7) to (8).
[0101] Step S54: Check whether all the operation tasks in the automation operation execution list are completed. If not, return to step S52 to read the next automation operation instruction in the automation operation list and continue to execute; if completed, execute step S55.
[0102] Step S55: End of the automated test process. After the test software for product A automatically completes the steps of "opening the test software", "clicking the burn button", "waiting for the burn to complete", and "closing the test software", the automated test process for the product ends.
[0103] The principles of steps S31 to S55 are described in detail in Figure 7 The script file writing executable file generates a script file from multiple automated operation instructions input by users. The script file parsing executable module stores multiple operation instances into an automated operation execution list. The automated operation execution executable file executes multiple execution functions in sequence until the automated test process ends.
[0104] The automated testing tool of this embodiment first determines the specific operation flow of the test software, splits each operation step into specific automated operation instructions, uses the script file to write an executable file to generate a corresponding Json string, and combines all the Json strings containing automated operation instructions to generate a script file. After the corresponding script file is generated, it is passed into the script file parsing executable file. The executable file will read the script file, split it into preset automated operation instructions, and generate corresponding instruction instances and store them in the automated operation execution list in sequence. After the automated instructions are stored in the automated operation execution list, the automated operation execution executable file will read the operation instances in the automated operation execution list in sequence, and select the corresponding execution function according to the operation instance and execute it. The execution function will call the computer operation method corresponding to AutoHotKey. When all execution functions are executed in sequence, the entire automated testing process ends.
[0105] The automated testing tool of this embodiment can be used as a separate software, or can be embedded in other software as a third-party library. This is because this embodiment is developed on the basis of AutoHotKey, and provides an interface for communicating with external testing software. When other testing software uses the automated testing tool of this embodiment, it only needs to introduce the library in this embodiment and then call the corresponding interface to implement the corresponding function. Therefore, compared with the existing product testing tools in the form of closed software, the automated testing tool written according to the method of this embodiment can interact well with the original product testing software in the automated factory, and can be embedded in the original product testing software with simple secondary development, which ensures the smoothness of the automated testing process and reduces the cost of manual operation.
[0106] This embodiment uses text files and Json data exchange format to write script files, which is simple to operate and has low learning costs. Users can quickly learn the writing process of automated operation steps. After the script file is edited, it can be used directly the next time the script file is used to write an executable file without editing. The content parsed by the script file parsing executable file can also be stored in the process and directly input into the automated operation execution executable file. The automated operation execution executable file can also perform corresponding operations at any time according to the parsed operation content.
[0107] In summary, the method of this embodiment can use AutoHotkey to realize many quick and automated operations of product testing software, realize automated testing of products, and improve product testing efficiency. This embodiment can also reduce debugging complexity and improve product testing efficiency. This embodiment can be applied to an automated production system on an assembly station, and the assembly station and the test station can be combined. After the assembly is completed, testing can be performed, which saves labor and equipment costs.
[0108] Reference Figure 8, an embodiment of the present invention further provides an automated testing device based on AutoHotKeyd, comprising a script file writing module 100, a script file parsing module 200 and an automated operation execution module. The script file writing module 100 is used to generate a script file based on automated operation steps written by a user, wherein the automated operation steps are steps that need to be executed when the target test software performs product testing. The script file parsing module 200 is used to parse the script file, obtain automated operation instructions recognizable by AutoHotKey, and store the automated operation instructions in a pre-established automated operation execution list; wherein the automated operation instructions correspond to the automated operation steps. The automated operation execution module 300 is used to execute the automated operation instructions in the automated operation execution list, and call the execution function corresponding to the automated operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automated operation steps.
[0109] In an optional embodiment, the script file is a text file based on the Json data exchange format.
[0110] In an optional embodiment, the script file writing module 100 includes a first acquisition module and a script file generation module. The acquisition module is used to acquire the automated operation steps input by the user, and generate a Json string based on the Json data exchange format according to the automated operation steps and a pre-built command template library; wherein the Json string includes parameter information of the automated operation steps. The script file generation module is used to generate a script file according to all the generated Json strings in response to generating a script file, wherein the script file is an executable automated script file.
[0111] In an optional embodiment, the parameter information of the automated operation step includes name information, operation parameter information, operation time information and description text information.
[0112] In an optional embodiment, the automated operation instructions include opening the target test software, closing the target test software, clicking on a picture in the target test software, and clicking on coordinates in the target test software.
[0113] In an optional embodiment, the script file parsing module 200 includes a second acquisition module, a parsing module, an operation instance generation module and an execution list module. The second acquisition module is used to acquire the script file. The parsing module is used to parse the Json string in the script file into corresponding automated operation instructions in sequence, and determine the operation class corresponding to each automated operation instruction based on the operation class template pre-set in the target test software; wherein the operation class encapsulates the automated operation behavior corresponding to the automated operation instruction. The operation instance generation module is used to generate an operation instance corresponding to each automated operation instruction using the operation class. The execution list module is used to store the automated operation instructions and the corresponding operation instances in sequence in a pre-built automated operation execution list.
[0114] In an optional embodiment, the automated operation execution module 300 includes a first calling module and a second calling module. The first calling module is used to sequentially call corresponding execution functions according to operation instances in the automated operation execution list. The second calling module is used to sequentially call corresponding AutoHotKey operation methods using execution functions to perform automated operations on the target test software.
[0115] In an optional embodiment, the second calling module includes an image recognition module, a recognition timeout processing module, and a recognition failure processing module. The image recognition module is used to perform an image recognition operation for a target image. The recognition timeout processing module is used to increase the recognition range of the target image and / or circle a local recognition frame for the target image in response to the image recognition operation time exceeding a preset time threshold. The recognition failure processing module is used to determine the similarity between the pixels in the local recognition frame of the target image and all the pixels of the target image in response to the failure of the target image recognition, and when the similarity exceeds the preset pixel comparison threshold, the recognition is successful.
[0116] The device provided in the embodiment of the present application is adopted. Since the device adopts the same inventive concept as the above-mentioned method provided in the embodiment of the present application, on the premise that the method can solve the technical problem, the device can also solve the technical problem, which will not be repeated here.
[0117] Reference Fig. 9 The embodiment of the present invention further provides an electronic device 400, including a communication interface 401, a processor 402, a memory 403 and a bus 404, wherein the processor 402, the communication interface 401 and the memory 403 are connected via the bus 404; the memory 403 is used to store a computer program that supports the processor 402 to execute the above-mentioned AutoHotKeyd-based automated testing method, and the processor 402 is configured to execute the program stored in the memory 403.
[0118] Optionally, an embodiment of the present invention further provides a computer-readable medium having a non-volatile program code executable by the processor 402 , wherein the program code enables the processor 402 to execute the automated testing method based on AutoHotKeyd in the above embodiment.
[0119] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
Claims
1. An automated testing method based on AutoHotKeyd, characterized in that: include: Generate a script file based on the automated operation steps written by the user, wherein the automated operation steps are the steps that need to be executed when the target test software performs product testing; Parsing the script file to obtain an automated operation instruction recognizable by AutoHotKey, and storing the automated operation instruction in a pre-established automated operation execution list; wherein the automated operation instruction corresponds to the automated operation step; Execute the automation operation instructions in the automation operation execution list, and call the execution function corresponding to the automation operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps.
2. The automated testing method based on AutoHotKeyd according to claim 1, characterized in that: The script file is a text file based on the Json data exchange format.
3. The automated testing method based on AutoHotKeyd according to claim 2, characterized in that: The script file is generated based on the automated operation steps written by the user, including: Acquire the automated operation steps input by the user, and generate a Json string based on the Json data exchange format according to the automated operation steps and a pre-built command template library; wherein the Json string includes parameter information of the automated operation steps; In response to generating a script file, the script file is generated according to all the generated Json strings, wherein the script file is an executable automation script file.
4. The automated testing method based on AutoHotKeyd according to claim 3, characterized in that: The parameter information of the automated operation step includes name information, operation parameter information, operation time information and description text information.
5. The automated testing method based on AutoHotKeyd according to claim 1, characterized in that: The automated operation instructions include opening the target test software, closing the target test software, clicking on a picture in the target test software, and clicking on coordinates in the target test software.
6. The automated testing method based on AutoHotKeyd according to claim 3, characterized in that: The step of parsing the script file to obtain an automated operation instruction recognizable by AutoHotKey and storing the automated operation instruction in a pre-established automated operation execution list includes: Obtain the script file; The Json strings in the script file are sequentially parsed into corresponding automated operation instructions, and the operation class corresponding to each automated operation instruction is determined based on the operation class template pre-set in the target test software; wherein the operation class encapsulates the automated operation behavior corresponding to the automated operation instruction; Using the operation class to generate an operation instance corresponding to each of the automated operation instructions; The automation operation instructions and the corresponding operation instances are sequentially stored in a pre-built automation operation execution list.
7. The automated testing method based on AutoHotKeyd according to claim 1, characterized in that: The step of executing the automation operation instructions in the automation operation execution list and calling the execution function corresponding to the automation operation instruction so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps includes: Calling corresponding execution functions in sequence according to the operation instances in the automation operation execution list; The execution function is used to sequentially call the corresponding AutoHotKey operation method to perform the automated operation on the target test software.
8. The automated testing method based on AutoHotKeyd according to claim 7, characterized in that: The performing of the automated operation for the target test software comprises: Performing image recognition operations on the target image; In response to the image recognition operation time exceeding a preset time threshold, increasing the recognition range of the target image and / or defining a local recognition frame for the target image; and, In response to a target image recognition failure, the similarity between pixels in a local recognition frame of the target image and all pixels of the target image is determined, and when the similarity exceeds a preset pixel comparison threshold, the recognition is successful.
9. An automated testing device based on AutoHotKeyd, characterized in that: include: A script file writing module, used to generate a script file based on the automated operation steps written by the user, wherein the automated operation steps are the steps that need to be executed when the target test software performs product testing; A script file parsing module, used to parse the script file, obtain an automated operation instruction recognizable by AutoHotKey, and store the automated operation instruction in a pre-established automated operation execution list; wherein the automated operation instruction corresponds to the automated operation step; The automation operation execution module is used to execute the automation operation instructions in the automation operation execution list and call the execution function corresponding to the automation operation instruction, so that the execution function calls the corresponding AutoHotKey operation method to control the target test software to complete the automation operation steps.
10. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of claims 1 to 8 when executing the computer program.