Assuming the installation path of python is under D: /
Step 1: Create a library file folder MyLibrary in D: / python / Lib / site-packages
Step 2: Create mytool.py file in MyLibrary
This file writes the keyword method that you need to wear. The following code has a method for comparing the size of the two parameters, which will be used as a keyword in Robot Framework.
# coding = utf-8 class mytool (): def __init __ (self): pass def test_a_b (self, a, b): '' ' Compare the size of two parameters ' '' if a> b: flag = False return flag else: flag = True return flag
Step 3: Create __init__.py file in MyLibrary
The following file content template, pay attention to the class name and library folder name
# coding=utf-8 from mytoolimport mytool version = '1.0' class MyLibrary(mytool): ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LIBRARY_SCOPE = 'GLOBAL' means that the library is global
version = '1.0' version definition
The fourth step: import the library in RIDE, see the blog for the import steps:
RobotFramework library file import http://my.oschina.net/hibony/blog/664995
Step 5: Custom use
After the import is complete, we can press F5 to Search Keywords in Ride keyboard, source select the library we just imported, we will see the introduction of all the methods in our library in the panel
operation result
Look back at the content of the method we wrote and see if the result is correct!