Forum Discussion

Maximus's avatar
Maximus
New Contributor
5 years ago
Solved

Pass variable from Groovy Script to request

Hi,   I have a test suite with a number of test steps: SOAP request -> Grtoovy Script -> Soap request.  My groovy script parses the response from the previous request and then is supposed to pass...
  • meinTest's avatar
    5 years ago

    Hi Maximus,

     

    you have different issues in your script.

    1.  you try to set the testStep property. As far as I know you can not do that (it makes no sense because you could also write the value in the same request)  

    testRunner.testCase.testSteps["Disable"].setPropertyValue('ID', job2)

    Therefore use the testCase.setPropertyValue...

     

    2. you try to set the value with the variable 'job2' but job2 is not instantiated and / or is not set in the script you should use job

    testRunner.testCase.testSteps["Disable"].setPropertyValue('ID', job2)

     

    Following is a script which should fix your error

     

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def holder = groovyUtils.getXmlHolder( "getBank#Response" )
    
    for(job in holder.getNodeValues("//*[local-name()='identifier']")){
      if (job.contains("70144")){
        testRunner.testCase.setPropertyValue('ID', job);
        testRunner.runTestStepByName("Disable");
      }
    }

     

    Best regards 

     

    sign.png

      meinTest GmbH

      www.meinTest.software

     

     SmartBear preferred value-added Service

     Provider in the DACH region