Forum Discussion

SankarB's avatar
SankarB
Occasional Contributor
7 years ago

How to pass the o/p value of groovy script to another API as input

Hi All,

 

Need a small help in fetching the value.

i am fetching the value required using groovy. Now i need to pass the output value of groovy script as input to the other API. I have tried in the below way:- Project->test suite-> test case -> selected the groovy script -> result -> i am not to fetch the value which it has displayed in the "log output". Unable to fetch the actual result. It would be great-full if you can provide the solution.

 

Even i have tried with property transfer. In that i am getting the null value.

Can any one please provide the solution to overcome this.

 

Regards,

Sankar

3 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    If you need to store the result produced by a groovy script, I find the best way is to store it as a property.

     

    Example: To store it in a Properties test step in the same test case:

    context.testCase.testSteps["Properties Test Step Name"].setPropertyValue("PropertyName", "PropertyValue");

    You can expand upon this to store it at the test case, test suite, or project level as well. Hope that helps!

  • nmrao's avatar
    nmrao
    Champion Level 3
    SankarB, show your script which is causing the issue. Also show your request where the value needs to be set.