Forum Discussion

zsousa's avatar
zsousa
Contributor
8 years ago

Capture environment form UI dropdown

Hi All, so I am running into an issue where by selecting my environment from the UI drop down list doesn't get activated. I know several months ago someone at SmartBear told me this is happening because of the way I created my endpoints. So I figured, I would force the activation of my environment by writing a groovy script. The question I have is there a way of caturing what is currently being displayed in my UI dropdown list ?

 

1 Reply

  • Radford's avatar
    Radford
    Super Contributor

    The following code is from one of my test case startup scripts:

     

    def activeEnviroment = testRunner.getTestCase().getTestSuite().getProject().getActiveEnvironmentName()
    log.info('Active enviroment = ' + activeEnviroment)

     

    You need to get hold of the project object as this is where most of the methods relating to environments are, depending where your Groovy script is it might be subtly different from the above.

     

    The getActiveEnvironmentName is implemented by a "Pro" class so the method doesn't show up in Ready API code completion (This limitation was raised with SmartBear issue API-957).