Forum Discussion
7 Replies
Sort By
- rohitgkkContributorHi,
This can be achieved by Groovy script.
Are you trying to say only one request that will be executed n number of times or they are multiple requests and just value needs to be increased?
Regards,
Rohit Shingalapur - nouvelleOccasional ContributorHi Rorit,
Many thanks for your help.
I have one request that will be executed n number of times, each time the parameter, which I called arg before, assumes values like arg1, arg2 and so on.
BR - rohitgkkContributorHi.
Ok, Then follow the following steps:
Step 1: Create a soapUI project and test suite and a test case within the test suite.
Step 2: Create a property at test case level say "incrementValue" and assign some value say 1
Step 3: Now add your Request say "Request 1" in this request add ${#TestCase#incrementValue} to the input element in the request.
So that it will take the value from the property that you have created at test case level i.e. incrementValue
Step 4: Now add Groovy step after the step "Request 1". Then add the following code in that
def incrementValue = context.expand( '${#TestCase#IncrementValue}' );
incrementValue = incrementValue.toInteger() + 1;
if (incrementValue <= 10) {
testRunner.testCase.setPropertyValue("IncrementValue", incrementValue);
log.info "IncrementValue: "+incrementValue;
testRunner.gotoStepByName("Request 1");
}
Step 5: Double click on the test case level and Test case editor will be displayed click on green button.
That's it!!!!!!!
Your request will be executed 10 times as per the groovy. Please remember to mention this otherwise it will run infinite times causing memory outage.
Hope this helps!!
Regards,
Rohit Shingalapur
http://rohit-developerscorner.blogspot.com/ - nouvelleOccasional ContributorHi Rohit,
Really many thanks !!!
I got your nice help and now I can proceed :-D
Best regards - dmltn84Occasional ContributorHello,
I am using this code for groovy script based on your instructionsdef incrementValue = context.expand( '${Properties#incrementValue}' );
incrementValue = incrementValue.toInteger() + 1;
if (incrementValue <= 10) {
testRunner.testCase.setPropertyValue("IncrementValue", incrementValue);
log.info "IncrementValue: " + incrementValue;
testRunner.gotoStepByName("xxx");
}
xxx - is a test step with request containing value which should be incremented
Output is as follows:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [incrementValue, 2] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [incrementValue, 2] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String)
I expanded script to look as follows, but it runs only once:def incrementValue = context.expand( '${Properties#incrementValue}' );
incrementValue = incrementValue.toInteger() + 1;
incrementValue = incrementValue.toString();
if (incrementValue <= 10) {
testRunner.testCase.setPropertyValue("incrementValue", incrementValue);
log.info "incrementValue: " + incrementValue;
testRunner.gotoStepByName("xxx");
}
Test steps are arranged in the following order:
1. Properties(1)
2. xxx
3. groovy script
Can you please advise what should be corrected? - dmltn84Occasional ContributorIs there a way to set property of Integer type, from http://www.soapui.org/apidocs/com/eviwa ... Utils.html:
setPropertyValue
public final void setPropertyValue(java.lang.String testStep,
java.lang.String property,
java.lang.String value)
throws java.lang.Exception
Throws:
java.lang.Exception - rohitgkkContributor
dmltn84 wrote:
I expanded script to look as follows, but it runs only once:def incrementValue = context.expand( '${Properties#incrementValue}' );
incrementValue = incrementValue.toInteger() + 1;
incrementValue = incrementValue.toString();
if (incrementValue <= 10) {
testRunner.testCase.setPropertyValue("incrementValue", incrementValue);
log.info "incrementValue: " + incrementValue;
testRunner.gotoStepByName("xxx");
}
Test steps are arranged in the following order:
1. Properties(1)
2. xxx
3. groovy script
Can you please advise what should be corrected?
It is running only once because your are setting the property value at the TestCase level and for condition check, you are accessing this from the test step i.e. Properties. So try the below
testRunner.testCase.getTestStepByName("Properties").setPropertyValue("incrementValue", incrementValue);
instead of testRunner.testCase.setPropertyValue("incrementValue", incrementValue);
Hope this helps.
Regards,
Rohit Shingalapur
http://www.developerscorner.co.cc