*** Settings ***
Library RequestsLibrary
Library Collections
Library XML *** Test Cases ***
case1
Create Session api http://localhost:8000
${addr} Get Request api users/1
Should Be Equal As Strings ${addr.status_code} 200
Log ${addr.content}
${responsedata} To Json ${addr.content}
${keys} Get Dictionary Keys ${responsedata}
${items} Get Dictionary Items ${responsedata}
${values} Get Dictionary Values ${responsedata}
${str} Get From Dictionary ${responsedata} 1
${addr} Get Request api users/5
Should Be Equal As Strings ${addr.status_code} 404
Log ${addr.content}
${responsedata} To Json ${addr.content}
${keys} Get Dictionary Keys ${responsedata}
${items} Get Dictionary Items ${responsedata}
${values} Get Dictionary Values ${responsedata}
${str} Get From Dictionary ${responsedata} message
Delete All Sessions case2
Create Session api http://localhost:8000
${addr} Get Request api hello/qitao
Comment Should Be Equal As Strings ${addr.status_code} 200
Log ${addr.content}
${responsedata} To Json ${addr.content}
${keys} Get Dictionary Keys ${responsedata}
${items} Get Dictionary Items ${responsedata}
${values} Get Dictionary Values ${responsedata}
${str} Get From Dictionary ${responsedata} hello
#xml方式
${dict} Create Dictionary accept=application/xml
${addr} Get Request api hello/qitao ${dict}
Comment Should Be Equal As Strings ${addr.status_code} 200
Log ${addr.content}
${responsedata} Set Variable ${addr.content}
${body} Get Element Text ${responsedata} hello
${hello} Get Element ${responsedata} hello
Log ${hello.text}
${responsedata} Add Element ${responsedata} <new id="3">test</new>
${new} Get Element Attribute ${responsedata} id new
Log ${new}
${a} Element To String ${responsedata}
Delete All Sessions case3
#用户密码
${auth} Create List ok python
Create Session api http://localhost:8000 \ \ ${auth}
${addr} Get Request api 401
Comment Should Be Equal As Strings ${addr.status_code} 200
Log ${addr.content}
${responsedata} To Json ${addr.content}
${keys} Get Dictionary Keys ${responsedata}
${items} Get Dictionary Items ${responsedata}
${values} Get Dictionary Values ${responsedata}
${str} Get From Dictionary ${responsedata} pass
Delete All Sessions case4
${dict} Create Dictionary Content-Type=application/x-www-form-urlencoded
Create Session api http://localhost:8000 ${dict}
${data} Create Dictionary username=qitao password=qt
${addr} Post Request api post data=${data}
Comment Should Be Equal As Strings ${addr.status_code} 200
Log ${addr.content}
Log ${addr.json()}
${responsedata} To Json ${addr.content}
${keys} Get Dictionary Keys ${responsedata}
${items} Get Dictionary Items ${responsedata}
${values} Get Dictionary Values ${responsedata}
${str} Get From Dictionary ${responsedata} username
Delete All Sessions

Post请求示例:

Post Requests
[Tags] post
Create Session httpbin http://httpbin.org
&{data}= Create Dictionary name=bulkan surname=evcimen
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
${resp}= Post Request httpbin /post data=${data} headers=${headers}
Dictionary Should Contain Value ${resp.json()['form']} bulkan
Dictionary Should Contain Value ${resp.json()['form']} evcimen

  

rf-demos (request)的更多相关文章

  1. FLASK 的Session和MoudelForm插件

    falsk是小而精的框架,但是热度高, 所有很多爱好者提供了很多扩展插件 功能强大,美而不足的就是兼容稳定性有时候不太好,不过大部分还是很可以的 Flask-Session flask内置sessio ...

  2. laravel文件上传(本人使用的ftp驱动配置,本地测试总结)

    1.电脑端在:控制面板->程序和功能->打开和关闭Window功能,安装:Internet信息服务的(Ftp服务器,web管理工具的IIS管理服务,万网服务的常见http功能) 2.在电脑 ...

  3. 转:攻击JavaWeb应用[8]-后门篇

    转:http://static.hx99.net/static/drops/tips-662.html 攻击JavaWeb应用[8]-后门篇 园长 · 2013/10/11 19:19 0x00 背景 ...

  4. Flask(5)- Flask-Session组件、WTForms组件、数据库连接池(POOL)

    一.Flask-Session 我们使用过flask内置的session,知道它是把session存放在浏览器,即客户端.今天要学习的flask-session是flask的第三方组件,看一下它和fl ...

  5. 11,flask之--WTForms

    WTForms是什么? 相当于django的ModelForm. 在网页中,为了和用户进行信息交互总是不得不出现一些表单.flask设计了WTForm表单库来使flask可以更加简便地管理操作表单数据 ...

  6. 两种“新型”的javaweb后门(jspx和Java Logger)

    利用这个可以突破st2下   强制jsp跳转login.jsp 利用jspx解决jsp后缀被限制拿shell - Hack Blog | 黑客博客http://www.hackblog.cn/post ...

  7. flask(四)

    1.Flask-Session from flask import session,Flask from flask_session import Session #导入 from redis imp ...

  8. flask flask_session,WTForms

    一.Flask_session 本质上,就是是cookie 下的session存储在redis中,方便快速取得session from flask import Flask,session from ...

  9. flask(3.0)

    目录 一.Flask - CBV 二.Flask - Session 1.安装flask-session 2.回顾flask自带的session的使用方法 3.flask-session的使用(以保存 ...

  10. robotframework之使用cookies登陆

    有的系统是使用cookies保持登陆的,而RF的Request库里面没有像Selenium2Library里面一样操作cookies的关键字,若接口需要登录则只能用UI自动化先登录,然后再将cooki ...

随机推荐

  1. 以前刷过的数位dp

    TOJ1688: Round Numbers Description The cows, as you know, have no fingers or thumbs and thus are una ...

  2. oracle中xhost报错

    一.命令找不到 xhost:command not found yum whatprovides "*/xhost" Loaded plugins: product-id, sec ...

  3. CodeForces839D[莫比乌斯反演] Codeforces Round #428 (Div. 2)

    /*CodeForces839D[莫比乌斯反演]*/ #include <bits/stdc++.h> typedef long long LL; const LL MOD = 10000 ...

  4. 洛谷P2664 树上游戏 【点分治 + 差分】

    题目 lrb有一棵树,树的每个节点有个颜色.给一个长度为n的颜色序列,定义s(i,j) 为i 到j 的颜色数量.以及 现在他想让你求出所有的sum[i] 输入格式 第一行为一个整数n,表示树节点的数量 ...

  5. vim 翻页命令记录

    vim命令: ctrl-f:往前翻一页(forward) ctrl-b:往后翻一页(backward) ​ ctrl-d:往下翻半页(down) ctrl-u:往上翻半页(up) ​​​

  6. 瞄一眼CopyOnWriteArrayList(jdk11)

    CopyOnWriteArrayList是ArrayList线程安全的变体.使用写时复制策略进行修改操作. 与之前版本较明显的区别是,jdk11中用来保护所有设值方法(mutator)的Reentra ...

  7. js中的clientHeight和offsetHeight的区别如

    如图所示:

  8. python time模块 sys模块 collections模块 random模块 os模块 序列化 datetime模块

    一 collections模块 collections模块在内置的数据类型,比如:int.str.list.dict等基础之上额外提供了几种数据类型. 参考博客 http://www.pythoner ...

  9. linux shmget shmctl

    shmgetint shmget(key_t key, size_t size, int flag);key: 标识符的规则size:共享存储段的字节数flag:读写的权限返回值:成功返回共享存储的i ...

  10. C/C++程序编译运行过程分析(转载)

    为了减轻使用机器语言编程的痛苦,人们进行了一种有益的改进:用一些简洁的英文字母.符号串来替代一个特定的指令的二进制串,比如,用“A D D”代表加法,“M O V”代表数据传递等等,这样一来,人们很容 ...