Forum Discussion
- Chowdhary8 years agoContributor
How to use the project level property or groovy script.
- nmrao8 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.
- Chowdhary8 years agoContributor
I Tried from using the groovy code what you gave, when I run it am getting an error like missing source property, can I have through any example to understand a bit....