Forum Discussion

Chowdhary's avatar
Chowdhary
Contributor
8 years ago

Property trasfer from one test suit to another test suit

How can I transfer the properties from one test suit to another, right now I am using the xpath to transfer the values

What is the best way to do this & how to do it with property transfer ?

7 Replies

  • groovyguy's avatar
    groovyguy
    Champion 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. 

    • Chowdhary's avatar
      Chowdhary
      Contributor

      I can know any sample groovy script for transfer the values ?

  • nmrao's avatar
    nmrao
    Champion Level 3
    What 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.
    • Chowdhary's avatar
      Chowdhary
      Contributor

      How to use the project level property or groovy script.

      • nmrao's avatar
        nmrao
        Champion 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.