Forum Discussion

archana1's avatar
archana1
Occasional Contributor
5 years ago

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()

 

    • groovyguy's avatar
      groovyguy
      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);

       

      • archana1's avatar
        archana1
        Occasional Contributor

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