*** Settings ***
Library RequestsLibrary
Library Collections
Library String
Library HttpLibrary.HTTP
*** Keywords ***
Request_Post
[Documentation] 通用post请求
[Arguments] ${host} ${path} ${datas} ${params} ${headers}=None ${cookies}=None ${timeout}=30
# 处理请求header
${header_dict} Create Dictionary Content-Type=application/json
Log ${header_dict}
Run Keyword If ${headers}==${None} Log 没有添加自定义header
... ELSE Run Keyword add_header ${headers} ${header_dict}
# 处理cookies
${cookies_dict} Create Dictionary
Run Keyword If ${cookies}==${None} Log 没有添加cookies信息
... ELSE Run Keyword add_cookies ${cookies} ${cookies_dict}
# 创建session
Create Session TZ_robotframework ${host} timeout=${timeout} cookies=${cookies_dict} verify=False
# 发起post请求
${resp} Post Request TZ_robotframework ${path} data=${datas} headers=${header_dict} params=${params}
[Return] ${resp}
Request_Get
[Documentation] 通用get请求
[Arguments] ${host} ${path} ${datas} ${params} ${headers} ${cookies}=None ${
robotframework接口自动化之get/post请求
最新推荐文章于 2022-12-16 14:30:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)