cancel
Showing results for 
Search instead for 
Did you mean: 

Active enviroment of other project in current project using groovy

Highlighted
Occasional Contributor

Active enviroment of other project in current project using groovy

HI Team,

I am trying to access active environment of a project into my current project but it always return me default environment even though environment is not default.

Code is below:

project = new WsdlProject(projectPath+"/SharedService-readyapi-project.xml");
log.info project.getActiveEnvironment().getName()

 

4 REPLIES 4
Highlighted
Community Manager

Thank you for posting your query here @archana1 !

Let's see if we can get help from the Community on this one🙂

 

@HimanshuTayal @msiadak @nmrao @sprice090161 

What do you think is happening?

 


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Community Hero

My example requires the other project to be loaded and open in the current workspace, but it has worked for me. Is that sufficient, or do you need to know this from a project that is not imported and open?

 

def workspace = context.testCase.testSuite.project.workspace.
def otherProject = workspace.projects["ProjectName"];

def otherName = otherProject.getActiveEnvironment().getName();

log.info(otherName);

 




---

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

Workspace is not working when working from command line. How else can i do it?

Highlighted
Community Hero

Okay, so you are trying to do this from command line. You are right, latching onto the workspace and another project will not work, because running it with testrunner.bat/testrunner.sh will only load the one project. In that particular instance, I have yet to find a good answer on how to get properties/data from one project to another short of saving them to a common properties file with one project and reading them from another.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors