A framework construction method and computing device for storing and using variables

By creating the first resource file and import configuration import library in the Robot Framework RIDE, the problem of inefficiency in the use of Robot Framework when the configuration information and/or page element information is large, and the configuration and page element errors are easily called. It realizes the simplified operation of variables and the reminder function of variables with the same name.

CN114398248BActive Publication Date: 2025-02-21XIAMEN LEELEN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111143678.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2025-02-21
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

Robot Framework and its accompanying Robot Framework RIDE are inefficient when the configuration information and/or page element information are large, configuration and page elements are prone to invoking errors, and workload is increased when storing through external files.

Method used

By creating the first resource file, setting the variable classification name, importing the resource library and configuring the import library in the second resource file, loading the variables of the first resource file, realizing the storage and use of the variables.

Benefits of technology

It solves the problem of inefficient storage and usage, avoids the workload of searching and switching interfaces when storing external files, and realizes the simplified operation of variables and the reminder function of variables with the same name.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398248B_ABST
    Figure CN114398248B_ABST
Patent Text Reader

Abstract

The present invention discloses a framework construction method for storing and using variables, comprising the following steps: S1, creating a first resource file, wherein the first resource file sets a variable classification name by creating a new keyword; the variables of the first resource file include configuration information and / or page element information; S2, creating a second resource file for automated testing, and importing a resource library and a configuration import library into the second resource file, wherein the configuration import library is provided with a preset identifier and a path of the first resource file; S3, identifying the configuration import library; S4, loading the variables of the first resource file by reading the path of the first resource file of the configuration import library.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to a framework construction method and computing device for storing and using variables. Background Art

[0002] In the field of automated testing frameworks, Robot Framework is the most widely used open source automated testing framework in the world. Combined with its supporting Robot Framework RIDE script editor, it provides many functions in actual automated testing work, including the storage and use of configuration information and / or page elements.

[0003] like Figure 1 As shown, the existing Robot Framework and its supporting Robot Framework RIDE have built-in configuration information and / or page element information storage and usage functions, but when the amount of configuration information and / or page element information is large, there are problems such as low efficiency and easy configuration and page element calling errors. The main reason is that the configuration and page elements are stored in variables. In the script tree structure, each variable occupies a node separately. When the number of variables is large, it is inconvenient to view and maintain the tree structure. At the same time, when the variables need to be grouped, it is necessary to create a new variable file, which increases the number of files and further increases the cost of use and maintenance. On the other hand, when multiple variables have the same name, no prompt will be given but they will overwrite each other, resulting in the failure of the automated test script to run as expected and unexpected errors. Figure 2 As shown, the industry often uses external files to store configuration information and / or page element information to solve this problem, but this method is inefficient. When writing and maintaining automation scripts, all operations that could have been completed in one interface can be completed by introducing external files, which requires opening a second interface to achieve the desired results. This increases the workload of searching for files and switching interfaces during use. Summary of the invention

[0004] The present invention proposes a framework construction method and computing device for storing and using variables, which solves the drawbacks of the native functions of Robot Framework and its supporting Robot Framework RIDE when the amount of configuration information and / or page element information is large, while avoiding the workload generated by searching for files and switching interfaces when storing configuration information and / or page element information through external files.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] A method for constructing a framework for storing and using variables, comprising the following steps:

[0007] S1. Create a first resource file, wherein the first resource file sets a variable category name by creating a new keyword; the variables of the first resource file include configuration information and / or page element information;

[0008] S2. Create a second resource file for automated testing, and import a resource library and a configuration import library into the second resource file, wherein the configuration import library is provided with a preset identifier and a path of the first resource file;

[0009] S3, identifying the configuration import library;

[0010] S4. Load the variables of the first resource file by reading the path of the first resource file of the configuration import library.

[0011] Preferably, step S1 specifically includes:

[0012] S11. Create a new automated test project using Robot Framework RIDE;

[0013] S12, creating a first resource file in the project root directory of the automated testing project;

[0014] S13, setting a variable category name in the first resource file by creating a new keyword, where the variables in the first resource file include configuration information and / or page element information;

[0015] S14. Use table editing mode to edit any variable in the first resource file.

[0016] Preferably, in step S12, the format of the first resource file is txt.

[0017] Preferably, in step S14, the first column of any variable in the first resource file is edited to be an alias of the configuration, and the second column is edited to be the actual value of the configuration.

[0018] Preferably, the input parameter of the configuration import library in step S2 is the file path of the first resource file.

[0019] Preferably, step S3 is specifically as follows: when Robot Framework imports a resource library required for automated testing and loads a library in its source code, if the loaded library is named the configuration import library, then no judgment is made as to whether the library exists or not, and the configuration import library is directly set to exist.

[0020] Preferably, step S4 is specifically as follows: loading the variables of the first resource file into the memory by reading the path of the first resource file of the configuration import library, wherein the keyword input parameters are mapped in the part of the Robot Framework source code that executes the automated test keyword, and when the input parameters exist in the first column of any category in the first resource file, the input parameters are replaced with the values ​​in the same cell of the second column, and the preset logic of the automated test keyword is continued to be executed after the replacement.

[0021] Preferably, in step S4, if there are rows other than two-column rows in the first resource file, the corresponding rows are ignored to avoid processing exceptions caused by certain character strings introduced by the native usage of the Robot Framework resource file.

[0022] Preferably, in step S4, if there is a value in the first column of any category in the first resource file that is repeated with any value in the first column of the current category or other categories, the Robot Framework will directly prompt the existing duplicate value during runtime and terminate the operation of the Robot Framework.

[0023] A computing device comprises: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the above methods.

[0024] After adopting the above technical solution, the present invention has the following advantages compared with the background technology:

[0025] The present invention provides a framework construction method and computing device for storing and using variables. When there are many variables (i.e., configuration information and / or page element information), the tree structure is still simple to operate. There is no need to create a new file when creating a new variable group, and a reminder will be given when variables with the same name exist, thereby solving the problems of low efficiency in using the native functions of Robot Framework and its supporting Robot Framework RIDE and easy calling errors of configuration and page elements. All operations can be completed through one interface, avoiding the workload generated by searching for files and switching interfaces when storing configuration information and / or page element information through external files. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A schematic diagram of a framework constructed for the prior art in the background art;

[0027] Figure 2 It is a schematic diagram of a framework commonly used in the industry to solve the defects of the prior art in the background technology;

[0028] Figure 3 A flowchart of the framework steps for constructing the present invention;

[0029] Figure 4 The figure is a schematic diagram of a framework constructed by the method of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0031] It should be noted that in the present invention, the terms "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside", etc. are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element of the present invention must have a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0032] Example

[0033] Please refer to Figure 3 and Figure 4 As shown, the present invention discloses a framework construction method for storing and using variables, comprising the following steps:

[0034] S1. Create a first resource file, where the first resource file sets a variable category name by creating a new keyword; the variables of the first resource file include configuration information and / or page element information;

[0035] In this embodiment, the page element information is defined as: in the field of automated testing, for web page testing, it is necessary to know the location of each button or input box and other content in the page to be operated and store them in the automated testing script in advance for calling when the script is running. In the field of automated testing, these stored contents are generally referred to as page elements.

[0036] Step S1 specifically includes:

[0037] S11. Create a new automated test project using Robot Framework RIDE;

[0038] S12, creating a first resource file in the project root directory of the automated test project, where the format of the first resource file is txt;

[0039] S13, setting a variable category name in the first resource file by creating a new keyword, where the variable in the first resource file includes configuration information and / or page element information;

[0040] If multiple keywords are created, it represents multiple variable categories, including multiple sets of configuration information and / or page element information. In the case of multiple variable categories, there is always only one first resource file (here, a file can have multiple keywords in its native usage), and there is no need to create a new file to create a new variable category, keeping the tree structure concise and easy to operate.

[0041] S14. Use the table editing mode to edit any variable in the first resource file, wherein the first column of any variable in the first resource file is edited to the configured alias, and the second column is edited to the actual value of the configuration.

[0042] For example, enter Alias ​​1, Alias ​​2, and Alias ​​3 in the first three cells of the first column, and enter Real Value 1, Real Value 2, and Real Value 3 in the first three cells of the second column, so that configuration information and / or page element information can be implemented in the Robot Framework RIDE interface.

[0043] S2. Create a second resource file for Robot Framework automated testing in the root directory of the automated testing project, and import a resource library and a configuration import library into the second resource file. The configuration import library is a non-existent library that is provided with a preset identifier and the path of the first resource file, wherein the file path of the first resource file is used as an input parameter of the configuration import library.

[0044] S3, identify the configuration import library;

[0045] Step S3 is specifically as follows: secondary development is performed on Robot Framework. When Robot Framework imports the resource library required for automated testing, when the library is loaded in its source code, if the loaded library is named configuration import library, no judgment is made as to whether the library exists or not, and the configuration import library is directly set to exist. Except for the newly added configuration import library identification and filtering operations, the other contents of the source code are kept as they are without modification.

[0046] S4. Load the variables of the first resource file by reading the path of the first resource file of the configuration import library.

[0047] Step S4 is specifically as follows: by reading the path of the first resource file of the configuration import library, the variables of the first resource file are loaded into the memory, wherein the keyword input parameters are mapped in the part of the Robot Framework source code that executes the automated test keywords, and when the input parameters exist in the first column of any category in the first resource file, the input parameters are replaced with the values ​​in the same cell of the second column. For example, in the case of the first resource file in step S1, if the input parameter is alias 2, it will be automatically replaced with the real value 2, and the remaining preset logic of the automated test keywords will continue to be executed after the replacement.

[0048] In step S4, if there are rows that are not two-column in the first resource file, the corresponding rows are ignored to avoid processing exceptions caused by certain strings introduced by the native usage of the Robot Framework resource file.

[0049] In step S4, if there is a value in the first column of any category in the first resource file that is repeated with any value in the first column of the current category or other categories, the Robot Framework will directly prompt the existing duplicate value at runtime and terminate the operation of the Robot Framework to avoid the situation where there are multiple variables with the same name without prompting but they are overwritten one by one in the loading order, resulting in the automated test script failing to run as expected and unexpected errors.

[0050] The present invention also discloses a computing device, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs include instructions for executing any of the above methods.

[0051] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for constructing a framework for storing and using variables, characterized in that: The following steps are involved: S1. Create a first resource file, wherein the first resource file sets a variable category name by creating a new keyword; The variables of the first resource file include configuration information and / or page element information; S2. Create a second resource file for automated testing, and import a resource library and a configuration import library into the second resource file, wherein the configuration import library is provided with a preset identifier and a path of the first resource file; S3, identifying the configuration import library; S4, loading the variables of the first resource file by reading the path of the first resource file of the configuration import library; Step S4 is specifically as follows: by reading the path of the first resource file of the configuration import library, the variables of the first resource file are loaded into the memory, wherein the keyword input parameters are mapped in the part of the Robot Framework source code that executes the automated test keyword, and when the input parameters exist in the first column of any category in the first resource file, the input parameters are replaced with the values ​​in the same cell of the second column, and the preset logic of the automated test keyword is continued to be executed after the replacement, and the first resource file includes at least one variable category name.

2. A method for constructing a framework for storing and using variables as claimed in claim 1, characterized in that: Step S1 specifically includes: S11. Create a new automated test project using Robot Framework RIDE; S12, creating a first resource file in the project root directory of the automated testing project; S13, setting a variable category name in the first resource file by creating a new keyword, where the variables in the first resource file include configuration information and / or page element information; S14. Use table editing mode to edit any variable in the first resource file.

3. A method for constructing a framework for storing and using variables as claimed in claim 2, characterized in that: In step S12, the format of the first resource file is txt.

4. A method for constructing a framework for storing and using variables as claimed in claim 2, characterized in that: In step S14, the first column of any variable in the first resource file is edited to be an alias of the configuration, and the second column is edited to be the actual value of the configuration.

5. A method for constructing a framework for storing and using variables as claimed in claim 1, characterized in that: The input parameter of the configuration import library in step S2 is the file path of the first resource file.

6. A method for constructing a framework for storing and using variables as claimed in claim 1, characterized in that: Step S3 is specifically as follows: when Robot Framework imports the resource library required for automated testing, when loading the library in its source code, if the loaded library is named the configuration import library, then no judgment is made as to whether the library exists or not, and the configuration import library is directly set to exist.

7. A method for constructing a framework for storing and using variables as claimed in claim 1, characterized in that: In step S4, if there are rows other than two-column rows in the first resource file, the corresponding rows are ignored to avoid processing exceptions caused by certain character strings introduced by the native usage of the RobotFramework resource file.

8. A method for constructing a framework for storing and using variables as claimed in claim 1, characterized in that: In step S4, if there is a value in the first column of any category in the first resource file that is repeated with any value in the first column of the current category or other categories, the Robot Framework will directly prompt the existence of the repeated value and terminate the operation of the Robot Framework during runtime.

9. A computing device, characterized in that include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any one of the methods according to claims 1-8.

Citation Information

Patent Citations

  • Design method, device and terminal of test case and readable storage medium

    CN108304329A

  • A software defect automatic detection method based on an open source code library

    CN109697162A