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 ...
随机推荐
- [gazebo-1] process has died [pid 22855, exit code 255,
[gazebo-1] process has died [pid 22855, exit code 255, cmd /opt/ros/kinetic/lib/gazebo_ros/gzserver ...
- Blog Part I
写随笔是不可能写的,这辈子都不可能写的. ——https://music.163.com/song?id=5039077 ============ Blog?不,并不擅长,毕竟Blog不是Novel, ...
- mysql几种关联的区别
1.平时都是用的逗号的模式:select * from a,b where a.id=b.id,逗号的模式等于inner join和join: 2.left join 和 right join相反,效 ...
- XBee 802.15.4/Digimesh FAQs:如何为2.4G模块选择合适的信道
XBee 802.15.4模块和XBee Digimesh模块在硬件上完全相同,只是出厂带有不同固件,如果测试需要,这两个固件可以都可以互换烧入模块中. 如何为2.4G模块选择合适的信道 IEEE 8 ...
- 20155312 张竞予 Exp2 后门原理与实践
Exp2 后门原理与实践 目录 基础问题回答 (1)例举你能想到的一个后门进入到你系统中的可能方式? (2)例举你知道的后门如何启动起来(win及linux)的方式? (3)Meterpreter有哪 ...
- spring boot + vue + element-ui全栈开发入门
今天想弄弄element-ui 然后就在网上找了个例子 感觉还是可以用的 第一步是完成了 果断 拿过来 放到我这里这 下面直接是连接 点进去 就可以用啊 本想着不用vue 直接导入连接 ...
- Win7 VS2017 NASM编译FFMPEG(2018.12.22)
今天无意中在gayhub发现个牛逼工程,全VS工程编译FFMPEG库,包括依赖库全是VS生成的,无需Mingw等Linux环境. 简单记录下过程,以防将来重装系统等情况,备忘. https://git ...
- vue中引入vux
1.安装相关依赖 cnpm install vux --save cnpm install vux-loader --save-dev cnpm install less less-loader -- ...
- 我的Unity学习笔记之——Unity中从网站下载ab资源+下载存储一条龙
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Net ...
- LwIP-网络接口管理
netif 各种类型网络接口的抽象------------------netif.c netif.h ————netif.h————————————————//网络接口最大物理地址长度,这 ...