Forum Discussion

Simon_InT's avatar
Simon_InT
Contributor
7 years ago

Is there a way of using a project suite variable within a project variable?

I have a project suite with multiple projects. Does anyone know if there is way to use a project suite variable within a project variable? For example, I want to do something like this:

 

Project Suite variable:

Name = "ProjectSuiteVariable"

Type = String

Value = "Variable1"

 

Project variable:

Name = "ProjectVariable"

Type = String

ValueProjectSuiteVariable + "Variable2"

  • shankar_r's code is correct for use within a script routine or when using the Set Variable Value operation of a keyword test.  However, you can't do such code within the Variables tab of the project.  To do what you want to do, it will have to be implemented some way in code... declare the two variables, one at the project level and one at the project suite level and then set the project level value in code as indicated above.

     

    Keep in mind that the "Value" field when you are declaring a variable is simply the default value that, unless otherwise specified, is used whenever the variable is called.

     

     

  • shankar_r's avatar
    shankar_r
    Community Hero

    Yes, you can do. Project suite variable can be accessed from all child projects of the project suite.

     


    from TestComplete document

    Project suite variables are similar to project variables. They store values that are specific to workstation and they can store their values between the test runs. The only difference is that their values are shared with all projects belonging to the project suite. That is, a project suite variable is available in any project that belongs to the suite while project variables are available only within the project to which they belong. If a project changes a project suite variable, the projects that run after it in the suite will use the changed value. From this point of view project suite variables are very useful for exchanging data between projects.

    Ref: https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/about.html#basic-concepts-and-fields-of-applications


    1. Create variable in project suite
    2. Go to project where you want to use it.
    3. you can get access by typing ProjectSuite.Variables.<your project suite variable name>
    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      shankar_r's code is correct for use within a script routine or when using the Set Variable Value operation of a keyword test.  However, you can't do such code within the Variables tab of the project.  To do what you want to do, it will have to be implemented some way in code... declare the two variables, one at the project level and one at the project suite level and then set the project level value in code as indicated above.

       

      Keep in mind that the "Value" field when you are declaring a variable is simply the default value that, unless otherwise specified, is used whenever the variable is called.

       

       

  • I suspected the only way I could do it would be in the code, however I just wanted to check if there was any way I could do it in the variable tab configuration. Thanks tristaanogre and shankar_r

    • shankar_r's avatar
      shankar_r
      Community Hero

      One more option can be used here,

       

      You can manually create two persistent variable in Variables tab of Project and ProjectSuite with some default value.

      Where ever you want you can change that.

       

      Default Value A project can be shared between several testers working on different workstations (see Using Test Projects in Shared Mode). The variable values are computer-specific. Using the Default Value column, you can specify the value that will be used when the project is opened for the first time on the remote computer. Default Value is stored in the project file and it is common for all computers for all testers that use the project. If you modify a value in this column, the resulting changes will modify the Default Value for all users who share the project with you.

      The default value cannot be set or read for Object type variables. The column displays {Object temporary variable [unassigned]} for these variables.

      ref: https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/common/variables-page.html

      However, if you want to change the default value you have to do it manually.