Passing Command-Line Arguments to Tested Applications

Applies to TestComplete 14.72, last modified on April 22, 2021
Information in this topic applies to desktop and web applications.

TestComplete lets you specify command-line arguments for your tested application before launching it. You can set the arguments in one the following ways:

You can specify arguments for the following application types:

  • Windows desktop applications running in the Simple, RunAs or Debug mode.

    Note: In the Profile run mode, application arguments are specified in the AQtime profiling project.
  • Java applications

  • AIR applications

  • Web browsers

  • Virtual browsers (mobile browser emulators)

Passing Arguments From Scripts

In scripted tests, you can set CommandLineParameters for your tested application as follows:

JavaScript, JScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = "C:\\MyFile.txt";
// Start Notepad and open MyFile.txt
TestedApps.notepad.Run();

Python

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = "C:\\MyFile.txt"
# Start Notepad and open MyFile.txt
TestedApps.notepad.Run()

VBScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = "C:\MyFile.txt"
' Start Notepad and open MyFile.txt
TestedApps.notepad.Run

DelphiScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters := 'C:\MyFile.txt';
// Start Notepad and open MyFile.txt
TestedApps.notepad.Run;

C++Script, C#Script

TestedApps["notepad"]["Params"]["ActiveParams"]["CommandLineParameters"] = "C:\\MyFile.txt";
// Start Notepad and open My File.txt
TestedApps["notepad"]["Run"]();

If you need to enclose the argument list in quotes (for example, to specify a file name with spaces), use code like this:

JavaScript, JScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = "\"" + "C:\\My File.txt" + "\"";
TestedApps.notepad.Run();

Python

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = '"' + 'C:\\My File.txt' + '"'
TestedApps.notepad.Run()

VBScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters = Chr(34) & "C:\My File.txt" & Chr(34)
TestedApps.notepad.Run

DelphiScript

TestedApps.notepad.Params.ActiveParams.CommandLineParameters := '"' + 'C:\My File.txt' + '"';
TestedApps.notepad.Run;

C++Script, C#Script

TestedApps["notepad"]["Params"]["ActiveParams"]["CommandLineParameters"] = "\"" + "C:\\My File.txt" + "\"";
TestedApps["notepad"]["Run"]();

Passing Arguments From Keyword Tests

In keyword tests, use the Call Object Method operation to set CommandLineParameters for your tested application:

  • Add the Call Object Method operation to your test (before the Run TestedApp operation).

  • Enter the following object name and click Next:

    TestedApps.AppName.Params.ActiveParams

  • Select CommandLineParameters [Set] and click Next.

  • Enter the arguments in the Value column and click Finish.

See Also

About Tested Applications
Run Modes and Parameters
About TestedApps Editor
Working With Tested Applications in Tests

Highlight search results