标签:framework url get header robot headers json host path
使用rf调用 get、post接口,可以先定义好 对应的关键字,后面直接使用
关键字如下:
一、 set login headers
入参为 cookie,如果没有,传 {}
1 [Arguments] ${cookies} 2 ${loginheader} Evaluate json.loads('{"User-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36","Content-Type":"application/json;charset=UTF-8","Connection":"keep-alive","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest","Content-Length":"72","cache-control":"no-cache","Accept-Language": "zh-CN,zh;q=0.9"}') json 3 ${header} Create Dictionary Cookie=${cookies} 4 log ${header} 5 ${header} Evaluate dict(${header},**${loginheader}) 6 [Return] ${header}
二、http-post
1 [Arguments] ${host} ${path} ${postdata} ${headers} 2 Create Session url ${host} ${headers} 3 ${data} Evaluate json.loads('${postdata}') json 4 ${res} Post Request url ${path} ${postdata} 5 Delete All Sessions 6 [Return] ${res.content}
三、http-get
1 [Arguments] ${host} ${headers} ${path} ${getdata}=None 2 Create Session url ${host} 3 ${res} Get Request url ${headers} ${path} ${getdata} 4 Delete All Sessions 5 [Return] ${res.content}
四、调用
结果如下:
标签:framework,url,get,header,robot,headers,json,host,path 来源: https://www.cnblogs.com/whycai/p/12234312.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。