GetVariableCategory Method

Applies to TestComplete 15.0, last modified on October 22, 2021

Description

This method returns the category of the variable specified by its name or index within the collection. This is the string shown in the Category column of the Variables page.

Declaration

VariablesObj.GetVariableCategory(Variable)

VariablesObj An expression, variable or parameter that specifies a reference to a Variables object
Variable [in]    Required    Variant    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Variable

Either the variable’s unique name or its index within the variables collection. The index is zero-based, so the first variable has the index 0, the second - 1 and so on.

Result Value

String specifying the variable’s category.

Remarks

TestComplete does not pass the category of network suite variables to remote projects in order to increase the network suite performance. So, in remote projects’ scripts the NetworkSuite.Variables.GetVariableCategory method returns an empty string.

If a variables collection does not contain the specified variable, an error occurs.

Example

The following code snippet obtains project suite variables and posts their properties to the test log.

JavaScript, JScript

function Variables()
{

  var Variables, Count, VarName;

  // Obtains a list of project suite variables
  Variables = ProjectSuite.Variables;
  // Obtains the total number of variables in the project suite
  Count = Variables.VariableCount;

  // Iterates through the project suite variables
  for (var i = 0; i < Count; i++)
    {
    // Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i);
    Log.AppendFolder(VarName);

    // Posts the variable’s category to the test log
    Log.Message("Category: " + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log.Message("Type: " + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log.Message("Default Value: " + Variables.GetVariableDefaultValue(i));
    // Posts the variable’s description to the test log
    Log.Message("Description: " + Variables.GetVariableDescription(i));

    Log.PopLogFolder();
    }

}

Python

def Variables():

  # Obtains a list of project suite variables
  Variables = ProjectSuite.Variables
  # Obtains the total number of variables in the project suite
  Count = Variables.VariableCount

  # Iterates through the project suite variables
  for i in range (0, Count):
    # Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i)
    Log.AppendFolder(VarName)

    # Posts the variable's category to the test log
    Log.Message("Category: " + str(Variables.GetVariableCategory(i)))
    # Posts the variable's type to the test log
    Log.Message("Type: " + str(Variables.GetVariableType(i)))
    # Posts the variable's default value to the test log
    Log.Message("Default Value: " + str(Variables.GetVariableDefaultValue(i)))
    # Posts the variable's description to the test log
    Log.Message("Description: " + str(Variables.GetVariableDescription(i)))

    Log.PopLogFolder()

VBScript

Sub Variables

  Dim Variables, Count, VarName

  ' Obtains a list of project suite variables
  Set Variables = ProjectSuite.Variables
  ' Obtains the total number of variables in the project suite
  Count = Variables.VariableCount

  ' Iterates through the project suite variables
  For i = 0 To Count - 1
    ' Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i)
    Log.AppendFolder(VarName)

    ' Posts the variable’s category to the test log
    Log.Message("Category: " & Variables.GetVariableCategory(i))
    ' Posts the variable’s type to the test log
    Log.Message("Type: " & Variables.GetVariableType(i))
    ' Posts the variable’s default value to the test log
    Log.Message("Default Value: " & Variables.GetVariableDefaultValue(i))
    ' Posts the variable’s description to the test log
    Log.Message("Description: " & Variables.GetVariableDescription(i))

    Log.PopLogFolder
  Next

End Sub

DelphiScript

procedure Variables();
var Variables, Count, VarName, i;

begin

  // Obtains a list of project suite variables
  Variables := ProjectSuite.Variables;
  // Obtains the total number of variables in the project suite
  Count := Variables.VariableCount;

  // Iterates through the project suite variables
  for i := 0 to Count - 1 do
    begin
    // Obtains a variable's name and posts it to the test log
    VarName := Variables.GetVariableName(i);
    Log.AppendFolder(VarName);

    // Posts the variable’s category to the test log
    Log.Message('Category: ' + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log.Message('Type: ' + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log.Message('Default Value: ' + aqConvert.VarToStr(Variables.GetVariableDefaultValue(i)));
    // Posts the variable’s description to the test log
    Log.Message('Description: ' + Variables.GetVariableDescription(i));

    Log.PopLogFolder;
    end;

end;

C++Script, C#Script

function Variables()
{

  var Variables, Count, VarName;

  // Obtains a list of project suite variables
  Variables = ProjectSuite["Variables"];
  // Obtains the total number of variables in the project suite
  Count = Variables["VariableCount"];

  // Iterates through the project suite variables
  for (var i = 0; i < Count; i++)
    {
    // Obtains a variable's name and posts it to the test log
    VarName = Variables["GetVariableName"](i);
    Log["AppendFolder"](VarName);

    // Posts the variable’s category to the test log
    Log["Message"]("Category: " + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log["Message"]("Type: " + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log["Message"]("Default Value: " + Variables.GetVariableDefaultValue(i));
    // Posts the variable’s description to the test log
    Log["Message"]("Description: " + Variables.GetVariableDescription(i));

    Log["PopLogFolder"]();
    }

}

See Also

GetVariableDescription Method
GetVariableName Method
GetVariableType Method

Highlight search results