Forum Discussion
Hi 4nes-team ,
one loop can resolve your question. But I did not see a complete JSON response, assume that you get a response with a list. Run your test case
/**
* TEST CASE
* REST STEP
* GROOVY STEP
*/
import groovy.json.JsonSlurper
def teststep = testRunner.testCase.testSteps['REST STEP']
// get REST response
def response = teststep.testRequest.response.contentAsString // context.expand( '${REST STEP#Response}' )
def json = new JsonSlurper().parseText(response)
// assume you get a list named "MyNode"
if (json.MyNode.any {it.reasonCode == 'EM_004}) {
testRunner.gotoStepByName("Next Step")
} else {
Thread.sleep(1000) // set your delay time
testRunner.gotoStepByName("REST STEP")
}
Thanks,
/Aaron
- 4nes-team4 years agoOccasional Contributor
Hi Aaron,
thank you for your quick reply.
I tried to implement your code into my testcase but apparently I'm doing something wrong. Could you take a look? You can see the error in the screenshot I attached.
Thanks again.
4nes team
- 4nes-team4 years agoOccasional Contributor
Hi,
is there any possibilty to get an answer to my question? I really hope that there is a solution to my issue.
Thanks.
Best regards,
4nes team
- aaronpliu4 years agoFrequent Contributor
Hi 4nes-team ,
No more workaround to support you since I did not get anything from your attachment. I attached groovy script that is groovy GDK built-in package, no need other dependency. So you should not run into those weird issue.
Can you please paste more details if possible? Maybe community would help you figure it out.
I did not login community all the time as I have a new project to work on now. Whatever, will go through all of new update and try to answer questions if I can.
Thanks
/Aaron
Related Content
- 10 years ago