cancel
Showing results for 
Search instead for 
Did you mean: 

Remove all the properties starts with given value

SOLVED
mpw83
Contributor

Remove all the properties starts with given value

I found that I can use the following groovy script line to remove the given property 

testRunner.testCase.removeProperty('ScheduleID');

In my test case, I have properties like 'ScheduleID0' , 'ScheduleID1', 'ScheduleID2' ..etc 

Is there any script that I can use in my TearDown Script to remove all the test properties that I mentioned above which starts with 'ScheduleID'?

Help much appreciated. Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
HimanshuTayal
Community Hero

Re: Remove all the properties starts with given value

Hi @mpw83 ,

 

You can use more of groovy to find solution of your problem, first count the number of properties stored under Test Case custom properties and then delete the selected properties, refer below code for reference:

 

def targetTestCase = testRunner.testCase;
def propList = targetTestCase.getPropertyNames()
propList.each{
	if(it.contains("ScheduleID")){
		targetTestCase.removeProperty(it);
	}
	else{
		//Do nothing
	}
}

Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

2 REPLIES 2
HimanshuTayal
Community Hero

Re: Remove all the properties starts with given value

Hi @mpw83 ,

 

You can use more of groovy to find solution of your problem, first count the number of properties stored under Test Case custom properties and then delete the selected properties, refer below code for reference:

 

def targetTestCase = testRunner.testCase;
def propList = targetTestCase.getPropertyNames()
propList.each{
	if(it.contains("ScheduleID")){
		targetTestCase.removeProperty(it);
	}
	else{
		//Do nothing
	}
}

Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

mpw83
Contributor

Re: Remove all the properties starts with given value

@HimanshuTayal , Thanks for sharing. Its worked.  

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors