File generation method and device, equipment, storage medium and program product
By automatically converting RF keywords to Python code, the problem of inefficiency of automated test case debugging and cross-platform call is solved, and efficient manual conversion and project maintainability is achieved.
Patent Information
- Application Number
- CN202411285840.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-03-07
AI Technical Summary
In the prior art, automated test case debugging and cross-platform call efficiency are low, and due to the complex and large number of RF cases, it takes a lot of time to convert RF keywords to Python methods, which affects work efficiency.
By obtaining the path list of robot robot files, mapping the relationship file based on the path list and the initialized keywords, traversing the robot files, obtaining the preset file code, and writing it to the conversion file, realizing automatic conversion of RF keywords to Python code.
It greatly improves the debugging and cross-platform application capabilities of automated test cases, significantly saves labor costs, improves conversion efficiency, and improves the maintainability of the project and team collaboration efficiency through the generated keyword mapping files.
Smart Images

Figure CN119576332A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data conversion, and in particular to a file generation method, apparatus, device, storage medium and program product. Background Art
[0002] With the rapid development of the Internet, the complexity and scale of software applications continue to rise, and the requirements for quality and efficiency are also increasing, which in turn puts forward new requirements for the flexible and efficient generation, use, and debugging of automation cases. In the past, due to limitations of technical levels and other factors, many automation test-related works were built based on RF (Robot Framework). Therefore, there are many RF keywords and RF cases composed of keywords in automation projects. Today, in the face of new technological developments and requirements, the shortcomings of RF cases, such as the difficulty of debugging and the inability to be directly called and executed by Python methods, have gradually been magnified, hindering the efficiency of debugging and cross-platform calling of automated test cases.
[0003] Based on the above, converting RF cases into Python methods can greatly improve case debugging and cross-platform application capabilities, and can better improve the efficiency of using automated test cases. Therefore, it is necessary to manually rewrite the existing keywords using the RF test framework into Python methods, but due to the complexity and large number of existing RF keywords and cases, the workload of conversion is very large and time-consuming, which seriously affects work efficiency. Summary of the invention
[0004] The main purpose of this application is to provide a file generation method, device, equipment, storage medium and program product, aiming to solve the technical problem of how to reduce the labor cost in the file generation process and improve the conversion efficiency.
[0005] To achieve the above purpose, the present application proposes a file generation method, which includes: Get the path list of robot robot files; According to the path list and the initialized keyword mapping relationship file, traverse the robot file to obtain the preset file code; The preset file code is written into a pre-created conversion file to obtain a code file corresponding to the preset file code.
[0006] In one embodiment, before the step of traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code, the step further includes: Initialize and read keyword mapping relationship files, where the keyword mapping relationship files include a first keyword mapping relationship file and a second keyword mapping relationship file.
[0007] In one embodiment, the step of traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code includes: Traverse the robot file according to the path list to obtain keywords in the robot file; Based on the initialized keyword mapping relationship file, the robot framework RF sentence in the keyword is converted into a preset file code.
[0008] In one embodiment, the step of reading the robot file according to the path list and obtaining keywords in the robot file includes: Determine whether the keyword exists in the current robot file; If the keyword does not exist in the current robot file, read the next robot file until the keyword exists in the robot file; If the keyword exists in the current robot file, determining whether the path list of the current robot file already exists in the second keyword mapping relationship file; If the path list of the current robot file does not exist in the second keyword mapping relationship file, the step of converting the RF statement in the keyword into a preset file code is executed.
[0009] In one embodiment, the step of converting the robot framework RF statement in the keyword into a preset file code based on the initialized keyword mapping relationship file includes: Analyze the keywords in the library file and the resource file referenced by the current robot file through a recursive expansion strategy to update the first keyword mapping relationship file and the second keyword mapping relationship file; According to the updated first keyword mapping relationship file and the second keyword mapping relationship file, the RF statements of the keywords in the library file and the resource file are converted to obtain a preset file code.
[0010] In one embodiment, the step of analyzing the keywords in the library file and the resource file by the recursive expansion strategy to update the first keyword mapping relationship file and the second keyword mapping relationship file includes: Recursively expand keywords in library files and resource files referenced by the current robot file; Analyze the keywords in the library file and the resource file to obtain keyword file information; The keyword file information is stored in the first keyword mapping relationship file and the second keyword mapping relationship file to complete the update of the first keyword mapping relationship file and the second keyword mapping relationship file.
[0011] In one embodiment, before the step of writing the preset code into a pre-created conversion file to obtain a code file corresponding to the preset code, the step further includes: creating a conversion file corresponding to the preset file code based on the preset file code.
[0012] In addition, to achieve the above-mentioned purpose, the present application also proposes a file generation device, the file generation device comprising: Get module, used to get the path list of robot files; A traversal module, used to traverse the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; The writing module is used to write the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code.
[0013] In addition, to achieve the above-mentioned purpose, the present application also proposes a file generation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the file generation method described above.
[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the file generation method described above are implemented.
[0015] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the file generation method described above are implemented.
[0016] The embodiment of the present application proposes a file generation method, device, equipment, storage medium and program product, the method comprising obtaining a path list of a robot file; traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; writing the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code. The solution obtains the preset file code according to the specified file path, so that the automatic conversion of RF keywords to target code files can be quickly realized, which greatly saves labor costs and improves efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 A flowchart of the first embodiment of the method for generating application documents is provided; Figure 2 A schematic diagram of a process flow provided for Example 2 of the method for generating application documents; Figure 3 A brief flowchart of the file generation method provided in Example 1 and Example 2 of the present application; Figure 4 This is a schematic diagram of the module structure of the file generation device according to an embodiment of the present application; Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the file generation method in the embodiment of the present application.
[0020] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0021] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0022] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0023] The main solution of the embodiment of the present application is: obtain the path list of the robot robot file; traverse the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code; write the preset file code into a pre-created conversion file to obtain the code file corresponding to the preset file code.
[0024] At present, the existing keywords using the RF test framework are manually rewritten and converted into Python methods. Due to the complexity and large number of existing RF keywords and cases, the conversion workload is very large and time-consuming, which seriously affects work efficiency.
[0025] The present application provides a solution, specifically, obtaining a path list of the robot file; traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code; writing the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code. This solution traverses the keywords in the RF file under the code project, recursively expands the methods referenced by these keywords in the library file and resource file, and organizes and saves the correspondence and reference path between the recursively expanded keyword methods and the preset code methods into the preset code file; at the same time, it also realizes the direct conversion of the keywords in the specified RF file into Python code that can be directly run; in addition, the user can clearly grasp the RF keywords in the code project and their file location and other related information by viewing the generated keyword mapping file.
[0026] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, etc. The following takes a mobile phone as an example to illustrate this embodiment and the following embodiments.
[0027] Based on this, the present application embodiment provides a method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the method for generating documents of this application.
[0028] In this embodiment, the file generation method includes steps S10 to S30: Step S10, obtaining a path list of robot files; It should be noted that Robot Framework is a general automation framework, mainly used for automated testing. Its file extension is usually .robot. This format supports writing test cases in a tabular form, making it relatively easy for non-programmers to write test scripts.
[0029] Optionally, get a list of paths to all Robot Framework (.robot) files that need to be converted, where you can choose to convert a single file in the path list or convert multiple files at the same time.
[0030] Step S20, traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; It should be noted that, in this embodiment, the preset file code is Python. The initialized keyword mapping relationship file includes a first keyword mapping relationship file and a second keyword mapping relationship file.
[0031] It is worth noting that in order to quickly complete the automatic conversion of RF keywords to executable Python, step S20 is executed without manually rewriting the keywords in the RF test framework, which saves the required labor costs and improves efficiency.
[0032] In a feasible implementation, step S20 may include steps S21-S22: Step S21, traversing the robot file according to the path list to obtain keywords in the robot file; In the current step S21, all relevant robot files are searched and accessed according to the pre-set path list. Keywords for automatic testing and their calls are included in these robot files. The purpose of traversal is to identify these keywords to provide important data basis for subsequent code conversion file work.
[0033] Based on this, step S21 "traversing the robot file according to the path list to obtain keywords in the robot file" specifically includes: First, open and read all library files (library) and other robot file resource information referenced in the current robot file.
[0034] And according to whether there are features such as keyword in the current robot file, it is determined whether there is an RF keyword in the current robot file. If the current robot file does not contain the RF keyword, continue to traverse the next robot file until the keyword in the robot file is found; if the current robot file contains the RF keyword, it is determined whether the file path of the current robot file already exists in the second keyword mapping relationship file, that is, it is determined whether the current robot file has been converted into a file corresponding to the preset file code (Python); if the file path of the current robot file does not exist in the second keyword mapping relationship file, it means that the current robot file has not been converted into a file corresponding to the preset file code (Python), which further indicates that the robot file can be converted.
[0035] Through step S21, it is ensured that only the robot files that are not recorded in the second keyword mapping relationship file are converted, thereby avoiding repeated conversions and making the maintenance of the entire automated test script more efficient.
[0036] Step S22: based on the initialized keyword mapping relationship file, convert the robot framework RF sentence in the keyword into a preset file code.
[0037] It should be noted that RF statements refer to instructions or keyword calls written in Robot Framework, which define the specific steps and operations of a test case. RF statements usually include, but are not limited to, the name of a keyword and its parameters.
[0038] In a feasible implementation, step S22 may include steps S221-S222: Step S221, analyzing keywords in the library files and resource files referenced by the current robot file through a recursive expansion strategy to update the first keyword mapping relationship file and the second keyword mapping relationship file; It should be noted that the first keyword mapping relationship file includes the library information of the RF keyword, the mapping relationship between the keyword name and the Python method name, and the import path in the Python file; the second keyword mapping relationship file contains the mapping relationship between the keyword name in different robot files under the path and the Python method name after successful conversion, as well as the import path in the Python file.
[0039] Among them, the library information of the RF keyword in the first keyword mapping relationship file records the library file described by the keyword; the mapping relationship between the keyword name and the Python method name defines how the RF keyword is mapped to the method in Python; the import path in the Python file specifies how to import the modules where these methods are located in the Python file.
[0040] The mapping relationship between the keyword names in different robot files and the successfully converted Python method names under the path in the second keyword mapping relationship file records how the keywords in each .robot file are converted into Python methods; the import path in the Python file also specifies the path for importing Python methods in the Python file.
[0041] Optionally, before recursively accessing RF keywords in libraries and other robot file resources referenced in the robot file, it is necessary to first read the library and other resource information referenced in the current robot file, so that all RF keywords can be fully identified and processed when the recursive search is carried out.
[0042] After obtaining the unconverted robot file through step S21, first, recursively access the RF keywords in the library and other robot file resource information referenced by the robot file, analyze the keywords in these files, and determine the keyword information corresponding to the RF keyword, where the keyword information includes the Python method name, the original robot file path, and the Python import path.
[0043] Subsequently, the information such as the Python method name, the original robot file path, the Python import path, etc. corresponding to the RF keyword is stored, and the information is updated to the first keyword mapping relationship file and the second keyword mapping relationship file.
[0044] Step S222: converting the RF statements of the keywords in the library file and the resource file according to the updated first keyword mapping relationship file and the second keyword mapping relationship file to obtain a preset file code.
[0045] Optionally, first, traverse the RF keywords in the current robot file, and convert, process, and the like the RF statements in each RF keyword according to the updated first keyword mapping relationship file and the second keyword mapping relationship file to generate Python code.
[0046] However, since the parameters between the keywords in Robot Framework and the Python methods may not match completely, it is also necessary to process the input and output parameters of the Python methods to ensure that the Python methods can correctly receive and return the necessary data. And assemble the dependent import statements, etc. to ensure that the code can run normally in the target environment. Finally, assemble it into a Python file code that can be executed immediately, and update the second keyword mapping relationship file at the same time to ensure that the second keyword mapping relationship file is always up to date and can track all converted keywords and their corresponding Python implementations.
[0047] Through the above steps, not only can the RF keywords be converted into the specified file code, but it can also be ensured that the converted file code is functionally equivalent to the original RF keywords and can run seamlessly in the target environment.
[0048] Step S30, writing the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code.
[0049] Optionally, before executing step S30, it is also necessary to create a conversion file corresponding to the preset file code based on the preset file code. For example, if the preset file code is a Python file code, it is necessary to create a Python file corresponding to the Python file code in advance.
[0050] After the Python file is created, the converted file code obtained in step S20 is written into the newly created code file, that is, the converted Python file code is written into the newly created Python file, so that the keywords in the robot file are converted into the preset code file.
[0051] Through the above-mentioned embodiment method, the keywords in the RF file under the code project can be traversed, the keyword methods in the library files and resource files referenced by them can be recursively expanded, and the corresponding relationship between the recursively expanded keyword methods and Python methods and the reference paths can be sorted and saved in the code project file, so as to realize the conversion of keywords into code files, greatly saving the cost of human conversion and improving efficiency. In addition, the conversion status and location of each keyword can be directly understood by viewing the generated keyword mapping file, thereby greatly improving the maintainability of the project and the efficiency of team collaboration.
[0052] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 Before step S20, the file generation method further includes step S201: Step S201 : Initialize and read a keyword mapping relationship file, wherein the keyword mapping relationship file includes a first keyword mapping relationship file and a second keyword mapping relationship file.
[0053] It should be noted that the first keyword mapping relationship file is the RF-library keyword mapping relationship file, which records the library information used in Robot Framework, the mapping relationship between keyword names and Python method names, and the path for importing these methods in Python files, such as "fromxxx.xxx import aaa".
[0054] The second keyword mapping relationship file is the converted RF file keyword mapping relationship file, which is grouped by the relative path of the folder above the robot file and the project root directory, and contains the mapping relationship between the keyword names in different robot files under the path and the Python method names after successful conversion, as well as the import path in the Python file.
[0055] Optionally, to determine whether the current robot file is converted for the first time, it is possible to check whether the current robot file already exists in the second keyword mapping relationship file. If not, it is considered that this is the first conversion, and the RF-library keyword mapping relationship file is initialized by reading the library information and keywords in the robot file; analyzing and recording the mapping relationship between keywords and Python methods; recording and importing the path; and writing this information into the RF-library keyword mapping relationship file to initialize the keyword mapping relationship file.
[0056] The above embodiment method specifically initializes and reads the first keyword mapping relationship file and the second keyword mapping relationship file to ensure that each keyword conversion file work is based on the latest information and all mapping relationship files can be kept synchronized and up-to-date.
[0057] For example, to help understand the implementation process of the file generation method obtained by combining the above-mentioned embodiment 1 and embodiment 2, please refer to Figure 3 , Figure 3 A brief flowchart of a file generation method is provided, specifically: This embodiment provides a method for converting keywords in a robot file under a RobotFramework test framework into a Python file.
[0058] First, determine whether the current project is the first time to convert files. If the current project is the first time to convert files, initialize the first keyword mapping relationship file and the second keyword mapping relationship file, where the first keyword mapping relationship file is the RF-library keyword mapping relationship file and the second keyword mapping relationship file is the converted RF file keyword mapping relationship file. If the current project is not the first time to convert files, load the first keyword mapping relationship file and the second keyword mapping relationship file saved before.
[0059] After obtaining the first keyword mapping relationship file and the second keyword mapping relationship file, obtain the path list of all robot files that need to be converted, and traverse each robot file according to the path list, including: first, read the library and other robot file resources referenced in the current robot file. Then, determine whether the RF keyword exists in the current robot file. If the RF keyword does not exist in the current robot file, continue to traverse the next robot file until the existence of the RF keyword is found; if the RF keyword exists in the current robot file, determine whether the file path of the current robot file already exists in the second keyword mapping relationship file, that is, determine whether the current robot file has been converted into a preset code file, that is, a Python file. If the file path of the current robot file does not exist in the second keyword mapping relationship file, recursively expand the RF keywords in all associated libraries and other robot file resources that are cascaded referenced by the current robot file, complete the conversion of keyword files in library methods and resource resources, and analyze and store the Python method names, original robot file paths, Python import paths, etc. corresponding to the keywords in these files, that is, update the keyword information in the first keyword mapping relationship file and the second keyword mapping relationship file; and complete the creation of the conversion file to obtain the preset file code file, that is, the Python file.
[0060] Then, by traversing the keywords in the current robot file, according to the updated first keyword mapping relationship file and the second keyword mapping relationship file, the RF statement of each keyword in the current robot file is converted and processed to generate Python code.
[0061] Next, the input and output parameters of the Python method are processed, and dependent import statements are assembled, and finally assembled into an immediately executable Python file code. At the same time, the second keyword mapping relationship file is updated.
[0062] Finally, write the immediately executable Python file code into the newly created Python file.
[0063] Through the above-mentioned embodiment method, the keywords in the Robot Framework file under the code project are traversed, and the keywords in all the library and resource files referenced by it are recursively expanded. In this way, the mapping relationship of all keywords encountered in the recursive process and their corresponding Python methods, as well as their reference paths, can be sorted and saved in the file of the code project. The automatic conversion from RF keywords to executable Python code can be quickly completed, thereby greatly saving labor costs and improving work efficiency. In addition, through the generated keyword mapping file, the associated information such as the RF keywords and the file location in the entire code project can also be clearly grasped.
[0064] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the document generation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0065] This application also provides a file generation device, please refer to Figure 4 , the file generating device comprises: An acquisition module 10 is used to obtain a path list of robot files; A traversal module 20 is used to traverse the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; The writing module 30 is used to write the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code.
[0066] The file generation device provided by the present application adopts the file generation method in the above embodiment, which can solve the technical problem of how to reduce the labor cost in the file generation process and improve the conversion efficiency. Compared with the prior art, the beneficial effects of the file generation device provided by the present application are the same as the beneficial effects of the file generation method provided by the above embodiment, and other technical features in the file generation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0067] The present application provides a file generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the file generation method in the above-mentioned embodiment 1.
[0068] Reference below Figure 5, which shows a schematic diagram of the structure of a file generating device suitable for implementing an embodiment of the present application. The file generating device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The file generation device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0069] like Figure 5 As shown, the file generating device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the file generating device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems may be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the file generation device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a file generation device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0070] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0071] The file generation device provided by the present application adopts the file generation method in the above embodiment, which can solve the technical problem of how to reduce the labor cost in the file generation process and improve the conversion efficiency. Compared with the prior art, the beneficial effects of the file generation device provided by the present application are the same as the beneficial effects of the file generation method provided by the above embodiment, and the other technical features in the file generation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0072] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0073] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0074] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the file generation method in the above-mentioned embodiment.
[0075] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0076] The computer-readable storage medium may be included in the file generating device; or may exist independently without being assembled into the file generating device.
[0077] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the file generating device, the file generating device: obtains a path list of the robot robot file; traverses the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; writes the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code.
[0078] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0079] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0080] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0081] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned file generation method, and can solve the technical problem of how to reduce the labor cost in the file generation process and improve the conversion efficiency. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the file generation method provided in the above-mentioned embodiment, and will not be repeated here.
[0082] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned file generation method when executed by a processor.
[0083] The computer program product provided by this application can solve the technical problem of how to reduce the labor cost in the file generation process and improve the conversion efficiency. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the file generation method provided by the above embodiment, which will not be repeated here.
[0084] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A file generation method, characterized in that: The method comprises: Get the path list of robot robot files; According to the path list and the initialized keyword mapping relationship file, traverse the robot file to obtain the preset file code; The preset file code is written into a pre-created conversion file to obtain a code file corresponding to the preset file code.
2. The method according to claim 1, characterized in that Before the step of traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code, the method further includes: Initialize and read keyword mapping relationship files, where the keyword mapping relationship files include a first keyword mapping relationship file and a second keyword mapping relationship file.
3. The method according to claim 2, characterized in that The step of traversing the robot file according to the path list and the initialized keyword mapping relationship file to obtain the preset file code includes: Traverse the robot file according to the path list to obtain keywords in the robot file; Based on the initialized keyword mapping relationship file, the robot framework RF sentence in the keyword is converted into a preset file code.
4. The method according to any one of claims 2 to 3, characterized in that The step of reading the robot file according to the path list and obtaining keywords in the robot file comprises: Determine whether the keyword exists in the current robot file; If the keyword does not exist in the current robot file, read the next robot file until the keyword exists in the robot file; If the keyword exists in the current robot file, determining whether the file path of the current robot file already exists in the second keyword mapping relationship file; If the file path of the current robot file does not exist in the second keyword mapping relationship file, the step of converting the RF statement in the keyword into a preset file code is executed.
5. The method according to any one of claims 2 to 4, characterized in that The step of converting the robot framework RF statement in the keyword into a preset file code based on the initialized keyword mapping relationship file includes: Analyze the keywords in the library file and the resource file referenced by the current robot file through a recursive expansion strategy to update the first keyword mapping relationship file and the second keyword mapping relationship file; According to the updated first keyword mapping relationship file and the second keyword mapping relationship file, the RF statements of the keywords in the library file and the resource file are converted to obtain a preset file code.
6. The method according to claim 5, characterized in that The step of analyzing the keywords in the library file and the resource file referenced by the current robot file through a recursive expansion strategy to update the first keyword mapping relationship file and the second keyword mapping relationship file includes: Recursively expand keywords in library files and resource files referenced by the current robot file; Analyze the keywords in the library file and the resource file to obtain keyword file information; The keyword file information is stored in the first keyword mapping relationship file and the second keyword mapping relationship file to complete the update of the first keyword mapping relationship file and the second keyword mapping relationship file.
7. The method according to claim 1, characterized in that Before the step of writing the preset code into a pre-created conversion file to obtain a code file corresponding to the preset code, the step further includes: creating a conversion file corresponding to the preset file code based on the preset file code.
8. A file generating device, characterized in that: The device comprises: Get module, used to get the path list of robot files; A traversal module, used to traverse the robot file according to the path list and the initialized keyword mapping relationship file to obtain a preset file code; The writing module is used to write the preset file code into a pre-created conversion file to obtain a code file corresponding to the preset file code.
9. A file generating device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the file generation method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the file generation method according to any one of claims 1 to 7 are implemented.
11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the file generation method according to any one of claims 1 to 7 are implemented.