我正在尝试运行一个脚本,postman在该脚本中发送Get请求,如果get响应包含某个变量,则运行Post请求。我该怎么做呢?
(还有没有办法每小时运行一次get请求)
发布于 2021-09-29 08:47:44
在先决条件添加中:
// set initial value
const method = pm.variables.get("method")
// set initial value as GET if method is undefined
method ? null : pm.variables.set("method", "GET")
// Set this as method
pm.request.method =method
在测试脚本中添加:
// the condition check
if (pm.response.json().somevalue === "somevalue") {
//then change the method
pm.variables.set("method", "POST")
//call the same request again using setNExtRequest
// pm.info.reqeustName gives current request's name
postman.setNextRequest(pm.info.requestName)
}
https://stackoverflow.com/questions/69369917
复制相似问题