Forum Discussion

Flo's avatar
Flo
Contributor
5 years ago
Solved

Groovy - How to automatically modify/set operation test step request

Hello, I want to automatically change content of a WSDL request of several requests in test steps of a test case. The name of the service changed in the WS I used to test, but the contents still th...
  • nmrao's avatar
    nmrao
    5 years ago

    Flo 

    Below should help you:

     

    import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep

    //Define element names in below two statements
    def elementNameBefore = 'DefineOldName'
    def elementNameAfter = 'DefineNameName'
    //No change required beyond this
    def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("testSuiteName").getTestCaseByName("testCaseName") testCase.testStepList.findAll{it instanceof WsdlTestRequestStep}.each { step -> def content = step.httpRequest.requestContent def changedContent = content.replaceAll(elementNameBefore, elementNameAfter) step.httpRequest.requestContent = changedContent }