Forum Discussion

CharlesHarold's avatar
CharlesHarold
Occasional Contributor
6 years ago
Solved

Tip: context.expand() works on multiple properties in one string!

This may be obvious to everyone else, but I'd always used context.expand() on single properties, e.g.: value = context.expand( '${#TestSuite#TsCustomProp}' ).

 

Today I realized that I could have multiple properties in a string, and using context.expand() on the entire string would expand all the properties in that string:

 

String checkMe = 'This string has properties ${#TestSuite#TsCustomProp} and ${#TestCase#TcCustomProp} and ${#Env#DATASOURCE_USERNAME} and ${#Project#ProjCustomProp}'
checkMe = context.expand( checkMe )
log.info " checkMe: '${checkMe}'"

Which outputs

 

Tue Apr 10 09:32:31 EDT 2018:INFO: checkMe: 'This string has properties MyTestSuiteCustomName and MyTestCase and CHARLES and thisisgreat'

Awesome!

  • Yes, that does evaluates all the properties until it finds none.
    Good you shared it to the community.

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3
    Yes, that does evaluates all the properties until it finds none.
    Good you shared it to the community.