cancel
Showing results for 
Search instead for 
Did you mean: 

Project Custom Properties and Environments Custom Properties

Occasional Contributor

Project Custom Properties and Environments Custom Properties

Hi,

 

I'm having a problem with Project Custom Properties and Environments Custom Properties.

 

I have a Project Custom Property set up ("Timestamp") and a Groovy Load Script that runs to set this.

 

This was working fine until I started adding Environments.

 

There is now a "Timestamp" Custom Property for each environment, which is blank and doesn't get set by the Groovy Load Script. (Update: Only the active environment's custom property is set by the Load Script when the project is loaded)

 

Is there a way arou nd this, or is this a bug?

 

Thanks

7 REPLIES 7
Community Hero

Re: Project Custom Properties and Environments Custom Properties

Can you show the relevant script that you are talking about for review?


Regards,
Rao.
Occasional Contributor

Re: Project Custom Properties and Environments Custom Properties

Sure, this is the Load Script:

 

Date date = new Date()

String newDateTime = date.format("yyyy-MM-dd'T'HH:mm:ss.SSS")

 

project.setPropertyValue("Timestamp", newDateTime)

Community Hero

Re: Project Custom Properties and Environments Custom Properties

This seems to be ok. Where do you experience the issue?


Regards,
Rao.
Occasional Contributor

Re: Project Custom Properties and Environments Custom Properties

Only the active environment's custom property is set by the Load Script when the project is loaded, switching to an inactive environment removes the custom property

Community Hero

Re: Project Custom Properties and Environments Custom Properties

You can try the following groovy script code to set the property value per Environment:

 

 


int names = testRunner.testCase.testSuite.project.getEnvironmentCount(); def proj = testRunner.testCase.testSuite.project; for (int i = 0; i < names; i++) { def env = testRunner.testCase.testSuite.project.getEnvironmentAt(i); proj.setActiveEnvironment(env.name); proj.setPropertyValue("PropertyName", "PropertyValue"); }

 

 

 

 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Occasional Contributor

Re: Project Custom Properties and Environments Custom Properties

Thank you for the script.

I still think that one should have a way to define a project property that is global to all environments.

Highlighted
Community Leader

Re: Project Custom Properties and Environments Custom Properties

Have you looked at Global Properties?

 

https://support.smartbear.com/readyapi/docs/configure/preferences/global-properties.html

 

These may or may not suit your need.

New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win