Forum Discussion

danielmbanks's avatar
danielmbanks
Occasional Contributor
8 years ago
Solved

How to access RunContext properties

If I have added a property to the runContext e.g.

 

testRunner.runContext.setProperty('myProperty', 'example data')

And I want to access this property in an assertion in a later step, is ${=context.myProperty} the only way to get the value?

 

It just seems weird that the syntax is different from the standard style e.g. ${#TestCase#myProperty}

 

  •  

    Hi Danielmbanks,

     

    The syntax is different because you are accessing to different objects. The context object is available only inside the test execution. Here, the property may have a completely different value (in comparison with the one specified in the TestCase) depending on how you work with it (change its value during the test).

    The second example gets value from the TestCase of the current project. 

    So, theoretically, you can use any objects in your test.

     

1 Reply

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

     

    Hi Danielmbanks,

     

    The syntax is different because you are accessing to different objects. The context object is available only inside the test execution. Here, the property may have a completely different value (in comparison with the one specified in the TestCase) depending on how you work with it (change its value during the test).

    The second example gets value from the TestCase of the current project. 

    So, theoretically, you can use any objects in your test.