Connect Class

Applies to TestComplete 14.10, last modified on June 5, 2019
Information in this topic applies to desktop applications only.
Connected and Self-Testing applications are deprecated. These technologies will be removed in one of the future releases of TestComplete.
To create test code that runs from within your tested apps, use TestLeft, a SmartBear functional testing tool for developers.

The Connect class is used to address global programming objects of TestComplete from Connected Applications. This class contains wrappers for the program objects and global constants that you can use in scripts. For instance:

  • Connect.Sys - Provides access to the Sys object.
  • Connect.Log - Provides access to the Log object.
  • Connect.TestedApps - Provides access to the TestedApps object.
  • Connect.Regions - Provides access to the Regions object.
  • etc.

Therefore, the methods of this class may address these properties without using Connect.

To use this class in your Connected Application, add the line

C#

using AutomatedQA.TestComplete.Connect;

to the source file that contains the test code. Note that you can skip Connect if the class whose methods contain the test code is inherited from the Connect class (see below).

Note that the Connect class contains fields for TestComplete standard objects (Sys, Log, Regions and others). It does not contain fields for objects provided by third-party plugins. To obtain these objects, use the GetObjectByName method of the Integration object:

C#

using AutomatedQA.TestComplete;
...
var MyObject = Connect.Integration["GetObjectByName"]("MyObjectName");

If your test class is not inherited from Connect, you should prefix the names of TestComplete program objects in imported script routines with Connect. For instance:

C#

// Script code in a class that is not inherited from the Connect class
Connect.Log["Message"]("My message"); // Calls the Log.Message method
Connect.Sys["Desktop"]["ActiveWindow"](); // Calls the Sys.Desktop.ActiveWindow method
int i = Connect.Sys["MouseX"]; //Getting the Sys.MouseX property
Connect.Sys["MouseX"] = 120; // Setting the Sys.MouseX property

Another approach is to create a test class that will contain the script code and will be inherited from Connect. Then, you can use this class in the same manner as you do this in TestComplete scripts:

C#

// Script code in a class inherited from the Connect class
Log["Message"]("My message"); // Calls the Log.Message method
Sys["Desktop"]["ActiveWindow"](); // Calls the Sys.Desktop.ActiveWindow method
int i = Sys["MouseX"]; // Getting the Sys.MouseX property
Sys["MouseX"] = 120; // Setting the Sys.MouseX property

For more information on testing applications from Connected Applications with TestComplete, see Connected Applications - Overview

See Also

Self-Testing Applications
Running Connected and Self-Testing Applications
Working With TestComplete via COM - Overview

Highlight search results