Working With Project and Project Suite Variables in Keyword Tests

Applies to TestComplete 15.68, last modified on October 16, 2024

Project and project suite variables can be used in keyword tests. Usually, you create variables before starting your test and assign the needed values to them during the test run. The sections below explain how to work with project and project suite variables from TestComplete keyword tests.

Note: You can work with your project and project suite variables in keyword tests in the same way you work with them in scripts by using the Run Code Snippet operation. Script operations provide a wide range of actions, for example, adding and removing project or project suite variables during the test run.

Modifying Variable Values

To modify the value of a project or project suite variable, use the Set Variable Value operation:

  1. Add the Set Variable Value operation to your keyword test. TestComplete will show a wizard in which you can configure the operation.

  2. On the first page of the wizard, choose the variable you want to modify.

    You can add a new variable by clicking Add Variable and specifying the variable's name in the Add Variable wizard.

  3. If you selected a table variable, specify the zero-based column and row indexes of the table elements to be set.

  4. On the last page of the wizard, select the type of the parameter's value from the Mode drop-down list. Here is a list of the available modes:

    Mode Description
    Constant A number, string, Boolean value or any other hard-coded value. Select the data type from the Type combo box (more info).
    Code Expression A one-line code in the scripting language of your TestComplete project (more info).
    Variable A keyword test variable, project variable, project suite variable or network suite variable. Select the needed variable from the drop-down list in the Value box (more info).
    Last Operation Result   The return value of the operation that was run before the edited operation (more info).
    Test Parameter The parameter of the current keyword test. Select the needed parameter from the drop-down list in the Value box (more info).
    Onscreen Object An application object. To select the needed object, click the ellipsis button in the Value box (more info).
    Table Data A value from the DB table variable defined in the current keyword test, project or project suite. Select the needed variable from the drop-down list in the Value box (more info).
    Object Property A property of an application object (more info).
    File Name A fully-qualified file name. To browse for the needed file, click the ellipsis button in the Value box (more info)
  5. Enter the new parameter value and click Finish.

Obtaining Variable Values

To use the value of a project of project suite variable in your test:

  • In the Operation Parameters dialog, select the Value cell and click the ellipsis button. This dialog is usually the last page of the wizard used to create or edit the operation.

  • In the Edit Parameter or Edit Value dialog, select the Variable mode and use the drop-down window to select the needed variable.

    Note: For project or project suite variables of the String, Integer, Boolean, and Double type, the list shows the current variable value making the choice easier.

Creating Project and Project Suite Variables

To create project or project suite variables, use the Variables page of the Project or ProjectSuite editor:

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

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

  3. Right-click within the appropriate section of the Variables page and select New Item.

    • Variables created in the Temporary Variables section do not keep data between test runs. So, each time you start your test, these variables have their default values.

    • Variables created in the Persistent Variables section keep data after the test run. The data is saved to the .tcLS file. You can use these variables for further testing.

      Note: Object, Table and DB Table variables cannot be persistent.
  4. TestComplete will add a new row to the Variables table. You can then enter the needed values in the table cells.

Removing Project and Project Suite Variables

To delete project or project suite variables, use the Variables page of the Project or ProjectSuite editor:

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

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

  3. Right-click within the variable you want to delete and select Delete.

  4. TestComplete will delete the variable.

See Also

Project And Project Suite Variables
About Project And Project Suite Variables
Variables Page

Highlight search results