Forum Discussion

HunterATtown's avatar
HunterATtown
Occasional Contributor
11 years ago

Any alternate for sleep()?

Hi,
I have a test case with following steps(example):
Step1 : PUT request - to insert some record
Step2 : Wait for 2 minutes
Step3 : GET request - to verify the inserted record

Here as per the requirement, server returns the fresh record within 2 minutes(any time within 2 minutes).
So instead of waiting for 2 minutes each time, i want to run(automatically) the test step(Step3) repeatedly unless I get its status code as '200 OK'(fresh record returned) and that step should not run more than 2 minutes.

Can anybody help me with this?
Let me know if any other details require...

Thanks,

7 Replies

  • HunterATtown's avatar
    HunterATtown
    Occasional Contributor
    Hi,

    I have tried with Goto feature but issue with that is 'what if condition never comes true?'...
    There might be an issue with server at that time it returns error so at that time this loop executes infinity times right?
  • nmrao's avatar
    nmrao
    Champion Level 3
    Well, there can have a configured property to control the number of times it should loop.
  • nmrao's avatar
    nmrao
    Champion Level 3
    Unfortunately, do not have something to show on screen.

    Assuming that there are test steps including the goto step in a test case.

    Define a user defined property at testcase level, say COUNTER and define a value.
    You might now understand how to use goto based on a condition. So, add an AND condition till local counter is less than the ${#TestCase#COUNTER}.
  • HunterATtown's avatar
    HunterATtown
    Occasional Contributor
    I resolved the issue with Goto step.
    Given the condition that if request fails then retry the same request and used counter variable.

    Thanks...
  • nmrao's avatar
    nmrao
    Champion Level 3
    Glad to know you could resolve. Anything that you would want to share how you did? May be that can be of help to someone.