Forum Discussion

rakeshg's avatar
rakeshg
Occasional Contributor
12 years ago

transferring multiple values in property transfer step

Hi-
I want to be able to transfer multiple values in PropertyTransfer step in SoapUI and assign the values in as a comma seperated list to a property. Is it possible to do so?

So e.g. if I have the following xml and using xPath I want to extract all <Text> node values (111,222,333) and assign it to a property. Is it possible?

<ABC>
<DEF>
<Text>111</Text>
<Text>222</Text>
<Text>333</Text>
</DEF>
</ABC>

Rakesh
  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi rakeshg,

    this probably can't be done by Property Transfer, because if I'm not wrong this step can't append values.
    So it will always save the value from the last node.

    But you could use this simple script, which should work for you:

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def holder = groovyUtils.getXmlHolder(your_xml)

    String valuesAsList = ""

    for (nodeValue in holder.getNodeValues("//Text")){
    valuesAsList += nodeValue + ","
    }

    //For example, setting these values as a property into the TestCase
    testRunner.testCase.setPropertyValue("values", valuesAsList[0..-2])


    Regards,
    Marek