Testing Console Applications - Overview

Applies to TestComplete 15.10, last modified on December 15, 2021

In Windows operating systems, console applications are programs that use a text-based interface and output data to and obtain input from a Win32 console. Users typically send commands to these applications via the keyboard. This differs from traditional Windows applications, in which you use a mouse or other pointing devices to interact with the windows and controls.

Supported Console Applications

TestComplete can interact with console applications created with any compiler: C++ console applications, .NET console applications and so on. However, TestComplete cannot access the internal objects, methods and properties of console applications. It just allows access to the console windows, lets you simulate keystrokes sent to these windows , work with console StdIn and StdOut streams, and so on.

General Approach

The processes, which the operating system creates for console applications, have only one window. The class name of this window is ConsoleWindowClass. To obtain a reference to this window, you can use the following code:

JavaScript, JScript

p = Sys.Process("MyApp");
w = p.Window("ConsoleWindowClass", "*");
// ...

Python

p = Sys.Process("MyApp");
w = p.Window("ConsoleWindowClass", "*");
# ...

VBScript

Set p = Sys.Process("MyApp")
Set w = p.Window("ConsoleWindowClass", "*")
' ...

DelphiScript

p := Sys.Process('MyApp');
w := p.Window('ConsoleWindowClass', '*');
// ...

C++Script, C#Script

p = Sys["Process"]("MyApp");
w = p["Window"]("ConsoleWindowClass", "*");
// ...

Alternatively, you can record the desired actions against the console window.

TestComplete automatically captures screenshots of the tested applications when you perform key input and other actions. However, screenshots are not captured when you perform clicks over console windows. If you want to get screenshots for each action in your test (even for clicks), record the desired actions and then play back the recorded test from TestComplete. This will allow you to automatically capture screenshots on playback and show them in the Picture panel of the Test Log window.

Simulating Keystrokes

Using TestComplete, you can simulate keystrokes sent to console windows directly from your test. For this purpose, you can use the Keys method. For more information, see Interacting With Console Windows.

Working with Console StdIn and StdOut Streams

To obtain the text generated by the console windows, use the wText property that TestComplete adds to all console applications’ windows. Also, TestComplete lets you access standard input and output streams that are associated with the tested console window. For this purpose, you can use the standard Windows object - WshShell. For more information, see Working With Console StdIn and StdOut Streams.

See Also

Interacting With Console Windows
Working With Console StdIn and StdOut Streams

Highlight search results