Articles

[Collapse]TestComplete/viewarticle/63445/
 [Expand]General Information/viewarticle/63445/
 [Expand]Using Help System/viewarticle/55799/
 [Expand]Getting Started Tutorial/viewarticle/56246/
 [Collapse]Using TestComplete/viewarticle/57875/
  [Expand]TestComplete User Interface, Projects and Settings/viewarticle/57876/
  [Expand]Creating, Recording and Running Tests/viewarticle/56646/
  [Expand]Test Results/viewarticle/55010/
  [Collapse]Enhancing Tests/viewarticle/56964/
   [Expand]Parameterizing Tests/viewarticle/56865/
   [Expand]Running Tests on Multiple Operating Systems/viewarticle/62743/
   [Expand]Testing Applications in Low-Level Mode/viewarticle/55190/
   [Expand]Handling Events/viewarticle/56222/
   [Collapse]Using Variables/viewarticle/56794/
    [Collapse]Variable Collections/viewarticle/56808/
     [Collapse]Project and Project Suite Variables/viewarticle/55668/
       Project And Project Suite Variables - Overview/viewarticle/55666/
       Working With Project and Project Suite Variables in Scripts/viewarticle/56792/
       Project and Project Suite Editor - Variables Page/viewarticle/55388/
      Keyword Test Variables/viewarticle/56810/
      Network Suite Variables/viewarticle/56547/
    [Expand]Variable Data Types/viewarticle/56807/
   [Expand]User Forms/viewarticle/55164/
   [Expand]Working With Files and Databases/viewarticle/56877/
   [Expand]Using External Functions/viewarticle/56836/
   [Expand]Using ActiveX Objects/viewarticle/55338/
   [Expand]Monitoring Performance/viewarticle/56380/
   [Expand]Tracing Exceptions, Crashes and Freezes in Tested Applications/viewarticle/56499/
   [Expand]Connected and Self-Testing Applications/viewarticle/56563/
   [Expand]Using Optical Character Recognition/viewarticle/55011/
   [Expand]Improving Object Recognition/viewarticle/56888/
    Integration With AQtime/viewarticle/55059/
    Using Environment Variables/viewarticle/64014/
    Working With Passwords and Other Sensitive Data/viewarticle/63995/
  [Expand]Teamwork and Integration Into QA Process/viewarticle/57266/
  [Expand]Extending TestComplete/viewarticle/57655/
  [Expand]Automating TestComplete/viewarticle/57438/
  [Expand]Best Practices/viewarticle/64008/
 [Expand]Testing Types/viewarticle/62721/
 [Expand]Applications Testing/viewarticle/62606/
 [Expand]Working With Application Objects and Controls/viewarticle/55815/
 [Expand]Samples and Tutorials/viewarticle/56239/
 [Expand]References/viewarticle/57878/
 [Expand]Other Tools That Help You Test Better/viewarticle/63442/
 [Expand]TestComplete 10 Licensing Guide/viewarticle/63451/
Updated: 7/15/2014 Applies To: TestComplete 10 Rating: No votes Click to rate: PoorNot badAverageGoodExcellent
Project And Project Suite Variables

Project And Project Suite Variables - Overview

Project and project suite variables are shared among a current project or a project suite and are used to store data between the test runs.

The following sections provide detailed information about project and project suite variables.

Basic Concepts and Fields of Applications

Project and project suite variables are used to store values specific to project and project suites. You create and modify these variables on the Variables page of the project or project suite editors.

Project variables only work for the current project. You can use them to share data between tests of various types included in your project, for instance, between scripts and keyword tests.

Project variables are specific to the workstation on which the project is opened, that is, they store information that is specific to the workstation and their values may differ from other computer to another. An example of this data is file paths. They are specific to the computer, on which the project is opened. Let’s suppose you have a test that exports data to a file on your hard disk. If this test were run on several machines, it would be nice if the file path were specific to each computer where the test is run. You can create a global script variable and change its value in the source code before running the test on each computer. With the projects variables feature you can perform this task in a more convenient way: you can create and modify the variable visually.

Project variables can store their values between test runs. This functionality is not applied to the Object, Table and DB Table variable types (see below), but can be used for variables of other types. In order for a variable to store its values between test runs, you must create it in the Persistent Variables section of the Variables page of the project or project suite editor. If the variable is created in this section, then after the test run is over, TestComplete will save the variable value to the .tcLS file that corresponds to your project and uses the stored value next time you run the test. This feature lets you use project variables to share data between test sessions. But do this carefully, because a variable will have the stored value rather than the initial value before the next run and this may cause the test to fail.

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.

Creating Project and Project Suite Variables

To create these variables use the Variables pages of the Project and ProjectSuite editors. To view this page, do the following:

  • Select the Project or ProjectSuite item in the Project Explorer panel and choose Edit from the context menu, or simply double-click this project item.

  • In the resulting Project or ProjectSuite editor of the Workspace panel, switch to the Variables page.

Types of Project and Project Suite Variables

Project and project suite variables can store values of the following types:

  • String - Use this type for variables that will store strings and individual characters.

  • Integer - Use this type for variables that will store integer numerical values.

  • Double - Use this type for variables that will store floating-point numeric values and dates.

  • Boolean - Use this type for variables that will store True or False.

  • Password - Use this type for variables that will store strings with sensitive information, such as passwords.

  • Object - Use this type for variables that will store object references.

  • Table - Use this type for variables that will store two-dimensional arrays.

  • DB Table - Use this type for variables that will provide access to an external data storage, such as a database, an Excel or CSV file. For detailed information on these variables, see .

String, Integer, Double and Boolean variables preserve their values between test runs. You can use these variables to store dynamically calculated values that you are going to reuse in subsequent test runs.

Object, Table and DB Table variables, on the other hand, are automatically reset to their original state after a test run. Any changes made to these variables during a test run are discarded once the test is finished.

Working With Project and Project Suite Variables in Scripts and Keyword Tests

Project and project suite variables can be used in scripts and keyword tests.

Working in Scripts

To access this variables from scripts, use the construction Project.Variables.variable_name or ProjectSuite.Variables.variable_name, for example:

VBScript

Project.Variables.MyVariable1 = 10
ProjectSuite.Variables.MyVariable2 = "My string value"

JScript

Project.Variables.MyVariable1 = 10;
ProjectSuite.Variables.MyVariable2 = "My string value";

DelphiScript

Project.Variables.MyVariable1 := 10;
ProjectSuite.Variables.MyVariable2 := 'My string value';

C++Script, C#Script

Project["Variables"]["MyVariable1"] = 10;
ProjectSuite["Variables"]["MyVariable2"] = "My string value";

The variable name must comply with the naming rules of the scripting language you are using.

You can also create and remove variables from scripts. For complete information about this, see Working With Project and Project Suite Variables in Scripts.

Working in Keyword Tests

You can use project and project suite variables to specify parameters of keyword test operations. You do this in the Operation Parameters dialog that is used to view and modify the operation parameters. For detailed information about this, see Specifying Operation Parameters.

To assign a value to a project or project suite variable from a keyword test, use the Set Variable Value operation. In the Operation Parameters dialog you can specify the desired variable and the value to be assigned.

To set the value of a project or project suite variable, you can also use the Run Code Snippet operation and execute the script code described above in the Working in Scripts section.

See also
Using Variables | Project And Project Suite Variables | Working With Project and Project Suite Variables in Scripts


© 2014 SmartBear Software. All rights reserved.
Email Send feedback on this document