Specifics of Usage Common for All Languages

Applies to TestComplete 14.72, last modified on April 22, 2021

All scripting languages supported by TestComplete have the following specifics related to naming conventions:

  • You can skip the object name when calling methods of some program objects in scripts. This feature is supported by the aqConvert, aqEnvironment, aqObject, aqUtils, BuiltIn, Utilities and Win32API objects. For example, you can call the Delay method of the aqUtils object as aqUtils.Delay(…) or as simply Delay(…). Custom objects can support this functionality as well.

    However, if the method name coincides with the name of an intrinsic function of the scripting language, TestComplete will call that function rather than the object’s method.

    To solve the problem, put the object name before the method name. For example:

    JavaScript, JScript

      // Calls the InputBox method of the BuiltIn object
      var str = BuiltIn.InputBox("InputBox Sample", "Enter the number of test iterations:", "3");
      Log.Message(str);

      // Calls the VBScript's InputBox function
      var str = InputBox("Enter the number of test iterations:", "InputBox Sample", "3");
      Log.Message(str);

    Python

    def Test():  
      # Calls the InputBox method of the BuiltIn object
      str = BuiltIn.InputBox("InputBox Sample", "Enter the number of test iterations:", "3")
      Log.Message(str)
    
      # Calls the VBScript's InputBox function
      str = InputBox("Enter the number of test iterations:", "InputBox Sample", "3")
      Log.Message(str)

    VBScript

      ' Calls the InputBox method of the BuiltIn object
      str = BuiltIn.InputBox("InputBox Sample", "Enter the number of test iterations:", "3")
      Log.Message(str)

      ' Calls the VBScript's InputBox function
      str = InputBox("Enter the number of test iterations:", "InputBox Sample", "3")
      Log.Message(str)

    DelphiScript

    var str;
    ...
      // Calls the InputBox method of the BuiltIn object
      str := BuiltIn.InputBox("InputBox Sample", "Enter the number of test iterations:", "3");
      Log.Message(str);

      // Calls the VBScript's InputBox function
      str := InputBox("Enter the number of test iterations:", "InputBox Sample", "3");
      Log.Message(str);

    C++Script, C#Script

    // Calls the InputBox method of the BuiltIn object
      var str = BuiltIn["InputBox"]("InputBox Sample", "Enter the number of test iterations:", "3");
      Log["Message"](str);

      // Calls the VBScript's InputBox function
      var str = InputBox("Enter the number of test iterations:", "InputBox Sample", "3");
      Log["Message"](str);

  • When calling routines or variables declared in another unit, the name of the external unit may be omitted. However, if the routine’s (or variable’s) name coincides with the name of an external unit, or if it coincides with the name of a routine (variable) declared in the current unit, then prefixing the call with the unit name is mandatory.
  • When you create a global variable, it is defined for the entire unit. These variables are not visible in the Locals panel. To see the value of a global variable while debugging your code, use the Watch List panel, or the Evaluate dialog. You can also assign a global variable to a local variable to see it in the Locals panel.

See Also

Script Tests
About Script Tests
Selecting the Scripting Language

Highlight search results