Forum Discussion

SriniMarva27's avatar
SriniMarva27
Occasional Contributor
6 years ago
Solved

How do I setup test case property key using a variable value?

def a = Property1

testRunner.testCase.addProperty(<Value of a>)

 

As you can see in the above piece of code, I have declared a variable named 'a' and assigned a value of Property1. Now how do I add a property using the variable 'a'?

  • Lucian's avatar
    Lucian
    6 years ago

    It is equally simple:

     

    def a = "Property1"
    
    testRunner.testCase.setPropertyValue(a, "")

5 Replies

  • Lucian's avatar
    Lucian
    Community Hero
    testRunner.testCase.setPropertyValue("nameForYourTestCaseProperty", a)

    That's all. The above method should add the property to your test case if the property doesn't already exist.
    • SriniMarva27's avatar
      SriniMarva27
      Occasional Contributor

      Hi Lucian,

       

      Thanks for your reply. I want to add a property name (key) using a variable value and not the property value. How do I do that?

      • Lucian's avatar
        Lucian
        Community Hero

        It is equally simple:

         

        def a = "Property1"
        
        testRunner.testCase.setPropertyValue(a, "")