Applies to Ready! API 2.0, last modified on May 16, 2017

Property expansions allow you to insert variable parts in a property value, request body, scripts and so on. This topic describes how to specify property expansion manually, but you can specify them visually, by using the Get Data dialog.

Transfer Property Values

You can specify a property expansion to use property value of one test item in another.

The syntax of property expression is:

${[#Scope#]Property Name[#Path Expression]}

Where:

  • Scope – A scope in which the desired property is declared. The following table lists available values:

    Scope Description Example
    #Project# Properties specified in the project. ${#Project#Project property}
    #TestSuite# Properties specified in the parent test suite. ${#TestSuite#Suite property}
    #TestCase# Properties specified in the parent test case. ${#TestCase#Case property}
    TestStep# The name of the test step in the same test case. ${REST Request#Response}
    #[TestSuite#TestCase#TestStep]#

    To refer to properties in other test suites, or test cases, use a full "path" to specify the desired scope.

    The "path" part is enclosed in square brackets.

    ${#[Suite name#Case name#Step name]#Property name}

    ${#[Shared suite#Common]#Username}
    #Global# Global property.
    Note: You can omit this scope.
    ${#Global#Global Property}

    or

    ${Global Property}
    #System# System property.
    Note: To see available system properties, select Help > System properties from the main menu.
    ${#System#os.name}
    #Env# System environment properties. ${#Env#JAVA_HOME}
    #MockService# Properties declared in a virt.
    Note: This scope available only in ServiceV.
    ${#MockService#Virt Property}
    #MockResponse# Properties declared in a virt response.
    Note: This scope available only in ServiceV.
    ${#MockResponse#Response Property}
    #SecurityTest# Properties declared in a security test.
    Note: This scope available only in Secure.
    ${#SecurityTest#Secure Property}
  • Property Name – The name of the desired property.

  • Path Expression – XPath or JSONPath expression to obtain a specific value from an XML or JSON content.

Dynamic Expression

Dynamic properties is a form of a property expansion where you insert a Groovy script to provide dynamic data.

To add Groovy to a property expansion, use the following syntax:

${=Groovy code}

For example, the following expression generates a random number between 0 and 999:

${=(int)(Math.random()*1000)}

Depending on where you use a property expansion, you can use relevant scripting objects. For example, in the request test steps, you can use the request object:

  • The ${=request.name} expression evaluates to the name of the request test step.

  • The ${=request.operation.interface.project.name} expression evaluates to the name of the project.

Almost in any script, you can use the log object.

Nesting Property Expansions

You can use property expansion in another expressions or its part. For example:

  • Refer to a property that contains another property expansion:

    Property Value Evaluated Value
    PropertyA Hello! Hello!
    PropExp ${#TestCase#PropertyA} Hello!
    Result ${#TestCase#PropExp} Hello!
  • Use property expansion as a part of an expression:

    Property Value Evaluated Value
    PropA Hello! Hello!
    PropB Good Morning! Good Morning!
    PropName PropA PropA
    Result ${#TestCase#${#TestCase#PropName}} Hello!
  • Use property expansion to specify an XPath expression:

    Property Value Evaluated Value
    xml

    <property>
      <value id="123">Hello!</value>
    </property>

    <property>
      <value id="123">Hello!</value>
    </property>

    id 123 123
    xpath //value[@id=${#TestCase#id}]/text() //value[@id=123]/text()
    Result ${#TestCase#xml#${#TestCase#xpath}} Hello!

Using Property Expansions in Scripts

You can use property expansion in scripts. To get value of the property in groovy script use the following syntax:

def foo = context.expand( 'Property expansion' )

For example, the following code snippet assigns to the foo variable the value of the Username test case property:

def foo = context.expand( '${#TestCase#Username}' )

See Also

Get Data Dialog
Property Transfer Test Step