开发robot framework系统关键字

上一篇 / 下一篇  2017-07-12 14:43:40 / 个人分类:RF

参考自:http://www.2cto.com/kf/201705/636177.html

   首先在安装目录\Python27\Lib\site-packages下创建Custom文件夹,用于放置自定义的库。在其下面创建addtest.py 文件:
#-*- coding:utf-8 -*-
 
__version__ = '0.1'
 
 
class AddTest(object):
 
    def run_add(self, A, B):
        u'''
            | A | B | 
        '''     
        return A+B
 
    def decode(self,customstr):
        u"""
            convert to utf8
        """
        return customstr.decode('utf-8')

同目录下创建__init__.py文件
#coding=utf-8
from addtest import AddTest
 
 
__version__ = '0.1'
 
class Custom(AddTest):
 
 
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

下面导入自定义库
点击测试套件,在Edit面板点击Library,在弹出窗口Name行输入Custom,点击确定。如果成功导入,显示是黑色字体,如果导入失败,是红色字体。点击Tools -> View RIDE log可以看到导入失败的原因。因为之前在__init__.py文件中没有写#coding=utf-8,所以导入失败提示(unicode error) 'utf8' codec can't decode byte 0xbb

成功导入自定义库后,按F5,可以在source下拉框中看到已经导入的库

TAG:

 

评分:0

我来说两句

Open Toolbar