Aliases Object

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The Aliases object provides access to objects in the Name Mapping repository (specifically, to the Aliases tree). You can access an object by its alias using the following syntax:

JavaScript, JScript

Aliases.browser.pageExample.linkProducts.Click();
// or
var link = Aliases.browser.pageExample.linkProducts;
link.Click();

Python

Aliases.browser.pageExample.linkProducts.Click()
# or
link = Aliases.browser.pageExample.linkProducts
link.Click()

VBScript

Aliases.browser.pageExample.linkProducts.Click
' or
Set link = Aliases.browser.pageExample.linkProducts
link.Click

DelphiScript

Aliases.browser.pageExample.linkProducts.Click;
// or
link := Aliases.browser.pageExample.linkProducts;
link.Click;

C++Script, C#Script

Aliases["browser"]["pageExample"]["linkProducts"]["Click"]();
// or
var link = Aliases["browser"]["pageExample"]["linkProducts"];
link["Click"]();

Members

Example

The following example uses aliases to refer to objects in Notepad. Before you run this example, add Notepad’s window to the Name Mapping repository (see Mapping Objects Manually).

JavaScript, JScript

function Test()
{
  // Launch Notepad if it's not running
  if (! Aliases.notepad.Exists)
    WshShell.Run("notepad");

  // Enter text in Notepad
  var wnd = Aliases.notepad.wndNotepad;
  wnd.Maximize();
  wnd.Keys("Hello, world!");
}

Python

def Test():
  # Launch Notepad if it's not running
  if not Aliases.notepad.Exists:
    WshShell.Run("notepad")
  # Enter text in Notepad
  wnd = Aliases.notepad.wndNotepad
  wnd.Maximize()
  wnd.Keys("Hello, world!")

VBScript

Sub Test
  Dim wnd

  ' Launch Notepad if it's not running
  If Not Aliases.notepad.Exists Then
    WshShell.Run "notepad"
  End If

  ' Enter text in Notepad
  Set wnd = Aliases.notepad.wndNotepad
  wnd.Maximize
  wnd.Keys "Hello, world!"
End Sub

DelphiScript

procedure Test;
var wnd;
begin
  // Launch Notepad if it's not running
  if not Aliases.notepad.Exists then
    WshShell.Run('notepad');

  // Enter text in Notepad
  wnd := Aliases.notepad.wndNotepad;
  wnd.Maximize;
  wnd.Keys('Hello, world!');
end;

C++Script, C#Script

function Test()
{
  // Launch Notepad if it's not running
  if (! Aliases["notepad"]["Exists"])
    WshShell["Run"]("notepad");

  // Enter text in Notepad
  var wnd = Aliases["notepad"]["wndNotepad"];
  wnd["Maximize"]();
  wnd["Keys"]("Hello, world!");
}

See Also

Name Mapping
Access Objects by Aliases

Highlight search results