AutomatedQA: Award-winning tools for software testing and quality assurance

Home » Products » TestComplete » FAQs » TestComplete FAQ - Testing Tasks - Part 1

TestComplete 6 FAQ - Testing Tasks - Part 1

This page contains answers to frequently asked questions about TestComplete ver. 4 - 6. For answers to questions on TestComplete 3, see TestComplete 3 FAQ.



Q.: If the window (or process) does not exist, I get an error. How can I check if the window (process) exists?

A.: Use the Exists property. Each process or window object in TestComplete has the Exists property. It returns True, if the tested object actually exists in the system, otherwise, it returns False. For instance:

[VBScript]
' Get the process object
Set p = Sys.WaitProcess("MyApplication", 5000)
If p.Exists Then
' Continue script execution
Else
Log.Error "The process does not exist."
End If
[JScript]
// Get the process object
p = Sys.WaitProcess("MyApplication", 5000)
if p.Exists
{
// Continue script execution
}
else
{
Log.Error("The process does not exist.");
}
[DelphiScript]
// Get the process object
p := Sys.WaitProcess('MyApplication', 5000)
if p.Exists then
begin
// Continue script execution
end
else
begin
Log.Error('The process does not exist.');
end;
[C++Script, C#Script]
// Get the process object
p = Sys.WaitProcess("MyApplication", 5000)
if p["Exists"]
{
// Continue script execution
}
else
{
Log["Error"]("The process does not exist.");
}

If you want to avoid error messages that are posted to the log by the Process, Window or Child functions when the required process or window does not exist, use the WaitWindow, WaitProcess or WaitChild routines. They delay the script execution for the specified period of time or until the specified object appears. They do not post any messages to the test log since Process or Window do. The general rule is that the Process, Window and Child methods should be used when you are sure that the required object already exists. WaitProcess, WaitWindow and WaitChild should be used when you are not sure if the object exists.

One note: Suppose, you have a window object with the name Window("WndClass", "WndCaption", -1). You can wait for it using the following code:

[VBScript]
p.WaitWindow "WndClass*", "WndCaption*", -1, 5000

[JScript]
p.WaitWindow("WndClass*", "WndCaption*", -1, 5000);

[DelphiScript]
p.WaitWindow('WndClass*', 'WndCaption*', -1, 5000);

[C++Script, C#Script]
p["WaitWindow"]("WndClass*", "WndCaption*", -1, 5000);

If you map this object to a new name, like MyWindow, you can still use this code to wait for the object. However, name mapping means that you want to avoid problems that may occur due to changes in object attributes in different builds of the tested application. You can wait for the object using the following code:

[VBScript]
p.WaitChild "MyWindow", 5000

[JScript]
p.WaitChild("MyWindow", 5000);

[DelphiScript]
p.WaitChild('MyWindow', 5000);

[C++Script, C#Script]
p["WaitChild"]("MyWindow", 5000);

The Window and Child methods are typically used to address objects of non-Open (black-box) applications. Objects of Open Applications are addressed with special methods like WinFormsObject, VBObject, VCLObject, AWTObject and others. For these methods TestComplete also offers “waiting” analogues: WaitWinFormsObject, WaitVBObject, WaitVCLObject and others. The difference between these “waiting” and “non-waiting” methods is the same as the difference between Window and WaitWindow.

To get a process or window you can also use the Find, FindId and FindChild methods, which return the first found object with the specified properties.

[VBScript]
w = p.Find "WndCaption", "New Document ", 5000

[JScript]
w = p.Find("WndCaption", "New Document ", 5000);

[DelphiScript]
w := p.Find('WndCaption', 'New Document', 5000);

[C++Script, C#Script]
w = p["Find"]("WndCaption", "New Document ", 5000);

Back to list

Q.: How do I delay the script execution until the desired window appears on screen?

A.: The first solution is to check the VisibleOnScreen property in a loop:

[VBScript]

b = False
Do Until b
  w = p.WaitWindow("WindowClassName", "WindowCaption", 1, 500)
  b = w.VisibleOnScreen
Loop
[JScript]

b = false
while(! b)
{
  w = p.WaitWindow("WindowClassName", "WindowCaption", 1, 500)
  b = w.VisibleOnScreen
}
[DelphiScript]

repeat
  w := p.WaitWindow('WindowClassName', 'WindowCaption', 1, 500);
until w.VisibleOnScreen;
[C++Script, C#Script]

b = false;
while(! b)
{
  w = p.WaitWindow("WindowClassName", "WindowCaption", 1, 500);
  b = w.VisibleOnScreen;
}

The second solution is to call the object’s WaitProperty method. It lets you pause the script execution until the specified object property becomes equal to the specified value, or until the specified timeout is over:

[VBScript]

Set w = Sys.Process("MyApp").Window("TMainFrm","MyApplication *")
If w.WaitProperty("VisibleOnScreen", True, 2000) Then
  ' Window is visible
Else
  ' Window is not visible
WEnd
[JScript]

var w = Sys.Process("MyApp").Window("TMainFrm","MyApplication *");
if(w.WaitProperty("VisibleOnScreen", true, 2000)
  // Window is visible
else
  // Window is not visible
[DelphiScript]

var
  w : OleVariant;
begin
  w := Sys.Process('MyApp').Window('TMainFrm','MyApplication *');
  if btn.WaitProperty(VisibleOnScreen, True, 2000) then
    // Window is visible
  else
    // Window is not visible
[C++Script, C#Script]

var w = Sys["Process"]("MyApp")["Window"]("TMainFrm","MyApplication *");
if(w["WaitProperty"]("VisibleOnScreen", true, 2000)
  // Window is visible
else
  // Window is not visible

For more information, see the “Waiting for Object State Changes” and “Waiting for a Process or Window Activation" help topics.

Back to list

Q.: How do I delay the script execution unless a window is closed?

A.: This situation is practically the same as described above. The only difference is in the property to be checked by the WaitProperty method. In this case we should wait for the window’s Exists property to become False.

[VBScript] 

Set w = p.WaitWindow("WindowClassName", "WindowCaption")
If w.Exists Then
  Call w.WaitProperty("Exists", False, 100000)
End If
[JScript] 

w = p.WaitWindow("WindowClassName", "WindowCaption");
if (w.Exists) w.WaitProperty("Exists", false, 100000);
[DelphiScript]

w := p.WaitWindow('WindowClassName', 'WindowCaption');
if w.Exists then w.WaitProperty('Exists', false, 100000);
[C++Script, C#Script]

w = p["WaitWindow"]("WindowClassName", "WindowCaption");
if (w["Exists"]) w["WaitProperty"]("Exists", false, 100000);

Back to list

Q.: How can I find the focused control?

A.: Use the Sys.Desktop.FocusedWindow property. Here is an example of how to use this property:

[VBScript] 

Sub TestFocusedWindowNew;
  Sys.Process("Project1").Window("TForm1", "*").Activate
  Set FocusedWindow=Sys.Desktop.FocusedWindow
  Log.Message(FocusedWindow.Name)
End Sub
[JScript] 

function TestFocusedWindowNew()
{
  var FocusedWindow;
  Sys.Process("Project1").Window("TForm1", "*").Activate();
  FocusedWindow=Sys.Desktop.FocusedWindow();
  Log.Message(FocusedWindow.Name);
}
[DelphiScript]

procedure TestFocusedWindowNew;
var FocusedWindow: OleVariant;
begin
  Sys.Process('Project1').Window('TForm1', '*').Activate;
  FocusedWindow:=Sys.Desktop.FocusedWindow;
  Log.Message(FocusedWindow.Name);
end;
[C++Script, C#Script]

function TestFocusedWindowNew()
{
  var FocusedWindow;
  Sys["Process"]("Project1")["Window"]("TForm1", "*")["Activate"]();
  FocusedWindow=Sys["Desktop"]["FocusedWindow"]();
  Log["Message"](FocusedWindow.Name);
}

Back to list

Q.: Is there a function that returns a window object from the window that is currently in focus?

A.: Yes. Use Sys.Desktop.ActiveWindow.

Back to list

Q.: Is there a way to translate HWND into a Window object?

A.: Yes. The ID property of a Window object specifies the HWND identifier of a window. Each Window object and Processobject contains the FindID method that lets you find the desired window by its ID:

[VBScript]

Dim MyProcessObj, MyWndObj

Set MyProcessObj = Sys.Process(“MyProcess”)
If MyProcess.FindID(HWND_Value, MyWndObj) Then
    ' The window with the specified hwnd was found.
    ' The MyWndObj parameter holds the corresponding Windows object.

Else
    ' Window not found.
End If

Back to list

Q.: How do I simulate a keystroke from script code?

A.: You can simulate keystrokes from your scripts by using the Sys.Keys, Desktop.Keys or Window.Keys methods. The difference between these methods is that the Window.Keys method sends the keystrokes to an individual window, while the keystrokes synthesized by Desktop.Keys or Sys.Keys are sent to the currently focused window. All of these methods have one parameter - a string of characters to be typed. This string may include special constants that simulate key presses of the shift and functional keys (CTRL, SHIFT, ALT, F1, TAB and others). For example,

[VBScript]
Window.Keys "Hello, wro[BS][BS]orld[Enter]"

[DelphiScript]
Window.Keys('Hello, wro[BS][BS]orld[Enter]');

[JScript]
Window.Keys("Hello, wro[BS][BS]orld[Enter]");

[C++Script, C#Script]
Window["Keys"]("Hello, wro[BS][BS]orld[Enter]");

In most cases Sys.Keys, Desktop.Keys or Window.Keys will fit all your needs. However, these methods have some limitations. For instance, they cannot simulate holding the Shift key for a long period of time, as if you need to hold Shift pressed while you are pressing several keys. The possible solution here is to use the Desktop.KeyDown and LLPlayer.KeyDown methods. These methods simulate a key press specified by its virtual-key code, which can be defined as an integer value (see the Virtual Key Codes article in Microsoft Developer Network library) or as a predefined constant. To refer to the constants without the need to define them in your scripts, you must install the Win32API plug-in in TestComplete.

Note: Do not forget to release the pressed key with the Desktop.KeyUp and LLPlayer.KeyUp methods, otherwise you may encounter abnormal application behavior.

[VBScript]
Sys.Desktop.KeyDown(VK_SHIFT)
Sys.Desktop.Keys "uppercased 1"
Sys.Desktop.KeyUp(VK_SHIFT)

[DelphiScript]
Sys.Desktop.KeyDown(VK_SHIFT);
Sys.Desktop.Keys('uppercased 1');
Sys.Desktop.KeyUp(VK_SHIFT);

[JScript]
Sys.Desktop.KeyDown(VK_SHIFT);
Sys.Desktop.Keys("uppercased 1");
Sys.Desktop.KeyUp(VK_SHIFT);

[C++Script, C#Script]
Sys["Desktop"]["KeyDown"](VK_SHIFT);
Sys["Desktop"]["Keys"]("uppercased 1");
Sys["Desktop"]["KeyUp"](VK_SHIFT);

Back to list

Q.: How to drag an object from one window and drop it to another?

A.: Below is sample code that lets you do this -

[VBScript]
Sub Test;
  WordPadPath = "C:\Program Files\Windows NT\Accessories\WORDPAD.EXE"
  ClientStartX = 30
  ClientStartY = 15
  ClientFinishX = 100
  ClientFinishY = 100
  Call WinExec(WordPadPath, SW_SHOW)
  Set p = Sys.Process("wordpad")
  Set w1 = p.Window("WordPadClass", "*")
  Call w1.Activate
  Call SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW)
  Call Sys.Keys("Test^a")

  Call WinExec(WordPadPath, SW_SHOW) 
  Set p = Sys.Process("wordpad", 2)
  Set w2 = p.Window("WordPadClass", "*")
  Call w2.Activate
  Call SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW)
  Call Sys.Delay(2000)

  x1 = ClientStartX
  y1 = ClientStartY
  x2 = ClientFinishX
  y2 = ClientFinishY
  Call w1.Window("RICHEDIT50W").ClientToScreen(x1, y1)
  Call w2.Window("RICHEDIT50W").ClientToScreen(x2, y2)
  Call w1.Activate
  Call w1.Window("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1)
End Sub
[JScript]

function ClientToScreenX(obj, x) { return obj.SLeft + x; }
function
ClientToScreenY(obj, y) { return obj.STop + y; } function Test() {   var p, w1, w2, path, x1, y1, x2, y2;   WordPadPath = "C:\\Program Files\\Windows NT\\Accessories\\WORDPAD.EXE";   ClientStartX = 30;   ClientStartY = 15;   ClientFinishX = 100;   ClientFinishY = 100;   WinExec(WordPadPath, SW_SHOW);   p = Sys.Process("wordpad");   w1 = p.Window("WordPadClass", "*");   w1.Activate();   SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW);   Sys.Keys("Test^a");   WinExec(WordPadPath,SW_SHOW);   p = Sys.Process("wordpad", 2);   w2 = p.Window("WordPadClass", "*");   w2.Activate();   SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW);   Sys.Delay(2000); x1 = ClientToScreenX(w1.Window("RICHEDIT50W"), ClientStartX);
y1 = ClientToScreenY(w1.Window("RICHEDIT50W"), ClientStartY);
x2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishX);
y2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishY);
  w1.Activate();   w1.Window("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1); }
[DelphiScript]
procedure Test;
var p, w1, w2, path, x1, y1, x2, y2 : OleVariant;
const
  WordPadPath = 'C:\Program Files\Windows NT\Accessories\WORDPAD.EXE';
  ClientStartX = 30;
  ClientStartY = 15;
  ClientFinishX = 100;
  ClientFinishY = 100;
begin
  WinExec(WordPadPath, SW_SHOW);
  p := Sys.Process('wordpad');
  w1 := p.Window('WordPadClass', '*');
  w1.Activate;
  SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW);
  Sys.Keys('Test^a');

  WinExec(WordPadPath,SW_SHOW);
  p := Sys.Process('wordpad', 2);
  w2 := p.Window('WordPadClass', '*');
  w2.Activate;
  SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW);
  Sys.Delay(2000);

  x1 := ClientStartX;
  y1 := ClientStartY;
  x2 := ClientFinishX;
  y2 := ClientFinishY;
  w1.Window('RICHEDIT50W').ClientToScreen(x1, y1);
  w2.Window('RICHEDIT50W').ClientToScreen(x2, y2);
  w1.Activate;
  w1.Window('RICHEDIT50W').Drag(ClientStartX, ClientStartY, x2-x1, y2-y1);
end;
[C++Script, C#Script]

function ClientToScreenX(obj, x) { return obj.SLeft + x; }
function
ClientToScreenY(obj, y) { return obj.STop + y; } function Test() { var p, w1, w2, path, x1, y1, x2, y2; WordPadPath = "C:\\Program Files\\Windows NT\\Accessories\\WORDPAD.EXE"; ClientStartX = 30; ClientStartY = 15; ClientFinishX = 100; ClientFinishY = 100; WinExec(WordPadPath, SW_SHOW); p = Sys["Process"]("wordpad"); w1 = p["Window"]("WordPadClass", "*"); w1["Activate"](); SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW); Sys["Keys"]("Test^a"); WinExec(WordPadPath,SW_SHOW); p = Sys["Process"]("wordpad", 2); w2 = p["Window"]("WordPadClass", "*"); w2["Activate"]() SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW); Sys["Delay"](2000); x1 = ClientToScreenX(w1.Window("RICHEDIT50W"), ClientStartX);
y1 = ClientToScreenY(w1.Window("RICHEDIT50W"), ClientStartY);
x2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishX);
y2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishY);
w1["Activate"](); w1["Window"]("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1); }

Back to list

Q.: How to right-click the application icon in the tray?

A.: You can use the following code. The RightClickTrayIcon routine “right-clicks” the Volume indicator in the system tray and then selects Open Volume Controls from the context menu.

[VBScript]
 
Sub RightClickTrayIcon(Name, ItemName)
  ' Gets the tray. Tray is a toolbar
  Set p = Sys.Process("Explorer")
  Set w = p.Window("Shell_TrayWnd")
  w.Activate
	
  Set show_button = w.WaitWindow("Button", "", 2, 100)
  If show_button.Exists Then
    If show_button.Visible Then
      show_button.Click
      Sys.Delay(1000)
    End If
  End If
	
  ' Get Button Position in the button array
  pos = w.Window("ToolbarWindow32", "", 1).wButtonPos(Name)
  ' Right-clicks the application icon
  x = pos * w.Window("ToolbarWindow32", "", 1).Height + 5
  w.Window("ToolbarWindow32", "", 1).ClickR x, 5
	
  ' Selects an item from the context menu
  w.PopupMenu.Click ItemName
End Sub

Sub Test
  RightClickTrayIcon "Volume", "Open Volume Controls"
End Sub

Back to list

Q.: Can I block user input during test execution?

A.: Yes. To enable or disable the user input, you can call the Windows API BlockInput function in your script. The function uses one parameter that enables or disables the user input. To call the function, you should use the DLL Access plug-in. The code below demonstrates this. Note that the user input will automatically be restored if a user presses Ctrl-Alt-Del during the test run or if the operating system displays a critical error dialog.

[VBScript]

Sub DisableInput
  Set Def_DLL = DLL.DefineDLL("USER32")
  Def_Proc = Def_DLL.DefineProc("BlockInput", vt_b1, vt_b1)
  Set Lib = DLL.Load("USER32.DLL", "USER32")
  Lib.BlockInput(True)
End Sub
 
Sub EnableInput
  Set Def_DLL = DLL.DefineDLL("USER32")
  Def_Proc = Def_DLL.DefineProc("BlockInput", vt_b1, vt_b1)
  Set Lib = DLL.Load("USER32.DLL", "USER32")
  Lib.BlockInput(False)
End Sub

[JScript]

function DisableInput()
{
  var Def_DLL = DLL.DefineDLL("USER32");
  var Def_Proc = Def_DLL.DefineProc("BlockInput", vt_b1, vt_b1);
  var Lib = DLL.Load("USER32.DLL", "USER32");
  Lib.BlockInput(true);
}

function EnableInput()
{
  var Def_DLL = DLL.DefineDLL("USER32");
  var Def_Proc = Def_DLL.DefineProc("BlockInput", vt_b1, vt_b1);
  var Lib = DLL.Load("USER32.DLL", "USER32");
  Lib.BlockInput(false);
}

[DelphiScript]

procedure DisableInput;
var
  Def_DLL, Def_Proc, Lib : OleVariant;
begin
  Def_DLL := DLL.DefineDLL('USER32');
  Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
  Lib := DLL.Load('USER32.DLL', 'USER32');
  Lib.BlockInput(true);
end;

procedure EnableInput;
var
  Def_DLL, Def_Proc, Lib : OleVariant;
begin
  Def_DLL := DLL.DefineDLL('USER32');
  Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
  Lib := DLL.Load('USER32.DLL', 'USER32');
  Lib.BlockInput(false);
end;

[C++Script, C#Script]

function DisableInput()
{
  var Def_DLL = DLL["DefineDLL"]("USER32");
  var Def_Proc = Def_DLL["DefineProc"]("BlockInput", vt_b1, vt_b1);
  var Lib = DLL["Load"]("USER32.DLL", "USER32");
  Lib["BlockInput"](true);
}

function EnableInput()
{
  var Def_DLL = DLL["DefineDLL"]("USER32");
  var Def_Proc = Def_DLL["DefineProc"]("BlockInput", vt_b1, vt_b1);
  var Lib = DLL["Load"]("USER32.DLL", "USER32");
  Lib["BlockInput"](false);
}

Back to list

Q.: How can I retrieve information on the memory use on a workstation?

A.: To do this, you can use the Windows API GlobalMemoryStatus function and MEMORYSTATUS structure. Below is a sample code snippet. Note that both the function and structure are available only if the Win32API plug-in is installed.

[VBScript]

Sub TestMemoryStatus
  Dim Mem

  Set Mem = Win32API.TMemoryStatus
  Mem.dwLength = 32
  Win32API.GlobalMemoryStatus Mem
  Log.Message "MEMORYSTATUS test", _
      "Percent of memory in use - " & _
      CStr(Mem.dwMemoryLoad) & vbNewLine & _
      "Total bytes of physical memory - " & _
      CStr(Mem.dwTotalPhys) & vbNewLine & _
      "Size of available physical memory (bytes) - " & _
      CStr(Mem.dwAvailPhys) & vbNewLine & _
      "Size of the user mode portion of virtual address space (bytes) - " & _
      CStr(Mem.dwTotalVirtual) & vbNewLine & _
      "The number of available bytes in the user mode portion of virtual " & _
      "address space - " & CStr(Mem.dwAvailVirtual)
End Sub

[JScript]

function TestMemoryStatus()
{
var Mem;

  Mem = Win32API.TMemoryStatus();
  Mem.dwLength = 32;
  Win32API.GlobalMemoryStatus(Mem);
  Log.Message("MEMORYSTATUS test",
      "Percent of memory in use - " +  VarToStr(Mem.dwMemoryLoad) +
      "\r\nTotal bytes of physical memory - " + VarToStr(Mem.dwTotalPhys) +
      "\r\nSize of available physical memory (bytes) - " + 
      VarToStr(Mem.dwAvailPhys) +
      "\r\nSize of the user mode portion of virtual address space (bytes) - " + 
      VarToStr(Mem.dwTotalVirtual) +
      "\r\nThe number of available bytes in the user mode portion of virtual " +
      "address space - " + VarToStr(Mem.dwAvailVirtual));
}

[DelphiScript]

procedure TestMemoryStatus;
var
  Mem: OleVariant;
begin
  Mem := Win32API.TMemoryStatus;
  Mem.dwLength := 32;
  Win32API.GlobalMemoryStatus(Mem);
  Log.Message('MEMORYSTATUS test',
      'Percent of memory in use - '+ VarToStr(Mem.dwMemoryLoad) + #13#10 +
      'Total bytes of physical memory - ' + VarToStr(Mem.dwTotalPhys) + #13#10 +
      'Size of available physical memory (bytes) - ' + 
      VarToStr(Mem.dwAvailPhys) + #13#10 +
      'Size of the user mode portion of virtual address space (bytes) - ' + 
      VarToStr(Mem.dwTotalVirtual) + #13#10 +
      'The number of available bytes in the user mode portion of virtual '+
      'address space - '+ VarToStr(Mem.dwAvailVirtual));
end;

[C++Script, C#Script]

function TestMemoryStatus()
{
  var Mem;

  Mem = Win32API["TMemoryStatus"]();
  Mem["dwLength"] = 32;
  Win32API["GlobalMemoryStatus"](Mem);
  Log["Message"]("MEMORYSTATUS test",
      "Percent of memory in use - " +
      VarToStr(Mem["dwMemoryLoad"]) +
      "\r\nTotal bytes of physical memory - " +
      VarToStr(Mem["dwTotalPhys"]) +
      "\r\nSize of available physical memory (bytes) - " +
      VarToStr(Mem["dwAvailPhys"]) +
      "\r\nSize of the user mode portion of virtual address space (bytes) - " +
      VarToStr(Mem["wTotalVirtual"]) +
      "\r\nThe number of available bytes in the user mode portion of virtual "+
      "address space - " + VarToStr(Mem["dwAvailVirtual"]));
}

Back to list

Q.: How can I obtain the name of the user account that TestComplete is running under?

A.: Use the the Sys.UserName property.

Back to list

Q.: Can I call DLL functions from scripts?

A.: Yes, you can. Both TestComplete Standard and Enterprise include the DLLAccess plug-in that lets you call any stdcall functions from 32-bit dynamic link libraries. Before calling a function, you should perform a number of preparations: load the DLL in memory, define parameter types, and so on. All of these steps are described in full detail in TestComplete help: just search for DLL Object in the Index tab.

Another plug-in, .NET Classes Support, is also available in TestComplete Standard and Enterprise. It lets you call functions that reside in any .NET assembly (it can be an assembly supplied with the .NET Framework, as well as an executable or an assembly of your or third-party .NET application). Before calling a function from the desired .NET assembly, you should add this assembly to the CLR Bridge list stored in project properties. See “Calling Functions From .NET Assemblies” in TestComplete help for more information.

Back to list

Q.: How do I call functions from a DLL created in Visual Basic? I tried the DLLAccess plug-in, but it does not help.

A.: Dynamic link libraries created in Visual Basic 6 are ActiveX libraries that contain four specific exported functions. You cannot call your custom functions from these DLLs using the DLLAccess plug-in.

Since these DLLs implement COM objects, you can create those COM objects from scripts and call their methods. To create the objects, use the Sys.OleObject(…) property. For more informaion, see the “Sys.OleObject Property” and “Sys.OleObject” topics in TestComplete’s help.

Back to list

Copyright © 1999-2008, AutomatedQA, Corp. All Rights Reserved.
Home | Legal | About | Contact | Site Map | Print