Forum Discussion
Chowdhary
Contributor
How to use the project level property or groovy script.
nmrao
8 years agoChampion Level 3
Set Project Level property Using Groovy Script:
Note that only String Type values are supported. In case, if the data type is other than string, user needs to change type explicitly while setting and getting.
Below are some common examples with different types.
# String Type
How to set
context.testCase.testSuite.project.setPropertyValue('PROPERTY_NAME', 'PROPERTY_VALUE')
How to get
def retriveValue = context.testCase.testSuite.project.getPropertyValue('PROPERTY_NAME')
#Integer Type
How to set
def value = 10 context.testCase.testSuite.project.setPropertyValue('PROPERTY_NAME', value.toString())
How to get
def retriveValue = context.testCase.testSuite.project.getPropertyValue('PROPERTY_NAME') as Integer assert retriveValue instanceof Integer, 'Value is not an Integer type'
# Boolean Type
How to set
def value = true context.testCase.testSuite.project.setPropertyValue('PROPERTY_NAME', value.toString())
How to get
def retriveValue = context.testCase.testSuite.project.getPropertyValue('PROPERTY_NAME')?.toBoolean() assert retriveValue instance of Boolean, 'Value is not a Boolean type'
Property Transfer:
And I believe that you would see Project an option in the Target drop down so that one would able to save the xpath selected value into a property which is similar to test suite which you are talking about.