Forum Discussion

gurpreets's avatar
gurpreets
Occasional Contributor
15 years ago

Property Transfer Using Groovy

Hi,

I am a newbie in Groovy Scripting. I need to do the following,.

Txt File -load--> Property (set of Values) --substitue--> Request

ie. get values from a text file and store it in a property. then transfer those values from property to the request. This way I just need to have a file and then run the groovy script, my test is automated.

I have the script to do the first part. Can you please guide me in doing the second part. ie, doing a property transfer of a set of values to my request using a Groovy script.

Thanks
Gurpreet

5 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    To get the value of a property stored in a Property Step in Groovy, just use a property expansion:


    context.expand('${Properties#propertyname}')


    Replace "Properties" with the actual name of your Properties step and "propertyname" with the property you wish to access.

    Regards,
    Dain
    eviware.com
  • gurpreets's avatar
    gurpreets
    Occasional Contributor
    I used the following script to transfer a static value into request. Instead of this, I wan to get the value from property step and transfer tat.

    -------------------------------------------------

    // Script to update a request with a single static value


    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    log.info( groovyUtils.projectPath );

    /* create holder for last response and log requestId
    def holder = groovyUtils.getXmlHolder( "Book Author Search#Response" )
    log.info( holder.getNodeValue( "//ns1:RequestId" ))*/

    // create holder for request and set id
    holder = groovyUtils.getXmlHolder( "deployCampaign#Request" )
    holder.setNodeValue( "//icom:sourceSystem", "testSystem")

    // update request with updated xml
    holder.updateProperty()

    -------------------------------------------------
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    is there any reason that you are not using "Property Transfer" test step?
    I think that "Property Transfer" test step is what you need here.

    Nebojsa
    eviware.com
  • gurpreets's avatar
    gurpreets
    Occasional Contributor
    Yes Nebojsa,

    I want to automate the stuff as much as possible. My request have quite a large amount attributes(40-50).

    Hence to create property transfer for all of them is a tedious task. So I am being lazy  and tryin to automate that part too.

    I hope I am being reasonable.

    thanks