Working with SoapUI Properties – SoapUI Tutorial #8

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated March 7, 2024

This tutorial is all about working with SoapUI properties. Let’s get started.

In the last SoapUI tutorial we saw how to add properties in Groovy script.

The property in SoapUI is similar to a variable/ parameter and in this tutorial, we will talk about how to use one in a service request and assign response value to it through scripting. Later, we will move on to the property transfer test step and then import the properties.

This is the 8th tutorial in our SoapUI online training series.

What will you learn from this SoapUI Tutorial?

  • Different Faces of Properties
  • Integrating Properties in Service Request
  • Understanding Property Transfer Test Steps
  • Load Properties Externally

Working With SoapUI Properties

working with soapui properties

There are two types of properties in SoapUI:

  1. Default Properties: included in the SoapUI installation. We can edit some of the default properties but not all of them.
  2. Custom/user-defined properties: These are defined by us at any level needed, such as global, project, test suite, test case or test step.

Most often, properties are used to store and retrieve data while executing test cases. Internally, the property will store the value in a key pair format.

For example, in the below statement, “Local_Property_FromCurrency” is a key name and “USD” refers value. To access the property value, we need to use the property name.

testRunner.testCase.testSteps[“Properties”].setPropertyValue
( “Local_Property_FromCurrency“, ‘USD’)

Various property levels in SoapUI Pro

Let’s discuss the various property levels in SoapUI Pro. There are three levels of properties available in SoapUI.

Level #1. Project and Custom Properties

At this level, properties are divided into two sections. They are project properties and custom properties. These will appear at the bottom of the navigator panel when we click on the Project name. The project properties section has default properties which are created during project creation for example, Name, Description, File etc.

In order to create our own properties, we use custom properties tab. Click on the plus icon to create properties:

WORKING WITH PROPERTIES new 1

There are many other options available such as remove, move up, move down and sorting next to add. Any number of custom properties can be added and used by any section (test suite, test cases) within the project.

Level #2. Test Suite and Custom Properties

These properties are only visible under the test suite. The test suite can contain any number of properties and can be accessed from any test steps which belong to the said test suite.
Test suite properties appear when you click on the respective test suite name under the project. To add custom properties as needed, click on the custom properties tab and click on the ‘+’ sign under it.

Working with Properties(2)

Property #3. Test Cases and Custom Properties

Test case properties are accessible within the test case. They are not accessible through other test case steps or even a test suite under the project.

More details about the properties with examples

Properties can store end points, login details, header information, domain etc. even though we have discussed writing and reading data to/from the properties, we are yet to discuss this topic in detail with an example.

The above discussed levels of properties are used in scripting to read the data.

#1. Reading properties

We will look at how we can read the properties in a groovy script. In order to access different level properties, the following is the syntax:

Project: Syntax: ${# Project Name # Value }
Example

def projectPro = testRunner.testCase.testSuite.project.getPropertyValue
( “Project_Level_Property” )
“Project_Level_Property” )
log.info (projectPro)

Test suite: Syntax: ${# TestSuite # Value }
Example

def testPro = testRunner.testCase.testSuite.getPropertyValue(‘Testsuite_Property’)
log.info (testPro)

Test case: Syntax: $ {# TestCase # Value }
Example

def testcasePro = testRunner.testCase.getPropertyValue(‘Testcase_Property’)
log.info (testcasePro)

Refer to the screenshot given below:

Working with Properties(3)

#2. Writing to properties

To do this, we have to use setPropertyValue method.

Syntax: setPropertyValue (“property name”,”value”)

If we assign values to unknown properties, then SoapUI will create these properties newly. For existing properties, receive the values during the assignment.

#3. Removing Properties through Script

This can be done by right-clicking on the property name from the property panel. Then click on the Remove option from the context menu.
To do this using script for removing the custom properties use the following statements for project, test suite or test case levels respectively:

testRunner.testCase.testSuite.project.removeProperty( “Testcase_Property” );
testRunner.testCase.testSuite.removeProperty( “Testcase_Property” );
testRunner.testCase.removeProperty( “Testcase_Property” );

The above scripts are not optimum when we have multiple properties in each level as these steps have to be repeated several times for each property. An alternative is to iterate the properties through the script as below:

testRunner.testCase.properties.each
{
           key,value ->
           testRunner.testCase.removeProperty(key)
}

The above script will iterate until the last property is available under the test case. “Key” refers the name of the property where as “value” denotes actual value of the property. We can modify the above script to remove the bulk property list present at various levels.

#4. Add property

AddProperty method is used for this whose syntax is:

addProperty ( property name );

This can be adapted for each level as below:

testRunner.testCase.testSuite.project.addProperty(‘ProjectProperty1’)
testRunner.testCase.testSuite.addProperty(‘TestsuiteProperty1’)
testRunner.testCase.addProperty(‘TestcaseProperty1’)

After executing the above scripts, click on the project/test suite/test case name. Check the custom properties tab in the property panel and the created property appears here. See below for reference:

WORKING WITH PROPERTIES new 2

Using properties in services

In this section, we will learn how to use the properties in services and we are going to use the above scripts for adding, assigning, retrieving property data with currency converter web service.

Integrating Properties in Service:

Let us start adding the test steps as shown in the below screenshot.

Working with Properties(5)

In the above screenshot, AddProperties_Script test step contains the following script which adds two properties such as Property_FromCurrency and Property_ToCurrency.

// Add Properties
testRunner.testCase.addProperty(‘Property_FromCurrency’)
testRunner.testCase.addProperty(‘Property_ToCurrency’)

// Assign values to the Properties
testRunner.testCase.setPropertyValue(‘Property_FromCurrency’,’USD’)
testRunner.testCase.setPropertyValue(‘Property_ToCurrency’,’INR’)

In the ServiceRequest_CurrencyConverter_1 contains the request with input parameters as seen below:

Working with Properties(6)

Assigned values in the properties will be transferred to these parameters during the execution. Following this test step, GetResponseData_Script test step has a script that will get the response value and show the result in the log. Here’s the script.

// Get Response data from the service
def response = context.expand( ‘${ServiceRequest_Currency
Converter_1#Response}’ )
def parsedResponse = new XmlSlurper().parseText(response)
String convertedValue = parsedResponse.Body.ConversionRateResponse.
ConversionRateResult.text()
log.info(convertedValue)

Once all the steps are ready, double click on the test suite name and run the test suite. Then, double-click on the ServiceRequest_CurrencyConverter_1 and see the response section.

Here’s what we would find:

  • Response will be received
  • Open the script log to see the resultant data that is converted based on input parameters

This is how we can pass the parameters to the input request and get the response through the script using properties. Going further, we can also pass the response value to another service as input.

Property Transfer

The property transfer test step transfers the property data from one property to another during the execution. Let us see in brief how we can create a property transfer test step and how the property value is transferred between the two properties.

  • Right click on the test case name under the test suite
  • Click Add Step and then click Properties option from the context menu
  • Repeat the above steps to create a second property. See the below screenshot:
Working with Properties(7)
  • Now we have to add a property transfer test step.
  • Right click on the test case name and click on the property transfer option from the context menu
  • Enter your desired property transfer name and then click OK
  • Click Add i.e. plus sign in the property transfer tool bar
  • Specify the transfer name and then click the OK button
  • On the right side panel, there are two sections available: Source and Target.

Choose the source as Properties and property as Property_Zipcode. Do the same in the target section. Choose Target_Property from the property drop down. When run icon, the property value will be transferred from Property_Zipcode to Target_Property.

(Click on the image for an enlarged view)

WORKING WITH PROPERTIES new 3

See the transferred value as shown in the below screenshot.

WORKING WITH PROPERTIES new 4

Note: Source property should contain the default value.

There are many options available on the property transfer screen.

  • Fail Transfer on Error
  • Transfer Text Content
  • Transfer to All
  • Entitize Transferred Value(s)
  • Set Null on Missing Source
  • Ignore Empty/Missing Values
  • Use XQuery
  • Transfer Child Nodes

Load Properties from External Source

To load properties from an external source, follow these steps:

  • Add Properties test steps under the test case
  • Enter the property step name and then click OK
  • In the property panel under the navigation panel, click the Custom Properties tab
  • Click Working with Properties icon to load the properties from the external property file

Note: Property files should be saved or present on your computer. To save the properties, click the icon.

Then, go to the respective drive and pick the property as shown below:

Working with Properties(9)

On OK, you can see the loaded properties and their values in the Custom Properties tab.

Conclusion

Well, that’s property for us!

Each level properties have their own characteristics. During your SoapUI practice, try to include properties whenever possible with the groovy script test steps for adding, removing, assigning and retrieving property data. This is not only useful when you practice with the services but also critical for real application testing as this technique is very helpful to assert your test cases.

Transferring properties between test steps is easier than writing repeated scripts to create new. SoapUI also gives a wonderful feature to import and export properties. This feature will be useful when we are using common properties such as login details, session details etc., for multiple projects. That way, we don’t have to create the same properties again and again for multiple projects. We can simply change the property value against the properties based on the projects.

Next tutorial #9:  In next SoapUI tutorial we will learn Conditional Statements in Groovy like:

  • Boolean Statements
  • Iteration Statements
  • Arrays in Groovy

Keep reading and we will see you in the next tutorial. Please don’t forget to share your questions, feedback and experiences in the comments section below. We would love to hear your thoughts.

Was this helpful?

Thanks for your feedback!

Recommended Reading

16 thoughts on “Working with SoapUI Properties – SoapUI Tutorial #8”

  1. Hi, I am fresher currently working as a QA (software tester) in a small company. I am scared about my career growth . i want to ask what is the career growth as QA. What should i do to enhance my skills and in which city i should move so that i can get a good package. Thanks Please reply ASAP

    Reply
  2. @Sunil: You can save the response values by clicking on the required request and choosing the “Dump file” location in its properties. Thanks!

    Reply
  3. whats the difference between context and testrunner ? are they exchangeable ?

    i tried to set testcase prooperty and use them inside request like ${from} but this approach was only working for global properties and not for testcase/testsuite properties
    by just putting ${property_name} how system will understand which property we are talking about

    PathLanguage is also shown in property transfer screen apart from Source/Property ( i am using SOAP NG version), by default the value is ?

    Can you elaborate more on the last part,how in a file we can place properties and load them(external source) ?

    Also if you can explain the code of getting response in a little detail ‘// Get Response data from the service” ?
    what if there are 2 responses from API, as of now we had only 1 amount returned

    when we can directly set a property as explained in earlier tutorial, then adding them first ? is there a special need to add them ?

    Reply
  4. Hi,

    I need to read data from excel sheet and save it in the SoapUI properties.

    Please help me asap.
    Also send me the detailed steps how to do.

    Reply
  5. How do I substitute a global property in request body. For eg my HTTP request body is of type application/json and the body is as follows :

    {
    “name”: “first name”,
    “groupId”: “${groupId}”
    }

    Where groupId is a Global Custom Property.

    Reply
  6. kindly give the tutorial for soapui open source version not for pro..open source only by most peoples..

    i can say u r giving the generic example here but focus on open source.

    its my request

    thanks
    sathya

    Reply
  7. I just want to know, I transfer the value to the property, then, how can I access it in another request, not using any code, just want the value.
    I try the to set the “Token” value as #{#CaseName#Token}, failed.

    As I know in Jmeter, I can set a value to a property, for example, “Token”. After that, anywhere, we can get the value of the “Token” by using “$Token”, but I can’t find this way works in SoapUI, now the problem is that, I can ge the value , and set it to a property, then, I don’t know how to access it.

    Reply
  8. Hi,

    I have given the location in DUMP FILE option in Request Properties. But my file is not generated at the location i.e. response is not getting saved. Please help!

    Reply
  9. I would like to change the Dump File location for every response using automation. How to achieve that?.
    Ex: For response 1, Dump File name is filename1 then for next response DumpFile should be filename2.

    Please help me how to implement it

    Reply
  10. Hi,

    I am using Excel DataSink for extracting some properties from SOAP response… it is only saving latest iteration results…Is there any way not to replace the previous run results.

    Reply

Leave a Comment