Forum Discussion

doubtsreadyapi's avatar
doubtsreadyapi
Contributor
5 years ago

Groovy script for executing the next step depending on the previous response parameter

Hi, 

 

I am running a testsuite in readyAPi, I am doing a GET  method Request , In GET method response i have response parameter Status, Until the status value is changed to completed i dont want to execute the next test step in the suite. The value of status will be changing after a certain time(there is no fixed time for the status to change to complete since in background some process will be running once those are completed then the status will be changing to complete)

 

So, in some intervals i have to check whether the status is changed to complete in GET response and accordingly i have to proceed with the next test step execution.

 

Is this possible with groovy script? if so can you please provide me the script, Since i am new to the scripting.

 

Thanks

 

  • richie's avatar
    richie
    5 years ago
    Hey doubtsreadyapi,

    Im not sure if the step supports json...according to the 'help' id say it doesnt. Im not in front of my laptop to check at the moment.
    Easiest way to check....add the conditional goto step into a test case immediately after your RESTstep that generates your json response, execute your RESTstep and via the conditional goto step, click on the button in the conditional goto step to try and read the RESTstep's response.
    Does it parse the json content ok? If yes you can use the conditional goto step. If it doesnt, you cant use it and youll have to revert to a groovyscript option (@nmrao and @HimanahuTayal may have alternative code to do what you need as im not a coder but they are)

    Nice one!

    Rich
  • nmrao's avatar
    nmrao
    Champion Level 3
    This use case can be achieved by employing conditional go to test step( without script as well)

    If condition added is true, complete the flow otherwise delay and get the status and conditional go to handles again, so kind of loop.
    • doubtsreadyapi's avatar
      doubtsreadyapi
      Contributor
      nmrao

      Thanks for the information. So you mean to say the loop will continue in my scenario until the status changes to complete? So how much time this loop will be executing?

      So conditional go to step will be hitting the GET request until the condition is met?

      Please let me know, Suppose in my scenario if status did not turned to complete what will happen? Using conditional go to step option.

      Thanks