How to handle Properties with Groovy Scripts

Lecture description
Today we will learn:
1. How to get property
2. How to set property
3. How to add property
4. How to remove property
5. How to loop through all properties
References
https://www.soapui.org/scripting-properties/tips-tricks.html
Notes
// Get and Set Property
//Project
testRunner.testCase.testSuite.project.getPropertyValue("Name")
testRunner.testCase.testSuite.project.setPropertyValue("Name","I am in Project")
//TestSuite
testRunner.testCase.testSuite.getPropertyValue("Name")
testRunner.testCase.testSuite.setPropertyValue("Name","I am in TestSuite")
//TestCase
testRunner.testCase.getPropertyValue("Name")
testRunner.testCase.setPropertyValue("Name","I am in TestCase")
//TestStep
testRunner.testCase.getTestStepByName("CountryCodes").getPropertyValue("Name")
testRunner.testCase.getTestStepByName("CountryCodes").setPropertyValue("Name","I am in Test Step")
//Global
com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "Name")
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "Name","I am in Global Prop" )
// Add Property
testRunner.testCase.testSuite.project.addProperty("DOB")
// Remove property
//Project
testRunner.testCase.testSuite.project.removeProperty("Name");
//TestSuite
testRunner.testCase.testSuite.removeProperty("Name")
// Loop through properties
testRunner.testCase.properties.each
{
key,value ->
log.info (testRunner.testCase.getPropertyValue(key))
//log.info (key+" - "+value)
}
Learn more from the full course
SOAPUI API Testing | Step by Step for Beginners
learn SoapUI from scratch
06:44:07 of on-demand video • Updated September 2024