Robot Framework - 3 - 测试库API
08- 创建测试库--发布测试库
***** 测试库文档
***** 对测试库进行测试
***** 打包测试库
***** 不推荐的关键字
示例: LibraryExampleD.py
# -*- coding: utf-8 -*-
###发布测试库
class LibraryExampleD():
#测试库文档
"""This is an example library with some documentation."""
def keyword_with_short_documentation(self, argument):
"""This keyword has only a short documentation"""
pass
def keyword_with_longer_documentation(self):
"""First line of the documentation is here.
Longer documentation continues here and it can contain
multiple lines or paragraphs.
"""
pass
#不推荐的关键字
def example_keyword(argument):
"""*DEPRECATED* Use keyword `Other Keyword` instead.
This keyword does something to given `argument` and returns the result.
"""
09- Robot Framework 的测试库 API
10- 创建测试库-- 动态测试库
***** 获取关键字的名称
***** 运行关键字
***** 获取关键字的参数
***** 获取关键字的文档
***** Remote
示例: LibraryExampleE.py
# -*- coding: utf-8 -*- ###动态测试库 class LibraryExampleE(): #获取关键字名称
def get_keyword_names(self):
return ['first keyword', 'second keyword']
#运行关键字
def run_keyword(self, name, args):
print "Running keyword '%s' with arguments %s." % (name, args)
#获取关键字的参数
def get_keyword_arguments(self, name):
return ['*arguments']
#获取关键字的文档
def get_keyword_documentation(self, name):
return """This is an example Dynamic library with some documentation."""
11- 创建测试库-- 混合测试库
***** 获取关键字的名称
***** 运行关键字
***** 获取关键字的参数和文档
***** 小结
***** Telent
示例: LibraryExampleF.py
# -*- coding: utf-8 -*-
#混合测试库 import LibraryExampleFlib class LibraryExampleF():
"""This is an example Dynamic library with some documentation."""
#获取关键字名称
def get_keyword_names(self):
return ['my_keyword','external_keyword']
#运行关键字
def my_keyword(self, arg):
print "My Keyword called with '%s'" % arg
#__getattr__方法
def __getattr__(self, name):
if name == 'external_keyword':
return LibraryExampleFlib.hello
raise AttributeError("Non-existing attribute '%s'" % name) LibraryExampleFlib.py
def hello():
print "Hello, world!"
def Nothing():
pass
12- 创建测试库-- 使用 Robot Framework 内部模块
示例: LibraryExampleG.py
# -*- coding: utf-8 -*- ###使用RobotFramework内部模块 import os.path
from robot.libraries.BuiltIn import BuiltIn class LibraryExampleG(): def do_something(argument):
output = 'do_something_that_creates_a_lot_of_output(argument)'
outputdir = BuiltIn().replace_variables('${OUTPUTDIR}')
path = os.path.join(outputdir, 'results.txt')
f = open(path, 'w')
f.write(output)
f.close()
print '*HTML* Output written to <a href="results.txt">results.txt</a>'
13- 创建测试库-- 扩展已存在的测试库
***** 修改原始代码
***** 继承
***** 直接使用其他测试库
***** 从 Robot Framework 中获取活动的测试库实例
***** 使用动态库或者混合库 API 的测试库
Robot Framework - 3 - 测试库API的更多相关文章
- Robot Framework自定义测试库的作用域的理解
robot framework中,强大的测试库api支持,用户可根据实际需求定义测试库,导入后可使用自定义库中相应的关键字. 当自定义的测试库是类库,则需要考虑一个问题:类实例.用类实现的库可以有内部 ...
- Robot Framework 自动化测试 Selenium2Library 库 用法
Robot Framework自动化测试Selenium2Library库详细用法 一.浏览器驱动 通过不同的浏览器执行脚本. Open Browser Htpp://www.xxx.com ...
- 使用远程接口库进一步扩展Robot Framework的测试能力
引言: Robot Framework的四层结构已经极大的提高了它的扩展性.我们可以使用它丰富的扩展库来完成大部分测试工作.可是碰到下面两种情况,仅靠四层结构就不好使了: 1.有些复杂的测试可能跨越多 ...
- Robot Framework(Collections 库)
Collections 库 Collections 库同样为Robot Framework 标准类库,它所提供的关键字主要用于列表.索引.字典的处理. 在使用之前需要在测试套件(项目)中添加:
- robot framework自定义python库
自定义python库的好处: robot framework填表式,将python的灵活性弄没了,但是不要担心,RF早就想到了解决办法,就是扩充自己的库. 1.在python应用程序包目录下创建一个新 ...
- Robot Framework(Databaselibrary库操作)
1.安装 DatabaseLibrary 库 DatabaseLibrary 下载地址:https://pypi.python.org/pypi/robotframework-databaselibr ...
- Robot Framework(Screenshot 库)
Screenshot 库 Scrennshot 同样为 Robot Framework 标准类库,我们只将它提供的其它中一个关键字“TakeScreenshot”,它用于截取到当前窗口.虽然 Scre ...
- Robot Framework web测试demo
1.Open RIDE: ride.py 2.New Project: "File" -> "New Project" ,click "OK&q ...
- Robot Framework自动化测试Selenium2Library库详细用法
一.浏览器驱动 通过不同的浏览器执行脚本. Open Browser Htpp://www.xxx.com chrome 浏览器对应的关键字: firefox FireFox ff internete ...
随机推荐
- JS的深浅拷贝
项目中根据各种需求或多或少会需要用到拷贝,通过查询整理之后今天简单的记录一下. 我们可以利用 slice.concat 返回一个新数组的特性可以实现数组的拷贝. var arr = ['a', 1, ...
- centos服务器监控 服务器虚拟机里面的客户端zabbix-agent安装
开启zabbix要用的端口, 也可以关闭服务器的防火 [html] view plain copy #vim /etc/sysconfig/iptables -A INPUT -m state --s ...
- Numpy 数据类型
numpy支持的数据类型比Python内置的类型多很多,基本上可以和C语言的数据类型对应上, 其中部分类型对应为Python内置的类型.下表列举了常用的Numpy基本类型. 名称 描述 bool_ 布 ...
- Linux 安装源码软件
linux下,源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install) 过程中用到configure --prefix --with:其中--pr ...
- MIUI通过xposed自动设置root权限
在小米手机上,每次安装一个自己的插件总需要打开安全中心进行root权限授权,非常的麻烦,总共需要电5次确认,每次需要等5秒 因为插件开发的需求,希望重启计算机时候判断是否已经root,未root则自动 ...
- 201771010142 张燕& 杨蓉庆 实验十一 集合
实验十一 集合 实验时间 2018-11-8 一 理论知识 一般将数据结构分为两大类:线性数据结构和非线性数据结构.线性数据结构:线性表.栈.队列.串.数组和文件.非线性数据结构:树和图. 线性 ...
- Cbv源码简单分析图
重点:cbv源码的简单分析(有后续)
- Forward团队-爬虫豆瓣top250项目-开发文档
项目地址:https://github.com/xyhcq/top250 我在本次项目中负责写爬虫中对数据分析的一部分,根据马壮分析过的html,我来进一步写代码获取数据,具体的功能及实现方法我已经写 ...
- linux使用framebuffer的代码
#include <linux/fb.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <st ...
- sqoop错误集锦2
1.使用sqoop技术将mysql的数据导入到Hive出现的错误如下所示: 第一次使用命令如下所示: 1 [hadoop@slaver1 sqoop-1.4.5-cdh5.3.6]$ bin/sqoo ...