Featured Posts

How to use properties in soapui

 
What is properties in SoapUI ?
        Properties in SoapUI is used to store and retrieve data. The data is stored as key,value format.

Default properties in SoapUI.

    SoapUI has properties at three levels by default.
        1.    Project level default/custom properties.
            User can add any number properties at project level and this can be accessed from any test steps from any test cases under any test suites.
          
        2. Test suite level default/custom properties.
            User can add any number properties at test suite level and this can be accessed from any test steps from any test cases under this test suite.
          
        3. Test Case level default/custom properties.
            User can add any number properties at test case level and this can be accessed from any test steps from this test case.

SoapUI Properties
Where to use properties in SoapUI

        We can read the property values into test step endpoint, Header values, username, password, domain, GET, POST, PUT and DELETE method properties.
               
Header properties
   
    The above image shows how to use the properties in Header or inside the Post request.

How to use default/custom properties.
   
    The default/custom values at three levels can be used for endpoint, Header values, username, password etc..
    The general format for reading the default/custom property value is     :    ${#levelname#key}
    Ex :
   
        To read test case level property    :    ${#TestCase#param1}
        To read test suite level property    :    ${#TestSuite#param1}
        To read  project level property        :    ${#Project#param1}
   
    The above image shows how to use the property at test case level.
     
Read property using Groovy Script   

    Reading property values from a script is straight-forward, to get a property value you first need to get hold of the containing object and then use the getPropertyValue("property name") method.

    Groovy script can be used in two places inside the SoapUI.
        1.    Groovy script test step
        2.    Script Assertion - within test step.
   
    The below code snippet can be used to read test case level property from Groovy script test step.
def param1 = context.testCase.getPropertyValue( "param1" )
log.info param1
Read property
    Similarly the below code snippet can be used to read test case level property from Script Assertion.
def param1 = testRunner.testCase.getPropertyValue( "param1" )
log.info param1
       
Read property using script

    We can read the property value from test suite level as well as project level in similar way.
   
    Code snippet to read test suite level property
def param1 = testRunner.testCase.testSuite.getPropertyValue( "param1" )
log.info param1
    Code snippet to read project level property
def param1 = testRunner.testCase.testSuite.project.getPropertyValue( "param1" )
log.info param1
   
Set/Add property using Groovy Script

    As like reading property value, writing property values from a script is also straight-forward. we need to call setPropertyValue("property name","property value") method. If the property is not exist already then it will be created and the value will be assigned. If the property is already exist then its value will be updated.

    Code snippet to write test case level property
context.testCase.setPropertyValue( "param1","88" );
    Similarly the code snippet to write values for testsuite and project level property are
context.testCase.testSuite.setPropertyValue( "param1","88" );
context.testCase.testSuite.project.setPropertyValue( "param1","88" );
Delete property using Groovy Script   

    We can manually add any number of default or custom properties at all three levels. But the tool doesn't have the option to delete the properties manually. we need to use the script to delete the property.
   
   SoapUI Delete property
    using the below script we can delete the property.
context.testCase.removeProperty( "param1" );
    similarly we can delete the properties in testsuite and project level
context.testCase.testSuite.removeProperty( "param1" );
context.testCase.testSuite.project.removeProperty( "param1" );
Delete/Remove all custom properties using Groovy Script.

    The below code snippet can be used to delete all the properties available in test suite level.
context.testCase.properties.each
{
    k,v ->
    context.testCase.removeProperty(k);
}
    we can modify the above code to delete all the properties at different levels as discussed above.
   

Search
Sponsors
Techie##
###
We will keep You Updated...
Sign up to receive breaking news as well as
receive other site updates!
Subscribe via RSS Feed subscribe to feeds
Sponsors
Popular Posts
Sponsors
Recent Stories
Connect with Facebook
Google Connect
Recent Comments