Forum Discussion
4 Replies
Sort By
- SmartBear_SuppoSmartBear Alumni (Retired)Hello,
If you're just interested in reading the values of properties, you should use Property Expansions, like
context.expand('${#Project#P1}')
(note the required use of single quotes). If you need write access, or need to access properties in another TestSuite or TestCase, you will need to access the properties "manually" For example:
//Access property 'C1' in current TestCase:
def property = testRunner.testCase.properties['C1']
//Access property 'T1' in current TestSuite:
def property = testRunner.testCase.testSuite.properties['T1']
//Access property 'T2' in TestSuite 'TS2' (which is different from the current TestSuite):
def property = testRunner.testCase.testSuite.project.testSuites['TS2'].properties['T2']
//Once you have a reference to the property you can read or write the value:
property.value = 'new value'
log.info property.value
Regards,
Dain
eviware.com - HeavenOccasional ContributorHi
this is another way to change the property of test suite
// this is the script to change/ set the properties of
// any of the test suite in same project
testRunner.testCase.testSuite.project.testSuites["TestSuite name"].
setPropertyValue( "property name", "property value" ) - ian_howardNew ContributorThanks everyone, thats exactly what needed.
- grexeOccasional Contributor(Couldn't reply to the more appropriate thread about project properties not expanded in Groovy scripts)
I had no luck with expanding project properties like [tt:1cglnrmn]${projectDir}[/tt:1cglnrmn] in a TestCase's groovy script.
Instead, I had to manually define a project property that holds [tt:1cglnrmn]${projectDir}[/tt:1cglnrmn] - only then it worked.
Related Content
Recent Discussions
- 9 days agoemoya