Cannot get parameter to pass through
I have a test shown in the screenshot. Its data driven and requires several API's to be hit to collect the right ID's to then make the final request.
In the below code (From the parameters groovy step), I get the 'expectedMatchingValue' from the TestData step.
I then get the response from the call made in the 'GetTest' step.
I then try to look at this response and find the ID that matches the value of the 'expectedMatchingValue' ('TestName').
I cannot get it to work though. It always returns a blank value.
I can make it work if I add an assertion step with the 'Gettest' call, but its not a true assertion so trying to split it out and put it into its own Groovy step.
ANy help is really appreciated.
/** * Script Assertion for REST Request test step **/ //Change the value for below statement as needed def name = context.expand( '${EditTestData#Name}' ) def expectedMatchingvalue = name assert context.'${GetTest#Response}', 'Response is empty or null' //def json = new groovy.json.JsonSlurper().parseText(context.response) def json = new groovy.json.JsonSlurper().parseText(context.'${GetTest#Response}' ) context.testCase.setPropertyValue('TESTIDNEW', json.value.find {it.TestName == expectedMatchingvalue}?.Id?.toString())
Hey endorium
in the line
assert context.'${GetTest#Response}', 'Response is empty or null' //def json = new groovy.json.JsonSlurper().parseText(context.response)
aren't you missing the word a word after 'context.' in the assertion?
e.g.
assert context.expand('${GetTest#Response}'), 'Response is empty or null' //def json = new groovy.json.JsonSlurper().parseText(context.response)
??
ta,
rich