How can I pass variable in ReadyAPI step using groovy script

Viewed 543

I have a 4 steps in a ReadyAPI only thing changes is step number.

def testStep = testRunner.testCase.testSteps['Verify Application1']

def testStep = testRunner.testCase.testSteps['Verify Application2']

def testStep = testRunner.testCase.testSteps['Verify Application3']

Now, I want to pass a variable instead of 1,2,3 in ReadyAPI step using groovy. So that I can add loop and iterate whenever i need.

1 Answers

// Run a loop and use concatenation to generated the string you want

for(int i=1 ;i<=3 ;i++)
{
   str='Verify Application'
   str=str+i
   log.info str

    def testStep = testRunner.testCase.testSteps[str]

 }

output is like

enter image description here

Related