Forum Discussion
7 Replies
- groovyguyChampion Level 1
I do not think that Property Transfer steps can accomplish this. I typically write a groovy script to handle moving values from one test suite to another.
- ChowdharyContributor
I can know any sample groovy script for transfer the values ?
- nmraoChampion Level 3What is your use case? If the data is common across the suites, then best way is to use Project level property instead of Test Suite level.
- ChowdharyContributor
How to use the project level property or groovy script.
- nmraoChampion 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.
Related Content
- 10 months agolodecesa