How to TRANSFER the result of Scripted Assertion in SOAP UI 5.4.0 as input to next request
Hi there,
I retrieved the OTP sent to an email. Successfully truncated the snippet from the SOAP UI Json response and saved the OTP as a variable in scripted assertion within SOAP UI 5.4.0. The problem is I'm not able to transfer the OTP as a property so i can use it as input for next request (chaining request). Really appreciate if you can help me with this.
Hi,
It looks like you are mixing up Groovy Script step with a Script Assertion.
Script Assertion is a means of validating the API response.
Groovy script step basically allows you to do anything you want.
Script Assertions typically contain some sort of check. E.g.
// Just a var for example sake, but usually somehting from the response. def animal = "Cat'; assertEquals("Cat", animal); // This should assert to true. assertEquals("Dog", animal); // This should assert to false. E.g. failed test.
Your script assertion does not contain a check and based on the requirement, I think it should be a Groovy Script step.
Copy your code into a Groovy Script step add the following to the end of script....
// Let's return the value we have for use elsewhere... return OTP;
For the view where you can see your test steps, you should be able to double-click the Groovy script and you should get a response in a modal window.
Now, how to use in another step. You can do property transfers and stuff like that, but my preference is to 'pull' the required value into the step it is needed in.
In the test step you want to use the value, you can pull in the OTP from the Groovy script by doing something like this....
${MyGroovyStep#result}
For context and how this actually looks in SoapUI, have a look at this other solution I posted... Passing-the-SOAP-Request-from-File
Hi, Thanks for the steer. Able to achieve my intended o/p. Much Appreciated. 🙂