Forum Discussion

redellestioko's avatar
13 years ago

SoapUi: read my input request data from txt file

request:
<urn1:req_insert_held_receipts>
<urn1:din_pin>2243797</urn1:din_pin>
</urn1:req_insert_held_receipts>

On the request I want to made the node din_pin as variable.

What i did is define a properties ( properties.jpg). Then change the request.

New request after adding properties
<urn1:req_insert_held_receipts>
<urn1:din_pin>${Properties#dinpin}</urn1:din_pin>
</urn1:req_insert_held_receipts>


My question is: I want to make the node DIN_PIN to read from a text file. Eg. dinpin.txt

content of dinpin.txt
2243797
2243798
2243799

Please help on how to make read an input to my request to read from dinpin.txt

thank you.
  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    For example:

    def ts = context.getProperty("#TestSuiteRunner#").currentTestCase.testSuite
    def groovyUtil = new com.eviware.soapui.support.GroovyUtils(context)
    def filepath = groovyUtil.projectPath

    def filename = filepath+"//dinpin.properties" //if the file is in the same folder with project,or plus subfolder name

    def pros = new Properties()
    pros.load(new java.io.InputStream(filename))
    Enumeration e = props.keys()

    while (e.hasMoreElements()){
    key = e.nextElement()
    val = props.get(key)
    ts.setPropertyValue(key,val)
    }


    ps: dinpin.properties
    dinpin1=123456
    dinpin2=234567
    dinpin3=345678

    Thanks,
    Aaron