[英]Gatling: How to pass value in next request when previous request doesn't have JSON response?
Please consider the scenario... Here, in GET request I found 'derId' but it's response is not JSON. 请考虑这种情况...在这里,在GET请求中我找到了'derId',但它的响应不是JSON。 So I am not able to save this value in that request.
因此,我无法在该请求中保存此值。
.exec(http("OnClick")
.get("/url/apz?action_id=1&SelectRadiobutton=1_${abcID}_${xyzID}_${zipID}")
.headers(headers_1))
.pause(2)
.exec(http("PopUp")
.post("/url/dis")
.headers(headers_1)
.formParam("action_id", "2")
.formParam("abcId", "${abcID}")
.formParam("rmft", "${rmftID}")
.formParam("msg_id", "${msgID}")
.formParam("matId", "${matID}"))
.pause(1)
.exec(http("Bananana")
.post("/url/abc")
.headers(headers_1)
.formParam("abcId", "${abcID}")
.formParam("msg_id", "${msgID}")
.formParam("matId", "${matID}")
.formParam("derId", "${??}"))
Is there any method or way to pass the value in next request from GET request??? 有什么方法或方法可以在GET请求的下一个请求中传递值???
Or 要么
How to save a value, when a request doesn't have JSON response??? 当请求没有JSON响应时,如何保存值?
Can a GET request have JSON response??? GET请求可以具有JSON响应吗???
Your help will be much appreciated. 您的帮助将不胜感激。
Thanks! 谢谢!
By using regex method, we can save values from jsp page (not json). 通过使用regex方法,我们可以保存jsp页面(而不是json)中的值。
for example: 例如:
.check(regex("""type="hidden" name="abcId" id="abcId" value="([\w=\/.\d_%+-.$]*)"""").saveAs("abcID"))
Thanks! 谢谢!
I was able to use this answer ( https://stackoverflow.com/a/40736282/9371636 ) from a similar question to make a request, then another request with an input parameter that came from the JSON response of the first request. 我能够使用类似问题中的这个答案( https://stackoverflow.com/a/40736282/9371636 )发出请求,然后发出另一个输入参数来自第一个请求的JSON响应的请求。
Example API I'm testing with: 我正在测试的示例API:
/step1 -> returns { "key": 888 }
/step2/{key} -> returns { "key": 999 } if {key} passed in is == 888
Scala Code: Scala代码:
var step1 = exec(http("step1")
.get("/step1")
.check(jsonPath("$..key").optional.saveAs("key")))
var step2 = exec(http("step2")
.get("/step2/${key}"))
val scn: ScenarioBuilder = scenario("SimulationName").exec(step1,
doIf(session => session.contains("key")) {
exec(step2)
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.