Robot Framework 自定义library

来源:互联网 发布:淘宝买手机流量 编辑:程序博客网 时间:2024/06/05 16:22

我们常常需要使用一些自定义的库文件来满足一些特别的需求,这时候我们可以可以写一些代码来拓充库。
这就是自定义library。下面将以python为语言基础一步一步介绍怎么自定义library

1、在安装python的路径下找到\Lib\site-packages中新建自定义library文件夹。如:CustomLibrary

这里写图片描述

2、在文件夹中创建Python文件即.py文件,与类名一致(重要)

这里写图片描述

3、新建一个init.py文件。文件内容为:其实里面只有四句是有效的。其他都是注释

#  Copyright (c) 2010 Franz Allan Valencia See##  Licensed under the Apache License, Version 2.0 (the "License");#  you may not use this file except in compliance with the License.#  You may obtain a copy of the License at##      http://www.apache.org/licenses/LICENSE-2.0##  Unless required by applicable law or agreed to in writing, software#  distributed under the License is distributed on an "AS IS" BASIS,#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.#  See the License for the specific language governing permissions and#  limitations under the License.from Runbat import Runbatversion = '1.0'class CustomLibrary(Runbat):    """    这里也可以装x的写上我们创建的CustomLibrary如何如何。    """    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

4、打开IDLE,导入自定义library

这里写图片描述
导入完成后,按F5后再soure中可以找到自定义的library
这里写图片描述
关于使用这里就 不讲了~~

0 0
原创粉丝点击