一、介绍
Robot Framework 相关介绍CSDN
二、安装依赖库
在robot当中,python语言接口测试库为RequestsLibrary ;
pip install -U requests
pip install -U robotframework-requests
在robot编辑工具中,创建 test suites,并在 Settings 区域点击 Library 按钮引入:
三、RequestsLibrary 关键字
RequestsLibrary 有22个关键字;其中 get、post、head、options、patch、put、delete这7个关键字系统中将被废弃;get request、post request、head request、options request、patch request、put request、delete request这7个关键字来代替他们。
Requests关键字可以分为三类:一类:与服务端的会话。包含 Create Session 创建会话、update session 更新会话、Delete all session 删除会话。二类:请求类型。get requests等发送请求的关键字。三类:响应结果转json:To json关键字。将json字符串转换成python对象。
四、测试流程
1、Create Session,创建一个与对应的服务器地址的连接会话,并设置别名;供后面的请求使用,以保持会话状态。
2、发送GET请求到首页,并且将响应赋值给变量${response}。
3、对首页进行简单的断言,
4、将响应的内容输出到日志信息中,便于调试时查看。