TestComplete samples (both built-in and additional) are located in the <Users>\Public\Public Documents\TestComplete 12 Samples folder.
Some file managers display the Public Documents folder as Documents.
Information in this topic applies to generic desktop applications (.NET, WPF, Delphi and others). |
TestComplete lets you run desktop applications in several modes - Simple, Run As, Profile and Debug. You can change the run mode not only in the TestedApps editor, but also during the test run.
Scripting Objects
To access the run mode parameters from tests, you can use one of the following objects:
Run Mode | Parameters Object |
---|---|
Simple | TestedApps.AppName.Params.SimpleParams |
RunAs | TestedApps.AppName.Params.RunAsParams |
Debug | TestedApps.AppName.Params.DebugParams |
Profile | TestedApps.AppName.Params.ProfileParams |
In addition, the TestedApps.AppName.Params.ActiveParams
object provides access to the current run mode’s parameters.
Getting and Setting Run Mode From Scripts
To get an application’s current run mode, you can use the TestedApps.AppName.Params.ActiveParams.Name
property. It returns the mode name as a string.
JavaScript, JScript
var app = TestedApps.MyApp;
Log.Message("The active run mode is " + app.Params.ActiveParams.Name);
Python
app = TestedApps.MyApp
Log.Message("The active run mode is " + app.Params.ActiveParams.Name)
VBScript
Dim app
Set app = TestedApps.MyApp
Call Log.Message("The active run mode is " & app.Params.ActiveParams.Name)
DelphiScript
var app;
begin
app := TestedApps.MyApp;
Log.Message('The active run mode is ' + app.Params.ActiveParams.Name);
end;
C++Script, C#Script
var app = TestedApps["MyApp"];
Log["Message"]("The active run mode is " + app["Params"]["ActiveParams"]["Name"]);
Alternatively, you can use the TestedApps.AppName.Params.ModeNameParams.IsActive
method to check if a specific mode is active (see the example below).
To set a run mode for your application, use the TestedApps.AppName.Params.ModeNameParams.Activate
method:
JavaScript, JScript
if (! TestedApps.MyApp.Params.RunAsParams.IsActive())
{
TestedApps.MyApp.Params.RunAsParams.Activate();
}
Python
if (not TestedApps.MyApp.Params.RunAsParams.IsActive()):
TestedApps.notepad.Params.RunAsParams.Activate()
VBScript
If Not TestedApps.MyApp.Params.RunAsParams.IsActive Then
TestedApps.MyApp.Params.RunAsParams.Activate
End If
DelphiScript
if not TestedApps.MyApp.Params.RunAsParams.IsActive then
TestedApps.MyApp.Params.RunAsParams.Activate;
C++Script, C#Script
if (! TestedApps["MyApp"]["Params"]["RunAsParams"]["IsActive"]())
{
TestedApps["MyApp"]["Params"]["RunAsParams"]["Activate"]();
}
Getting and Setting Run Mode From Keyword Tests
In keyword tests, you can call the above-mentioned object methods and properties using the Call Object Method, Run Code Snippet or Run Script Routine operation.
Samples
TestComplete includes a sample test project that tests an application in different run modes in a loop:
<TestComplete Samples>\Desktop\Running Tested Applications\Run Modes
Note: | If you do not have the sample, download the TestComplete Samples installation package from the https://support.smartbear.com/downloads/testcomplete/samples/ page of our website and run it. |
See Also
Run Modes and Parameters
Run Modes and Parameters
Editing Desktop Application Parameters