Forum Discussion
Solved
3 Replies
Sort By
- HimanshuTayalCommunity Hero
rajs2020 : Yes it is possible to get the request and response of any test step refer below code sample:
def request = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Request") def response = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Response") log.info request log.info response
Let me know in case more help you needed.
- rajs2020Frequent Contributor
- rajs2020Frequent Contributor
I realized that there is another, more common way to access the request/response via the UI options.
Open groovy script > Right click > Get data > Select the test case step which has the API call > Select request/response etc.def request = context.expand( '${YourAPICallStep#Request}' )
The "request" is type of class java.lang.String. To convert a Json string to groovy objects, we can use JSON slurper library - https://groovy-lang.org/json.html.