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

Home » Products » TestComplete » FAQs » Recording and Running Scripts

TestComplete 3 FAQ. Recording and Running Scripts

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



Q.: Why does TestComplete use coordinates when recording a script with my application?

A.: TestComplete has special support for a number of Win32 controls and it uses object names instead of coordinates when working with some of them. The tool uses specific methods and properties to work with standard Win32 controls. If you open the "Working With Win32 Controls" help topic, you will see a list of supported Win32 objects. To determine whether a specific control behaves as a standard Win32 control, TestComplete uses the Object Mapping feature (Options | Engine Options). This feature sets a correspondence between onscreen objects and their possible class names. For example, by default the following classes are listed for the toolbar control: ToolBar, WindowsForms10.ToolbarWindow32.*, WFC.ToolbarWindow32. This means that if TestComplete sees a window that has one of these class names, it will try to work with it as with a standard Win32 toolbar.

The Object Mapping feature can be customized: You can add class names of your application's objects to it. However, this does not guarantee that TestComplete will be able to get the needed data from the control: If the control does not respond properly to Windows messages that TestComplete sends to it, the Object Mapping option is useless.

When TestComplete records coordinates, it uses relative coordinates. For example, when it records clicks on a button, the coordtinates are recorded relative to the button’s left top corner. The size of the button is measured in pixels and it does not change on different resolutions. For example, if the button’s height is 25 pixels, width is 75 pixels and a click on it is recorded as Click(13, 38), TestComplete will click in the center of the button at any display resolution. If the button is moved to some other position on the form, the script will not fail.

Back to list

Q.: TestComplete does not pick up my mouse clicks when recording. What is wrong?

A.: This may happen because once you place the mouse cursor over an item of a tree view or of some other Windows control, a tooltip is brought up. This tooltip can cover the item you are clicking. As a result, TestComplete cannot record this click since you are actually clicking on the tooltip. To work around this problem, do any of the following:

Turn off tooltips if possible;
Place the mouse cursor over the needed item, wait until the tooltip disappears, then click the item. The click will be recorded.

Note: Tooltips on Windows toolbar buttons do not require waiting for the tooltip to disappear; you can just click the button for which a tooltip is displayed. The other Windows controls that have tooltips may work in the same way, or may require that you wait until the tooltip goes away as in tree view controls.

Back to list

Q.: Is it possible to record actual delays between user actions?

A.: Yes. The record of actual delays between user actions may be desirable if you want the scripts to be executed at the same speed as they were recorded. Without delays, scripts are executed at full speed.

There are two possible ways to record delays between user actions --

  • You can record a low-level procedure. In low-level recording, TestComplete registers only mouse and keyboard events, namely, mouse clicks, keyboard events, mouse movements and mouse wheel events. Also, TestComplete registers the time delay between these events. So, the delays between user actions will be reproduced correctly. However, low-level procedures are recorded in absolute coordinates. Thus, if the application under test has changed its window size, the low-level procedure may fail to reproduce the user actions.
  • You can use the Real-Time Mode option (Options | Engine Options | Record). If it is enabled, TestComplete records actual time between user actions and inserts it in the script as calls to Sys.Delay.

Back to list

Q.: I recorded my actions successfully and the resulting script looks fine, but when I play it back to do the test, there is nothing happening in my test program, but the run result says OK. What is wrong?

A.: The Run button launches the main routine of the TestComplete project. By default, the routine called Main is the project's main routine. For instance, if you create a new project in VBScript, it will hold the following script code:

[VBScript]

Sub Main
' Call Test
End Sub
If you uncomment the line
[VBScript]

' Call Test
in the routine and replace the routine name Test with the name of the routine you recorded (it is Test1 by default), you'll be able to execute your recorded script by pressing the Run button. You can also make the recorded routine the main routine - please read the "Running Scripts" help topic for more details.

Back to list

Q.: How can I run several scripts one after another?

A.: A script is routine written in one of the supported languages - VBScript, JScript, DelphiScript, C++Script or C#Script. Scripts can call one another. So assuming your problem is that you run Script1, it stops, then you launch Script2, it ends too, then..., well, the solution is simply to modify the main script in the following way --

procedure Main;
begin
  Script1;
  Script2;
  Script3;
  ...
end;

You also have another way to run several scripts: you can switch to the Test Suites panel and create a test suite (In TestComplete 2.xx test suites are available in TestComplete Enterprise only. In TestComplete 3.xx, test suites are available in both TestComplete Standard and Enterprise). In TestComplete a test suite consists of three routines: Initial, Final and Main. However, each test suite can have any number of child test suites. A child suite, in its turn, can have child suites that can also have child suites, and so on. Therefore, you can create any sequence of scripts you need.

The results of a suite run are displayed in the Test Log in a tree-like structure. For each test suite (parent or child) there is a row in the upper pane of the panel -

For more information on test suites, see the TestComplete on-line help system.

Back to list

Q.: Is there any way to supply parameters to the main script?

A.: A.: The script defined as the main routine in the Code Explorer, must be a procedure which does not require parameters. Else, it cannot be executed by TestComplete. If your script requires some parameters, you can create an empty routine and call your script from it. However, this means you have to specify parameter values in source code, that is, you have to modify the sources before running the script. If you don't want to modify the source code, use any of the following solutions --

  • You can set up a small text file with the parameter string in it, and have the main procedure read its parameters from there. But then it has to interpret them itself.
  • You can use InputBox to ask the tester for parameters. This routine is built in TestComplete and supported by all scripting languages - DelphiScript, VBScript, JScript and C++Script.
  • You can use the Local Variables panel. It allows you to create and modify script variables in a convenient manner. These variables are stored in the <project.cfg> file and, thus, their actual values depend on the machine where the script is run. In other words, the values of such variables differ from one tester computer to another. The Local Variables panel provides a dialog for the creating and deleting variables and changing their values. All variables have the OLE Variant type. Once a variable has been created, it appears in the Code Completion window under the Options | LocalVars node. To call the variables in a script, use the construction Options.LocalVars.variable_name, for instance --

[VBScript]
Sub Main
  . . .
  ExportFileTo Options.LocalVars.MyExportFilePath
  . . .
End Sub

Back to list

Q.: TestComplete does not break the script running on breakpoints. How can I fix it?

A.: Please download Microsoft's Windows script debugger and install it. This should solve the problem.

Please use the following address if you use Windows 98 or Me:

http://www.microsoft.com/downloads/details.aspx?FamilyId=E606E71F-BA7F-471E-A57D-F2216D81EC3D&displaylang=en

or the address below if you use Windows NT 4.0, 2000 or XP:

http://microsoft.com/downloads/details.aspx?FamilyId=2F465BE0-94FD-4569-B3C4-DFFDF19CCD99&displaylang=en

Back to list

Q.: After my script executes the p.WaitWindow("TFormName*") instruction, TestComplete posts the "Ambiguous recognition" error to the log. What happens?

A.: This error message means that TestComplete has found several windows whose attributes (class names, caption and index) correspond to the specified pattern. To resolve the issue, try to specify a more precise search criteria. If there should be only one window with this class name in your project, the possible reason is that the application under test does not free the previous instances of the window.

Back to list

Q.: When my script is running, unexpected windows appear (this is quite normal for my app). Is it possible for TestComplete to close them and to continue executing the script? Or does TestComplete stop executing the script when an unexpected window appears?

A.: Select Options | Engine Options from the main menu. This will call the Engine Options dialog. Select Run from the left of the dialog, expand the On Unexpected Window group of options. If the Stop Execution option is checked, TestComplete stops the script execution. Else, it does not stop the script.

The other four options in this group, Click on Focused Button, Press Esc, Press Enter and Send WM_Close, provide different ways of getting the window to close automatically. You can use all four if this doesn't confuse your application, or any combination that works for your windows.

You can also create an event handler for the OnUnexpectedWindow event and process unexpected windows in your own manner.

Back to list

Q.: Is it possible to create a script routine that would be run when an unexpected window appears?

A.: Yes. Add the ProjectEvents control to a form in your TestComplete project, switch to the Component Inspector panel, open the Events page, find the OnUnexpectedWindow event there and double-click it. TestComplete will create an event handler and display it in the Editor panel. Now you can write code of the OnUnexpectedWindow event handler. TestComplete on-line help includes several examples of such code.

Back to list

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