cancel
Showing results for 
Search instead for 
Did you mean: 

Project Custom Properties and Environments Custom Properties

Highlighted
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

8 REPLIES 8
Highlighted
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.
Highlighted
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)

Highlighted
Community Hero

Re: Project Custom Properties and Environments Custom Properties

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


Regards,
Rao.
Highlighted
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

Highlighted
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!
Highlighted
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.

Super Contributor

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.

Highlighted
Occasional Contributor

Re: Project Custom Properties and Environments Custom Properties

Yes. Sure I know the Global Properties.

I still think one should have Project Global Properties Smiley Happy

Or a boolean that would set a Project Properties "instanciated per environment" or "always equal in all environments".