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 |