Forum Discussion

SureshR's avatar
SureshR
Occasional Contributor
12 years ago

Multiple values in property teststep

Hi All,

I am using soapui 3.6.1.
I am trying to have multiple values for an property and that values to load from external file.
Can anyone suggest the format of contents in external files ?
I tried with comma delimiter and new lines but, did'nt work.

Regards,
-Suresh
  • dlizarazo's avatar
    dlizarazo
    Occasional Contributor
    I created a request called "Passing Values from groovy script to properties and Vic Vera". My Script is there but I can pass it over here if that is easier

    What I want to do is iterate through a list of items. I think it is very simple; I have my array of Item IDs and I input those into a property I called ItemID.

    In properties I also have a variable call "Counter" that should increase the value.

    and a conditional goto that will stop looping once Counter is at the max number
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi dlizarazo,

    Yes, please post the groovy for this, and I'll have a look for you when I have a few spare minutes.

    Kind regards,
    Tim
  • Hi..

    anybody can tell me , how i can pass multiple values to the property from the txt file without writing any script by using
    POST Request.Because i m new on soapui
    i found one option that are available in sopaui properties having an option to adding a property values from external file.
    but it can take the last values if i given a multiple.

    so i think their is an option to insert the values from an external source in REST API

    Regards
    vivek.....
  • Hi Tim,

    Thanks a lot for the below post. But, the below request is running for first parament. The second one is being passed.

    An error saying "[Isolated Process Thread] INFO com.jniwrapper.win32.ie.IsolatedProcess - Executing command: "C:\DOCUME~1\machant\LOCALS~1\Temp\JExplorer32.2.6.8.exe" "C:\DOCUME~1\machant\LOCALS~1\Temp\JExplorer32.2.6.8.dll" {92D448FF-0B2E-4F2F-A681-D3EC1AB40786}" is displayed.


    Can you let me know the wayforward to execute with more than one request using the below code. Thanks in advance..
    Regards,
    Madhu

    tjdurden wrote:
    Hi Suresh,

    I've created something that you may find of use. In my project I have used just a single TestCase, with 3 TestSteps, in the following order:

    1) A groovy step, called 'myGroovy'.
    2) A properties file, called 'myProperties', which contains a single property, called 'myParam'
    3) A test request, called 'myRequest', containing my SOAP request.

    It also assumes you've got a parameters file (called 'params.txt') containing your 5-digit values.

    Here's how to set it up:

    The groovy step:
    In the Groovy step, paste the following code:

    // Define a new array called 'paramList'
    def paramList = [];

    // Store each line of a specified text file as an item in the array
    new File( "C:\\params.txt" ).eachLine { line -> paramList.add( line ) };

    // Loop through each item in the array
    for ( i in paramList ) {

    def myProps = new java.util.Properties();
    myProps = testRunner.testCase.getTestStepByName("myProperties");

    // Replace existing myParam value with new item from array
    myProps.setPropertyValue("myParam",i);

    // Execute the myRequest TestStep
    log.info("Sending request using param value: " + i);
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def testCase = testRunner.testCase;

    def testStep = testCase.getTestStepByName("myRequest");
    // OR USE: def testStep = testCase.getTestStepAt(0);
    // OR USE: def testStep = testCase.testSteps["Delay"];

    testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
    testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
    testStep.run(testRunner, testStepContext);
    }


    The properties step:
    The properties step should contain a single parameter, called 'myParam'. I set the initial value to 0.

    The SOAP request
    You can use whatever SOAP request you want, but make sure you use the parameter identifier, which will be ${myProperties#myParam}.

    The groovy step will basically read in the external properties file, and store each line into an array. This array is then iterated in a loop and for each iteration it updates the myParam property, then executes the myRequest test step, using the updated parameter value. The loop will stop when all iterations have been completed.

    I hope this goes some way to helping you out.

    Kind regards,
    Tim