Forum Discussion
aaronpliu - Thanks for your reply. Some questions.
def teststep = testRunner.testCase.testSteps['Your Test Step']
def responseStatus = teststep.testRequest.response.responseHeaders["#status#"]
1) Could you please point me to the official documentation on these classes and functions like testRunner etc.?
2) Is there a table of keywords to use for other headers besides "#status#"?
3) Like the headers, can I easily access body also, maybe like this -
teststep.testRequest.response.body(Json path query to get a field)
Hi rajs2020
Answer your questions:
A1: Go to smartbear official online document to look for API docs of ReadyAPI (SoapUI)
A2: responseHeaders return a map object, you can output this object and to see which info would be access
A3: Since you already get response object, can directly get response body (e.g.
def responseBody = teststep.testRequest.response.contentAsString
if you get response body, then using JsonSluper (if it is json response) to parse it, you can retrieve any node / value under json object.
For example:
json data: {“a": {"b": [{"c": 1, "d": 2}]}}
import groovy.json.JsonSlurper
def json = new JsonSlurper().parseText(responseBody)
// output b
log.info json.a.b
// output value of b
for (def x in json.a.b) {
log.info x
}
Thanks,
/Aaron
Related Content
- 4 years ago