Forum Discussion

Buschfunk's avatar
Buschfunk
Frequent Contributor
13 years ago

Inline Groovy script in test request

Hello,

Let's say a test request contains the following element:

<DataFieldValue>${DataSource#myCharacter}</DataFieldValue>

Now I need to pad this value with a certain character. In a Groovy script I would do:

def s = myString.padRight(12, "<")

I know that it is possible to use "inline Groovy scripts" starting with a '='. However I don't know how to apply this to my need.

Regards,
Robert

1 Reply

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

    you could have Groovy script that would parse the element in xml, similar to this:

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def holder = groovyUtils.getXmlHolder("Properties#response")

    holder.setNodeValue("//id", "aaaaa") // <- set value

    for( node in holder['//id'] )
    log.info node // <- debugging purposes

    holder.updateProperty() // <- important

    Hope this helps!

    Vladimir
    SmartBear Software