Forum Discussion
HimanshuTayal
5 years agoCommunity 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())
}
}
}