Automatic test script generation method and device, storage medium and electronic equipment

By allowing users to write test cases in natural language format and parse data using regular expressions to generate automated test scripts, the problem that testers in the existing technology need to have Python programming capabilities is solved, which significantly reduces the difficulty of generating test scripts and improves testing Efficiency and accuracy.

CN119473909APending Publication Date: 2025-02-18AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411721286.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

When generating automated test scripts, existing interface automation testing tools require testers to have certain Python programming capabilities, which increases the difficulty of learning and using the tools.

Method used

By allowing users to write test cases in natural language format, parse object information and transaction operation steps using regular expressions, store image data and table data in a structured manner, and automatically generate Python code snippets to generate automated test scripts.

Benefits of technology

It reduces the requirements for writing complex code, allowing users to describe test scenarios without programming skills, significantly reducing the difficulty of generating automated test scripts, and improving testing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473909A_ABST
    Figure CN119473909A_ABST
Patent Text Reader

Abstract

The invention provides an automated testing script generation method and device, a storage medium and electronic equipment, and is applied to the technical field of automated testing. According to the method, the user writes the test case in the natural language format, the generation process of the test script is simplified, the regular expression is used for analyzing the object information and the transaction operation steps, the picture data and the table data are stored in a structured mode, the Python code segment is automatically generated, the user can create the automatic test script without programming skills, and the user experience is improved. According to the method, the generation difficulty of the automatic test script is remarkably reduced, so that a user can better use an interface automatic tool for testing, the test description is more intuitive, and the test efficiency and accuracy are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing technology, and in particular to an automated testing script generation method, device, storage medium and electronic equipment. Background Art

[0002] UI (User Interface) automated testing is the most realistic automated testing method that is closest to real user behavior. Traditional interface testing tools usually locate elements by identifying the properties of interface element controls (such as ID, name, relative path, type, etc.). However, since these tools rely on the implementation principle of element attribute positioning, it is difficult to carry out UI automated testing for some applications. The industry has been exploring more stable object recognition technologies to address this challenge.

[0003] Currently, interface automation tools usually use image recognition technology supported by OpenCV to identify GUI components, locate images on the screen, and use the mouse and keyboard to interact with the identified GUI elements. Interface automation tools can also embed OCR functions, which can be used to search for text in images, and support running on Windows, Mac OS, and most Linux / Unix systems. However, interface automation tools require testers to have certain Python programming skills, which undoubtedly increases the difficulty of learning and using the tools.

[0004] Therefore, how to reduce the difficulty of generating automated test scripts and facilitate users to better utilize interface automation tools for testing has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention

[0005] In view of the above problems, the present invention provides an automated test script generation method, device, storage medium and electronic device that overcome the above problems or at least partially solve the above problems. The technical solution is as follows:

[0006] An automated test script generation method, comprising:

[0007] Obtaining a test case edited by a user in a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information;

[0008] The transaction name, object name and picture in the object information are parsed using a first preset regular expression, wherein the picture includes four types of data including an offset, a matching degree, a picture name and picture format data;

[0009] Using a second preset regular expression to parse out the system name, transaction name, object name, operation name and parameter data in the transaction operation step information;

[0010] Associating the object information with the object name of the transaction operation step information, storing the offset, the matching degree and the picture name as the object location description corresponding to the object name in the table data with the transaction name as the object table name, storing the picture format data in the transaction name folder with the transaction name as the file name, and storing the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name;

[0011] Generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library;

[0012] Integrate the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case.

[0013] Optionally, after integrating the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case, the method further includes:

[0014] Use the target interface automation tool to run the automated test script, identify and classify checkpoint errors, image non-existence errors and abnormal errors during the running process, take a screenshot of the final state of the automated test script and save it, and generate a script test result.

[0015] Optionally, the table data is stored in a table format, and the table includes an object name, an object type, and an object location description.

[0016] Optionally, the transaction operation step information includes at least one logical operation including sequential execution of logical operations, conditional judgment execution of logical operations and loop execution of logical operations.

[0017] Optionally, the using of the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, to generate a Python code segment corresponding to the transaction operation step information, comprises:

[0018] Utilizing the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, the logical operation in the transaction step information is mapped to a first Python code segment.

[0019] Optionally, the using of the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, to generate a Python code segment corresponding to the transaction operation step information, comprises:

[0020] Utilizing the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, the first preset operation in the transaction step information is mapped to a second Python code segment containing a single function call, and the second preset operation in the transaction step information is mapped to a third Python code segment containing multiple function calls.

[0021] Optionally, the first preset operation includes: clicking, double-clicking, inputting, pasting, waiting for an object to appear, scrolling up and scrolling down, and the second preset operation includes dragging and taking values.

[0022] An automated test script generation device comprises: a test case acquisition unit, an object information parsing unit, a transaction operation step information parsing unit, an information data storage unit, a code segment generation unit and an automated test script generation unit.

[0023] The test case obtaining unit is used to obtain a test case edited by a user in a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information;

[0024] The object information parsing unit is used to parse the transaction name, object name and picture in the object information using a first preset regular expression, wherein the picture includes four types of data including offset, matching degree, picture name and picture format data;

[0025] The transaction operation step information parsing unit is used to parse the system name, transaction name, object name, operation name and parameter data in the transaction operation step information using a second preset regular expression;

[0026] The information data storage unit is used to associate the object information with the object name of the transaction operation step information, store the offset, the matching degree and the picture name as the object positioning description corresponding to the object name in the table data with the transaction name as the object table name, store the picture format data in the transaction name folder with the transaction name as the file name, and store the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name;

[0027] The code segment generating unit is used to generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, in combination with the path information of the table data and the image format data corresponding to the transaction operation step in the object library;

[0028] The automated test script generation unit is used to integrate the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case.

[0029] A computer-readable storage medium stores a program, wherein when the program is executed by a processor, the program implements any of the above-mentioned automated test script generation methods.

[0030] An electronic device, comprising at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute any of the above-mentioned automated test script generation methods.

[0031] By means of the above technical scheme, the automated test script generation method, device, storage medium and electronic device provided by the present invention obtain a test case edited by a user in a preset natural language format, wherein the test case includes multiple object information and multiple transaction operation step information; uses a first preset regular expression to parse out the transaction name, object name and picture in the object information, and the picture includes four types of data including offset, matching degree, picture name and picture format data; uses a second preset regular expression to parse out the system name, transaction name, object name, operation name and parameter data in the transaction operation step information; associates the object information with the object name of the transaction operation step information, and uses the offset, matching degree and picture name as The object location description corresponding to the object name is stored in the table data with the transaction name as the object table name, the image format data is stored in the transaction name folder with the transaction name as the file name, and the table data and the transaction name folder are stored in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name; the system name, transaction name, object name, operation name and parameter data of any transaction operation step information are used, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to generate the Python code segment corresponding to the transaction operation step information; the Python code segments corresponding to each transaction operation step information are integrated to generate the automated test script of the test case. The present invention reduces the requirements for writing complex codes by allowing users to write test cases in natural language format, so that users can describe test scenarios without programming skills, and then combine regular expression parsing with structured storage of image data and table data to generate automated test scripts. The user does not need to contact Python code to complete the creation of automated test scripts during the whole process, which significantly reduces the difficulty of generating automated test scripts and helps testers to better use interface automation tools for testing.

[0032] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0034] Figure 1 A flow chart showing an implementation of a method for generating an automated test script according to an embodiment of the present invention is shown;

[0035] Figure 2 A schematic diagram showing a format of a natural language format provided by an embodiment of the present invention is shown;

[0036] Figure 3 A schematic diagram showing the format of a target Python script provided by an embodiment of the present invention is shown;

[0037] Figure 4 A schematic diagram showing the structure of an automated test script generating device provided by an embodiment of the present invention is shown;

[0038] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0039] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0040] In the UI (User Interface) page, information is mainly composed of images and text. Efficiently identifying control objects based on images and text has become a key issue facing automated testing. With the development of computer vision (CV) algorithms, automated testing technology based on image recognition has gradually developed from an auxiliary technology to a mainstream technology. This technology can solve the problems faced by traditional methods based on element attribute recognition, such as slow positioning speed, non-standard elements, hidden elements, etc., which lead to the inability to locate.

[0041] Current image recognition-based interface automation tools (such as SIKULIX and AIRTEST) have the following main problems:

[0042] 1. High cost of writing automated test cases: These tools rely on Python scripts for the development and maintenance of automated scripts, requiring testers to master programming skills. This not only increases the difficulty of implementation, but also makes writing test cases time-consuming and laborious, reducing the efficiency of tool use.

[0043] 2. High maintenance cost of automated test cases: Automated testing technology based on image recognition relies on element screenshots for element location. Existing tools usually name images with timestamps, which lack readability. A large number of page elements need to be adjusted during software product iterations, and it is difficult to quickly locate the elements that need to be updated, which increases maintenance costs.

[0044] 3. Automated testing assets are not clear enough: Automated testing tools verify software functions by executing test cases, but these cases are usually non-process-oriented and not very readable, making it difficult to show the full picture of the business process. Different people need to familiarize themselves with the same case repeatedly when executing it, making it difficult to ensure the effective transfer of test assets.

[0045] In summary, although image recognition-based automated testing technology shows great potential, it still has significant challenges in use case writing, maintenance, and asset management, and needs further improvement and optimization to improve overall efficiency and usability.

[0046] Based on this, in an embodiment of the present invention, an automated test script generation method is provided, which simplifies the test script generation process by allowing users to write test cases in a natural language format, uses regular expressions to parse object information and transaction operation steps, stores image data and table data in a structured manner, and automatically generates Python code segments, so that users can create automated test scripts without programming skills, significantly reducing the difficulty of automated test script generation, thereby facilitating users to better utilize interface automation tools for testing, making test descriptions more intuitive, and effectively improving test efficiency and accuracy.

[0047] like Figure 1 As shown, a flow chart of an implementation of a method for generating an automated test script provided by an embodiment of the present invention is provided, and the method includes:

[0048] S100: Obtain a test case edited by a user in a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information.

[0049] Among them, natural language format refers to the language that people use in daily life, such as English, Chinese, etc., to communicate information and ideas, rather than computer programming language. It is an informal and easy-to-understand description method that usually does not require a technical background to understand.

[0050] The natural language format provided by the embodiment of the present invention can be as follows Figure 2As shown, the object information is contained between three single quotes, including the object table name, object name and picture information. The object table name is the name of the table used to store objects. It also represents the name of the upper-level transaction to which the object belongs and is unique in each set of object information. The object name is a natural language description of the image. In addition, the picture information includes the offset of the center of the image, the matching degree, the picture name and the corresponding ".png format data". The transaction operation step information is contained between three double quotes and is divided into two formats: data-free operation and data-with operation. The format of data-free operation is: "serial number, system name / transaction name.object name+operation name (no data type)". The format of data-with operation is: "serial number, system name / transaction name.object name+operation name (with data type)+data".

[0051] When the SIKULIX execution engine performs case execution, it selects the target image for matching by the image name. If two images with the same name are found, an error will be generated because it is impossible to determine which image to use. To improve user ease of use, the default screenshot image name is a timestamp, however, for more intuitive identification, the system uses the object name to name the image. Each image is uniquely identified by its path and name. When running the conversion program, the object name duplication check and image existence check are performed. It should be noted that the image name is related to the positioning content of the object, but is not directly associated with the object name. Therefore, even if the tester modifies the object name, there is no need to change the image name and the positioning content of the object. This design simplifies the tester's operation and makes the management of object names and images more flexible and efficient.

[0052] Among them, transaction operation step information refers to the specific sequence of operations performed during software testing to verify a certain function or feature. Each step usually includes a series of instructions on how to operate the system or application to ensure that it runs as expected. For example, transaction operation step information may include opening an application, entering data, clicking a button, etc. In the context, multiple transaction operation step information written by the user is described in a natural language format. This means that users describe the sequence of operations they want to test in an intuitive and easy-to-understand way, rather than writing scripts in a programming language. This makes writing test steps more readable and accessible, especially for non-technical personnel.

[0053] The embodiments of the present invention allow users to write test cases in natural language format, which reduces the requirement for writing complex code. Testers do not need to have programming skills to describe test scenarios, making the test writing process more intuitive and user-friendly.

[0054] In order to convert data into tables and images for storage, regular expressions can be used to extract the required information based on the format characteristics. This information includes object table name, object name, image name, offset, matching degree, and steps. In this way, data can be parsed and organized efficiently.

[0055] S110. Use a first preset regular expression to parse out the transaction name, object name, and picture in the object information. The picture includes four types of data, including offset, matching degree, picture name, and picture format data.

[0056] The image format data may specifically be PNG image format data.

[0057] The object table name in the object information is specifically the transaction name. Since the format of the object table name is clear, the regular expression "object table (.+?)(?:#|#)" can be used, and it is compatible with Chinese and English pound signs.

[0058] For object names, image names, offsets and matching degrees, the text display formats of SIKULIX can be parsed. These formats include image name format, matching degree format, offset format and comprehensive format. The corresponding regular expressions are as follows:

[0059] The image name format is: "(?:#|#)([^##\(]+)\"([0-9]+)\.png".

[0060] Matching format: "(?:#|#)([^##]+)Pattern\(\"([0-9]+)\.png\"\)\.similar\(([0-9\.]+)\)".

[0061] Offset format: "(?:#|#)([^##]+)Pattern\(\"([0-9]+)\.png\"\)\.targetOffset\(([0-9-,]+)\)".

[0062] Comprehensive format: "(?:#|#)([^##]+)Pattern\(\"([0-9]+)\.png\"\)\.similar\(([0-9\\.]+)\)\.targetOffset\(([0-9-,]+)\)".

[0063] After processing with the above regular expression, the text data corresponding to each image can be extracted. Then, the data is formatted through the following steps: replace "Pattern(" with an empty character, replace ")" with ";", and perform existence check and replacement on ".similar(0" and ".targetOffset(". Finally, the data is divided into the format of object name and image name corresponding to the object name, matching degree and offset: "image name.png; (matching degree); (offset)".

[0064] S120. Use a second preset regular expression to parse out the system name, transaction name, object name, operation name, and parameter data in the transaction operation step information.

[0065] When processing transaction operation step information, each step content is wrapped between three double quotes. You can use the regular expression "([^,]+)" to split and sort the steps. At the same time, in order to identify the operation name with data type and extract the corresponding object name, you can use the regular expression "\.(.*)\+(input|paste|wait for object to appear|roll up|roll down|drag|value)(.*)".

[0066] The embodiment of the present invention uses a preset regular expression to automatically parse the natural language test case input by the user. This step converts the unstructured natural language information into structured data (such as object information and transaction operation step information), which helps the system to automatically identify and process this information.

[0067] S130. Associate the object information with the object name of the transaction operation step information, store the offset, matching degree and image name as the object location description corresponding to the object name in the table data with the transaction name as the object table name, store the image format data in the transaction name folder with the transaction name as the file name, and store the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name.

[0068] Among them, interface automation tools are a type of software tools used to automate the testing and operation of the graphical user interface (GUI) of computer applications. These tools perform a series of predefined tasks by simulating user interactions such as clicking, entering text, dragging and dropping, etc. Interface automation tools can be used for a variety of purposes, including software testing, task automation, and improving productivity. Interface automation tools can include Selenium, QTP / UFT, SIKULIX, AutoIt, and TestComplete, etc.

[0069] In order to save the automation testers from writing Python scripts, we need to analyze and extract the input items of the assembly script and design a natural language format. This format allows testers to achieve the same effect as writing Python scripts by writing natural language text. Before conducting the analysis, the concept of modularity is introduced. Modular design is a design method that splits the system into smaller parts, called modules. These modules can be independently created, modified, replaced, or exchanged between different systems.

[0070] Automated testing is the process of converting manual test operations into machine-executable ones. It automates software testing by writing test scripts to simulate the steps of manual testing. In this process, the test object can be decomposed from the system into transactions, then into elements, and finally into specific test steps. The test steps are composed of a series of transactions, such as login, data entry, query, and logout.

[0071] Since the steps of each transaction are usually fixed and do not affect the steps of other transactions, applying modular design in automated test scripts can significantly improve the reusability of scripts and reduce maintenance costs. Through modularization, test scripts can be managed and updated more flexibly, making automated testing more efficient and maintainable.

[0072] For example, the execution process of SIKULIX automation scripts usually follows a specific logical sequence of steps to perform image-related operation functions. Each image operation involves four types of data: offset, match, image name, and PNG format data. Therefore, the main input items required by the script are the step description and the related image data.

[0073] In order to effectively organize the image data, the embodiment of the present invention divides it into two parts: image format data and corresponding table data. PNG images are stored in folders named after the transaction name, and tables are named after the transaction name. Both are located in folders named after the system name. All assets in the system name folder are stored in the "Object Library" folder.

[0074] Optionally, the table data is stored in a table format, which contains the object name, object type, and object location description. The design of the table refers to Table 1, and the table design contains three columns: object name, object type, and object location description. The first row represents the page information, which stores the transaction name, that is, the table name. Object data is listed starting from the second row. In SIKULIX, since the operation object is based on image recognition, the object data refers to the image data. The table data of the image includes offset, matching degree, and image name. Therefore, the object location description is designed as: "image name.png; (matching degree); (offset)".

[0075] Table 1

[0076] Object Name Object Type Object Positioning Description Transaction 1 page Transaction 1 Subject 1 picture Image name.png; (matching degree); (offset)

[0077] The embodiment of the present invention can identify object information (such as object table name, object name, picture, etc.) through parsing and associate it with transaction operation steps (such as system name, transaction name, object name, operation name, parameter data). This association enables the system to understand the relationship between elements and operations in the test. At the same time, the parsed information is stored in the object library in a structured manner, including the management of table data and picture format data. This organized storage method improves the accessibility and reusability of data and simplifies the subsequent code generation process.

[0078] S140. Generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any transaction operation step information and combining the path information of the table data and image format data corresponding to the transaction operation step in the object library.

[0079] Optionally, the transaction operation step information includes at least one logical operation including sequential execution of logical operations, conditional judgment execution of logical operations, and loop execution of logical operations.

[0080] Optionally, an embodiment of the present invention can utilize the system name, transaction name, object name, operation name and parameter data of any transaction operation step information, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to map the logical operations in the transaction step information to the first Python code segment.

[0081] For sequentially executed logic operations, the operations are directly mapped according to their order. For example, if the sequentially executed logic operations are: "object name + click; object name + input + 123", the mapped code segment is:

[0082] “click(“initial path / general name / transaction name / image name corresponding to object name.png”)

[0083] type("image name corresponding to initial path / unified name / transaction name / object name.png","123")".

[0084] For conditional judgment and logical operation, the natural language format is: "(execute internal operation: If start; [object name] | exists); (execute internal operation: ElseIf condition; [object name] | does not exist); (execute internal operation: If end)". For example: when the conditional judgment and logical operation are "(execute internal operation: If start; object name | exists); object name + click; (execute internal operation: ElseIf condition; object name | does not exist); object name 2 + input + 123; (execute internal operation: If end); object name 3 + up scroll wheel + 1", the code segments that can be mapped to these steps are:

[0085] “if exists("object name"):

[0086] click("initial path / unified name / transaction name / image name corresponding to object name.png")

[0087] elif not exists("object name"):

[0088] type("initial path / unified name / transaction name / image name corresponding to object name 1.png","123")

[0089] wheel("initial path / unified name / transaction name / image name corresponding to object name 3.png",Button.WHEEL_UP / ,1)".

[0090] For loop execution logic operation, the natural language format is: "(execute internal operation: While loop starts; [object name] | exists); (execute internal operation: While loop ends)". For example: when the loop execution logic operation is "(execute internal operation: While loop starts; object name | does not exist); object name 2 + click; (execute internal operation: While loop ends); object name + input + 123", it can be mapped to the following code segment:

[0091] “while not exists("object name"):

[0092] click("initial path / general name / transaction name / image name corresponding to object name 2.png")

[0093] type("image name corresponding to initial path / unified name / transaction name / object name.png","123")".

[0094] The embodiment of the present invention automatically maps different types of logical operations (sequential execution, conditional judgment, and loop execution) into Python code segments, so that users can create automated test scripts without having to access Python codes, thereby reducing the difficulty of generating automated test scripts.

[0095] Optionally, an embodiment of the present invention can utilize the system name, transaction name, object name, operation name and parameter data of any transaction operation step information, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to map the first preset operation in the transaction step information to a second Python code segment containing a single function call, and map the second preset operation in the transaction step information to a third Python code segment containing multiple function calls.

[0096] Optionally, the first preset operation includes: clicking, double-clicking, inputting, pasting, waiting for an object to appear, scrolling up and scrolling down, and the second preset operation includes dragging and taking values.

[0097] The image operation functions in SIKULIX include click(), doubleclick(), type(), paste(), wait(), and wheel(). These operation functions can be simply mapped as: "click -- click()", "double-click -- doubleclick()", "input -- type()", "paste -- paste()", "wait -- wait()", and "wheel -- wheel()".

[0098] Using modular thinking, the transaction operations in the case steps are encapsulated as combined steps. The operation format in the combined step is designed as: system / transaction.object+operation+parameter. The object table data can be found through the system name / transaction name table, and the table stores the image name of the object. The PNG image data of the object can be found through the path system name / transaction name / image name. The final operation object of each step is an element, and the system and transaction play an indexing role on the element.

[0099] The Python code that corresponds natural language operations to object names is as follows:

[0100] “Object name + click – click(“initial path / general name / transaction name / image name corresponding to object name.png”)

[0101] Object name + double click - doubleclick ("initial path / unified name / transaction name / image name corresponding to object name.png")

[0102] Object name + input + 123——type (“initial path / unified name / transaction name / image name corresponding to object name.png”, “123”)

[0103] Object name + paste + 123 - paste ("initial path / unified name / transaction name / image name corresponding to object name.png", "123")

[0104] Object name + waiting object to appear + 1——wait("initial path / unified name / transaction name / image name corresponding to object name.png", 1)

[0105] Object name + up / down wheel + 1——wheel("initial path / group name / transaction name / image name corresponding to object name.png",Button.WHEEL_UP / DOWN,1)".

[0106] In addition, there are other complex operations such as dragging and dropping, and obtaining values. Their mapping relationships are the same as the above principles, but involve the mapping of code segments rather than just a single function.

[0107] The embodiment of the present invention promotes the application of modular design ideas through a mapping mechanism, and enhances the reusability and scalability of the code by encapsulating operation steps into combined steps, so that users can create automated test scripts without having to access Python code, thereby reducing the difficulty of generating automated test scripts.

[0108] When using the SIKULIX tool, the above natural language format can be edited and saved directly in the py file of the SIKULIX tool. The script writer does not need to master the Python language, but only needs to operate according to the specified format.

[0109] In the SIKULIX tool, there are two ways to display images on the interface: Image display: including the center offset, matching degree and image name of the image. Text display: Default offset and matching degree: the format is "image name.png". Default offset and non-default matching degree: the format is Pattern("image name.png").similar(matching degree). Non-default offset and default matching degree: the format is Pattern("image name.png").targetOffset(x-axis offset, y-axis offset). Non-default offset and non-default matching degree: the format is Pattern("image name.png").similar(matching degree).targetOffset(x-axis offset, y-axis offset). All ".png image data" are stored in the same directory as the py file.

[0110] The embodiment of the present invention can automatically generate corresponding Python code segments by using the parsed test step information and stored data. The automatically generated code segments ensure the accuracy and consistency of the test scripts and reduce the difficulty of generating automated test scripts.

[0111] S150. Integrate the Python code segments corresponding to each transaction operation step information to generate a target Python script.

[0112] The target Python script is designed as follows: Figure 3 As shown, the step mapping code segment is the Python code segment corresponding to each transaction operation step information.

[0113] The process of step mapping data starts with the case table. When the program executes a case, each case record is parsed. During the parsing process, the corresponding transaction operation is located through the combined steps in the case. According to the system name, transaction name, object name, operation and data in the transaction step, this information is mapped into the corresponding Python code segment. Then, the generated code segment is embedded in the larger step mapping code segment to form a complete Python script corresponding to the case. After that, the SIKULIX program is directly started to execute the newly generated Python script. During the whole process, the tester does not need to directly touch the Python code.

[0114] The embodiment of the present invention integrates all generated code segments to form a complete Python script, which can be directly used in interface automation tools including SIKULIX tools to perform UI automation testing.

[0115] Optional, in the above Figure 1 In another optional embodiment provided by the embodiment of the present invention based on one or more corresponding embodiments, after integrating the Python code segments corresponding to the information of each transaction operation step to generate the target Python script, it may also include:

[0116] Use the target interface automation tool to run the target Python script, identify and classify checkpoint errors, image non-existence errors and abnormal errors during the running process, take a screenshot of the final state of the target PYTHON script and save it, and generate script test results.

[0117] Among them, checkpoint errors usually refer to situations where the expected state is not reached or certain conditions are not met during script execution.

[0118] Among them, the image does not exist error means that an image that needs to be operated is missing or cannot be recognized.

[0119] Among them, abnormal errors include unexpected errors that occur during script execution, such as program crashes or other uncaught exceptions.

[0120] When the script execution ends, the embodiment of the present invention takes a screenshot of the final state of the application or target interface and saves it, generating a visual record of the execution result to facilitate subsequent analysis. After the script is executed, a test report is generated to record in detail the execution status of the script, the errors identified and the final screenshot, which helps the tester understand the success or failure of the script execution and where the problem lies.

[0121] The embodiment of the present invention can quickly and accurately locate the problem by automatically identifying and classifying different types of errors, reducing the time for manual error analysis and the possibility of misjudgment. At the same time, error classification processing makes script debugging and maintenance more systematic, and developers can more clearly understand the nature of the problem and the solution.

[0122] The automated test script generation method provided by the present invention comprises: obtaining a test case edited by a user in a preset natural language format, wherein the test case comprises a plurality of object information and a plurality of transaction operation step information; using a first preset regular expression to parse out a transaction name, an object name and a picture in the object information, wherein the picture comprises four types of data including an offset, a matching degree, a picture name and picture format data; using a second preset regular expression to parse out a system name, a transaction name, an object name, an operation name and parameter data in the transaction operation step information; associating the object information with the object name of the transaction operation step information, and using the offset, the matching degree and the picture name as the corresponding objects to the object name. The image location description is stored in the table data with the transaction name as the object table name, the image format data is stored in the transaction name folder with the transaction name as the file name, and the table data and the transaction name folder are stored in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name; the system name, transaction name, object name, operation name and parameter data of any transaction operation step information are used, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to generate the Python code segment corresponding to the transaction operation step information; the Python code segments corresponding to each transaction operation step information are integrated to generate the automated test script of the test case. The present invention reduces the requirement for writing complex codes by allowing users to write test cases in natural language format, so that users can describe test scenarios without programming skills, and then combine regular expression parsing with structured storage of image data and table data to generate automated test scripts. The user does not need to contact Python code to complete the creation of automated test scripts during the whole process, which significantly reduces the difficulty of generating automated test scripts and helps testers to better use interface automation tools for testing.

[0123] Although operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.

[0124] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0125] Corresponding to the above method embodiment, the embodiment of the present invention provides an automated test script generation device, whose structure is as follows: Figure 4 As shown, it may include: a test case obtaining unit 10, an object information parsing unit 20, a transaction operation step information parsing unit 30, an information data storage unit 40, a code segment generating unit 50 and an automated test script generating unit 60.

[0126] The test case obtaining unit 10 is used to obtain a test case edited by a user according to a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information.

[0127] The object information parsing unit 20 is used to parse the transaction name, object name and picture in the object information using a first preset regular expression, where the picture includes four types of data including offset, matching degree, picture name and picture format data.

[0128] The transaction operation step information parsing unit 30 is used to parse the transaction operation step information to obtain the system name, transaction name, object name, operation name and parameter data using a second preset regular expression.

[0129] The information data storage unit 40 is used to associate the object information with the object name of the transaction operation step information, store the offset, matching degree and picture name as the object positioning description corresponding to the object name in the table data with the transaction name as the object table name, store the picture format data in the transaction name folder with the transaction name as the file name, and store the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name.

[0130] The code segment generating unit 50 is used to generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any transaction operation step information, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library.

[0131] The automated test script generating unit 60 is used to integrate the Python code segments corresponding to each transaction operation step information to generate an automated test script for the test case.

[0132] Optionally, the automated test script generating device may further include: a script test result generating unit.

[0133] The script test result generation unit is used for the automated test script generation unit 60 to integrate the Python code segments corresponding to the information of each transaction operation step, generate the automated test script of the test case, and then use the target interface automation tool to run the automated test script. During the running process, it identifies and classifies checkpoint errors, image non-existent errors and abnormal errors, takes a screenshot of the final state of the automated test script and saves it to generate a script test result.

[0134] Optionally, the tabular data is stored in a table format, which includes an object name, an object type, and an object location description.

[0135] Optionally, the transaction operation step information includes at least one logical operation including sequential execution of logical operations, conditional judgment execution of logical operations, and loop execution of logical operations.

[0136] Optionally, the code segment generation unit 50 can be specifically used to utilize the system name, transaction name, object name, operation name and parameter data of any transaction operation step information, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to map the logical operation in the transaction step information into a first Python code segment.

[0137] Optionally, the code segment generation unit 50 can be specifically used to utilize the system name, transaction name, object name, operation name and parameter data of any transaction operation step information, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to map the first preset operation in the transaction step information to a second Python code segment containing a single function call, and map the second preset operation in the transaction step information to a third Python code segment containing multiple function calls.

[0138] Optionally, the first preset operation includes: clicking, double-clicking, inputting, pasting, waiting for an object to appear, scrolling up and scrolling down, and the second preset operation includes dragging and taking values.

[0139] The automated test script generation device provided by the present invention is used to: obtain a test case edited by a user in a preset natural language format, wherein the test case includes multiple object information and multiple transaction operation step information; use a first preset regular expression to parse out the transaction name, object name and picture in the object information, wherein the picture includes four types of data including offset, matching degree, picture name and picture format data; use a second preset regular expression to parse out the system name, transaction name, object name, operation name and parameter data in the transaction operation step information; associate the object information with the object name of the transaction operation step information, and use the offset, matching degree and picture name as the corresponding object name. The image location description is stored in the table data with the transaction name as the object table name, the image format data is stored in the transaction name folder with the transaction name as the file name, and the table data and the transaction name folder are stored in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name; the system name, transaction name, object name, operation name and parameter data of any transaction operation step information are used, combined with the path information of the table data and image format data corresponding to the transaction operation step in the object library, to generate the Python code segment corresponding to the transaction operation step information; the Python code segments corresponding to each transaction operation step information are integrated to generate the automated test script of the test case. The present invention reduces the requirement for writing complex codes by allowing users to write test cases in natural language format, so that users can describe test scenarios without programming skills, and then combine regular expression parsing with structured storage of image data and table data to generate automated test scripts. The user does not need to contact Python code to complete the creation of automated test scripts during the whole process, which significantly reduces the difficulty of generating automated test scripts and helps testers to better use interface automation tools for testing.

[0140] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0141] The automated test script generating device comprises a processor and a memory. The test case obtaining unit 10, the object information parsing unit 20, the transaction operation step information parsing unit 30, the information data storage unit 40, the code segment generating unit 50 and the automated test script generating unit 60 are all stored in the memory as program units. The processor executes the program units stored in the memory to realize corresponding functions.

[0142] The processor contains a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set. By adjusting the kernel parameters, users can write test cases in natural language format, which reduces the requirement for writing complex code and allows users to describe test scenarios without programming skills. Combined with regular expression parsing and structured storage of image data and table data, automated test scripts are generated. During the whole process, users do not need to touch Python code to complete the creation of automated test scripts, which significantly reduces the difficulty of generating automated test scripts and helps testers better use interface automation tools for testing.

[0143] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the method for generating an automated test script is implemented.

[0144] An embodiment of the present invention provides a processor, which is used to run a program, wherein the automated test script generation method is executed when the program is running.

[0145] like Figure 5 As shown, an embodiment of the present invention provides an electronic device 1000, which includes at least one processor 1001, at least one memory 1002 connected to the processor 1001, and a bus 1003; wherein the processor 1001 and the memory 1002 communicate with each other through the bus 1003; the processor 1001 is used to call the program instructions in the memory 1002 to execute the above-mentioned automated test script generation method. The electronic device in this article can be a server, a PC, a PAD, a mobile phone, etc.

[0146] The present invention also provides a computer program product, which, when executed on an electronic device, is suitable for executing a program that initializes the steps of the automated test script generation method.

[0147] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatuses, electronic devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processor of the computer or other programmable device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0148] In a typical configuration, an electronic device includes one or more processors (CPU), a memory, and a bus. The electronic device may also include an input / output interface, a network interface, and the like.

[0149] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.

[0150] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0151] In the description of the present invention, it should be understood that the terms "up", "down", "front", "back", "left" and "right" etc. indicating directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the positions or elements referred to must have specific directions, be constructed and operate in specific directions. Therefore, they should not be understood as limitations of the present invention.

[0152] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0153] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0154] The above are only embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims

1. A method for generating an automated test script, characterized in that: include: Obtaining a test case edited by a user in a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information; The transaction name, object name and picture in the object information are parsed using a first preset regular expression, wherein the picture includes four types of data including an offset, a matching degree, a picture name and picture format data; Using a second preset regular expression to parse out the system name, transaction name, object name, operation name and parameter data in the transaction operation step information; Associating the object information with the object name of the transaction operation step information, storing the offset, the matching degree and the picture name as the object location description corresponding to the object name in the table data with the transaction name as the object table name, storing the picture format data in the transaction name folder with the transaction name as the file name, and storing the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name; Generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library; Integrate the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case.

2. The method according to claim 1, characterized in that After integrating the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case, the method further includes: Use the target interface automation tool to run the automated test script, identify and classify checkpoint errors, image non-existence errors and abnormal errors during the running process, take a screenshot of the final state of the automated test script and save it, and generate a script test result.

3. The method according to claim 1, characterized in that The table data is stored in a table format, and the table contains an object name, an object type, and an object location description.

4. The method according to claim 1, characterized in that: The transaction operation step information includes at least one logic operation including sequential execution logic operation, conditional judgment execution logic operation and loop execution logic operation.

5. The method according to claim 4, characterized in that The method of using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, to generate a Python code segment corresponding to the transaction operation step information includes: Utilizing the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, the logical operation in the transaction step information is mapped to a first Python code segment.

6. The method according to any one of claims 1 to 5, characterized in that The method of using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, to generate a Python code segment corresponding to the transaction operation step information includes: Utilizing the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, combined with the path information of the table data and the image format data corresponding to the transaction operation step in the object library, the first preset operation in the transaction step information is mapped to a second Python code segment containing a single function call, and the second preset operation in the transaction step information is mapped to a third Python code segment containing multiple function calls.

7. The method according to claim 6, characterized in that The first preset operation includes: click, double-click, input, paste, wait for the object to appear, scroll up and scroll down, and the second preset operation includes drag and value.

8. An automated test script generation device, characterized in that: include: Test case acquisition unit, object information parsing unit, transaction operation step information parsing unit, information data storage unit, code segment generation unit and automated test script generation unit, The test case obtaining unit is used to obtain a test case edited by a user in a preset natural language format, wherein the test case includes a plurality of object information and a plurality of transaction operation step information; The object information parsing unit is used to parse the transaction name, object name and picture in the object information using a first preset regular expression, wherein the picture includes four types of data including offset, matching degree, picture name and picture format data; The transaction operation step information parsing unit is used to parse the system name, transaction name, object name, operation name and parameter data in the transaction operation step information using a second preset regular expression; The information data storage unit is used to associate the object information with the object name of the transaction operation step information, store the offset, the matching degree and the picture name as the object positioning description corresponding to the object name in the table data with the transaction name as the object table name, store the picture format data in the transaction name folder with the transaction name as the file name, and store the table data and the transaction name folder in the object library of the target interface automation tool according to the folder structure of the system name and the transaction name; The code segment generating unit is used to generate a Python code segment corresponding to the transaction operation step information by using the system name, transaction name, object name, operation name and parameter data of any of the transaction operation step information, in combination with the path information of the table data and the image format data corresponding to the transaction operation step in the object library; The automated test script generation unit is used to integrate the Python code segments corresponding to the transaction operation step information to generate an automated test script for the test case.

9. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the method for generating an automated test script according to any one of claims 1 to 7 is implemented.

10. An electronic device, comprising at least one processor, and at least one memory and a bus connected to the processor; wherein: The processor and the memory communicate with each other via the bus; The processor is used to call the program instructions in the memory to execute the automatic test script generation method according to any one of claims 1 to 7.