Forum Discussion

rajs2020's avatar
rajs2020
Frequent Contributor
4 years ago

Access custom properties programmatically ?

Test cases have custom properties. To access each property inside a groovy script, I have to repeat the this "context.expand( '${TestCase#SomeProperty}" for each property. Is there a shorter way to access such properties? Perhaps like this:

def allProps = context.expand('Get all the properties')

def name = allProps.get('Name')

  • Hi rajs2020 ,

     

    FYI.

     

    testRunner.testCase.propertyList.each {
        log.info "name=${it.name}, value=${it.value}"
    }

     

    Thanks,

    /Aaron

  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    Hi rajs2020 ,

     

    FYI.

     

    testRunner.testCase.propertyList.each {
        log.info "name=${it.name}, value=${it.value}"
    }

     

    Thanks,

    /Aaron

  • nmrao's avatar
    nmrao
    Champion Level 3
    Even the sample you posted is doing the same. Isn't it?
    For each property, you are calling get method to get the value.