Forum Discussion
Not much familiar with Json Path along with Property Transfer. I would prefer to do it using Script Assertion for the first request test step.
The following Script Assertion would fetch the required value and set the value test case level custom property and access the value using property expansion in the following test steps.
assert context.response, "Response is empty of null" def parsedJson = new groovy.json.JsonSlurper().parseText(context.response) log.info "Retrieved sms code : ${parsedJson.sms_code}" assert parsedJson.sms_code, "sms code is null or empty in the response" context.testCase.setPropertyValue('SMS_CODE', parsedJson.sms_code.toString())
In the following request, use ${#TestCase#SMS_CODE} where you needed that value.
And regarding your 2nd question, please refer the below script which is done some time for similar requirement.
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/AddCookiesToNextRequest.groovy
I've tried your way and it doesn't work. I think that I specified it in an incorrect place.
Could you please clarify this moment?
- nmrao8 years agoChampion Level 3It was clearly mentioned that you need to use the provided script as "Script Assertion" for the request step where you get the response, no additional "groovy script" test step is needed.
- Titanium228 years agoOccasional Contributor
I've got the problem. Thanks. Now it works.
And what can be the reason of this behavior? Why "phone" property is not moved to request? - http://joxi.ru/VrwlzEXuO7NZLm
- PaulMS8 years agoSuper Contributor
Titanium22
At first glance, you need to specify the JSONpath expression to use the phone data from a previous request message
${Teacher_Create#Request#$.phone}
or
${Teacher_Create#Request#$['phone']}
Related Content
- 5 years ago
- 2 years ago
Recent Discussions
- 11 days ago