Forum Discussion

shabar's avatar
shabar
Contributor
13 years ago

How to use parameter in Folder path in Groovy

Hi All

If I want to use parameter in folder path in groovy, how should I define the path.

I tried several options but in vane

def outputFile = "D:/SoapUI/TestResults/${TestStep#Name}" + "_response.xml"



Thanks

8 Replies

  • SiKing's avatar
    SiKing
    Community Hero
    I think you are mixing SoapUI parameters and Groovy variables together.
  • Hi SiKing,

    Is there a way to do that?

    Basically needs to include SoapUI property value in the groovy script to create the folder path.


    Thanks
  • SiKing's avatar
    SiKing
    Community Hero
    This is rather basic Groovy scripting.

    def soapuiProperty = context.expand( '${some#property}' )
    def groovyVariable = "D:/SoapUI/TestResults/${soapuiProperty}_response.xml"
    File outputFile = new File(groovyVariable.toString()) // need to convert GString to String or this will fail
  • Appreciate your help

    I want to get REST Test Request Property instead of custom property and tried below as you specified.


    def stepName = context.expand( '${Simple Search#Name}' )
    log.info stepName

    But not able to see the property value.

    Am I doing something wrong here?


    Thax
  • SiKing, Thanks for your link it is really useful

    In my testcase I want to access previous test step name in immediate next groovy step. I checked any method like getPrevousStep or getLaststep but couldn't find anything.

    Is there a other way?

    Cheers
  • SiKing's avatar
    SiKing
    Community Hero
    This is still basic programming.
    You could try something like getCurrentStepIndex() and getTestStepAt(index - 1).