Forum Discussion

dimpi_ozwala's avatar
dimpi_ozwala
New Contributor
7 years ago
Solved

How to update common property value for all available environment once execution is performed ?

How to update common property value for all available environment once execution is performed on one environment ?

 

Let me brief my issue with example :

 

Say initially I have created two properties Username and Password at project level and executed automated script for only one environment (E.g. Env1). Username is getting incremented every time based on written groovy script.

 

Now I have created another environment (E.g. Env2) by cloning previous one so it inherits all custom properties of previous environment. Whenever username is getting changed based on groovy script, value of the defined property at project level is updated and same value is getting applied at Env1. But it is not getting reflected for Env2.

 

Can you please suggest the solution to make property value updated for all available environments?

  • Hi,

     

    At the end of your test on the 1st environment, change the active environment to Env2 through Groovy step:

    testRunner.testCase.testSuite.project.setActiveEnvironment("Env2")

    Then use the set property value. In my case, I'm transferring here the value of my token from the 1st environment:

    <-- start of Token cleanup code, since I only need the text in the middle -->
    def rawToken = testRunner.testCase.getPropertyValue( "rawToken" )
    def cleanedToken = rawToken.substring(5,120)
    log.info(cleanedToken)
    <-- end of my token cleanup -->
    testRunner.testCase.testSuite.project.setPropertyValue( "Token", cleanedToken )

    Since in your case, these are login details and no more processing involved, maybe you can go straight to the last line. Just replace the variable I used with those you have for the logins.

     

     

    Regards,

    Debz

2 Replies

  • Debz's avatar
    Debz
    Contributor

    Hi,

     

    At the end of your test on the 1st environment, change the active environment to Env2 through Groovy step:

    testRunner.testCase.testSuite.project.setActiveEnvironment("Env2")

    Then use the set property value. In my case, I'm transferring here the value of my token from the 1st environment:

    <-- start of Token cleanup code, since I only need the text in the middle -->
    def rawToken = testRunner.testCase.getPropertyValue( "rawToken" )
    def cleanedToken = rawToken.substring(5,120)
    log.info(cleanedToken)
    <-- end of my token cleanup -->
    testRunner.testCase.testSuite.project.setPropertyValue( "Token", cleanedToken )

    Since in your case, these are login details and no more processing involved, maybe you can go straight to the last line. Just replace the variable I used with those you have for the logins.

     

     

    Regards,

    Debz