Forum Discussion

kolersa's avatar
kolersa
Contributor
9 years ago

HOW CAN I REPETE TESTSTEP UNTILL GET SOME SPECIFIC RESPONSE?

I have testcase with testeps with video uploading and second testest with checking status for uploaded video in first step. How can I loop second step untill server will send status 200 - video was uploaded succesufully.

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Have you tried using conditional goto step? That will solve your case.
  • kondasamy's avatar
    kondasamy
    Regular Contributor

    Kolersa,

     

    Please try this approach wih the help of a Groovy Teststep,

    1) In the testacse, first should be 'upload video' teststep

    2) After that create a Groovy Teststep and insert the below script assuming "Check video uploaded status" is the following teststep,

    def step = testRunner.testCase.testSteps["Check video uploaded status"]
    for(int i=0;i<8;i++) //Just as a maximum of 8 loops
    {
    	step.run( testRunner, context )
    	//Assertion for the "Check video uploaded status" should be confined to check '200 OK'
    	if(!stepp.assertionList.status.toString().contains("INVALID") && !stepp.assertionList.status.toString().contains("UNKNOWN"))
    	{
    		break;
    	}
    	else
    	{
    		Thread.sleep(2000)
    	}
    }

    3) Have the "Check video uploaded status" teststep at 3rd position and disable it inorder to run from testcase level.

     

    Hope this helps! Please let me know if you need any other help!

     

    Thanks,

    Samy