Forum Discussion
HimanshuTayal
Community Hero
I have tried to automate the scenario which you have mentioned, hope below code will help you out :
//For getting count from Properties step 1
def propertiesStep = testRunner.testCase.getTestStepByName("Properties")
HashMap<String,Integer> map = new HashMap<String,Integer>();
for(testProperty in propertiesStep.getPropertyList()){
if(testProperty.name.contains("Serial")){
if(map.containsKey(testProperty.getValue()) )
map.put(testProperty.getValue(), map.get(testProperty.getValue())+1)
else{
map.put(testProperty.getValue(), 1)
}
}
}
//For setting count in Properties step 2
def propertiesStep1 = testRunner.testCase.getTestStepByName("Properties1")
for(testProperty in propertiesStep1.getPropertyList()){
for(Map.Entry entry in map.entrySet()){
if(entry.getKey() in testProperty.value){
flag = testProperty.name.substring(testProperty.name.length()-1);
propertiesStep1.setPropertyValue("Count "+flag.toString(),entry.getValue().toString())
}
}
}
mayur_vats
5 years agoOccasional Contributor
Thank you, Himanshu for your prompt response. This script is executed as teardown script of a test suite so testRunner will not be an option there. It might work with runner object but I just figured it out with minor UI setting from SoapUI itself: I was calling a test case with the run mode option selected in the screenshot.
If I select any option other than the selected one, I am able to read the properties of the callable test case when called as a Test Step.
But thank you again for your help.
- HimanshuTayal5 years agoCommunity Hero
I have tried last piece of code but it is working at my end don't know what's the issue at your end refer below screenshot.
Related Content
Recent Discussions
- 15 years ago