Forum Discussion

emile's avatar
emile
Occasional Contributor
9 years ago

set header in teststep by loop

Hi,

I'd like to set all my teststep Hedears by looping, something like that :

 

def testSteps = context.testCase.getTestStepList()
testSteps.each{
// This block will loop through the test steps and print the test step name to the log
testRunner.testCase.getTestStepByName(myTestStep).testRequest.setRequestHeaders(headers)

}

 

but get this "class" error

 

groovy.lang.MissingPropertyException: No such property: getTestStepByName for class: com.eviware.soapui.impl.wsdl.WsdlTestCasePro error at line: 32

 

Thx for any help

  • Hello Emile,

     

    I would simplify your code by using the "it" keyword withing the loop for referring to the current TestStep:

    def testSteps = context.testCase.getTestStepList()
    testSteps.each{
    try{
      it.testRequest.setRequestHeaders(headers);
    }
    catch (e){}
    }

     

  • Hello Emile,

     

    I would simplify your code by using the "it" keyword withing the loop for referring to the current TestStep:

    def testSteps = context.testCase.getTestStepList()
    testSteps.each{
    try{
      it.testRequest.setRequestHeaders(headers);
    }
    catch (e){}
    }

     

    • emile's avatar
      emile
      Occasional Contributor

      Thanx Nat, it works fine!