CommandLineParameters Property

Applies to TestComplete 15.40, last modified on July 05, 2022

Description

Use the CommandLineParameters property to get or set the command-line arguments that will be used to run the tested application in the appropriate run mode (for example, Simple or Debug). This is the same value as the one specified in the Command-line parameters property of the tested application in the TestedApps editor.

Declaration

ProgObj.CommandLineParameters

Read-Write Property String
ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following objects:

Property Value

A string that specifies the application’s command-line arguments.

Remarks

If you assign a value to this property, TestComplete will treat your project as modified. So, you will need to save or cancel changes when closing the project. The specified value will be displayed in the TestedApps editor.

To specify the property value, you can use project and project suite variables as well as the operating system’s environment variables.

The project or project suite variables must be of the string type. To refer to them, use the following syntax --

$(var_name)

--for example, “$(MyVar1)”.

Note: When evaluating the value of the property, TestComplete first searches for the specified variable in the project variables, then in the project suite variables. Please keep this in mind if you have project and project suite variables with the same names.

To refer to environment variables, use the following syntax --

%var_name%

-- for example, %Path%.

Note that variables can refer to each other, for instance, a project variable may include a reference to an environment variable. TestComplete will recursively analyze the variables and form the resulting value that does not contain variable names.

Example

The following script demonstrates how to set the tested application’s parameters:

JavaScript, JScript

function Test()
{
  // Add Notepad to TestedApps
  var index = TestedApps.Add("%WINDIR%\\notepad.exe");
  var app = TestedApps.Items(index);

  // Specify the working folder and command-line arguments for Notepad
  // Note: ActiveParams refer to Simple mode parameters by default
  var appParams = app.Params.ActiveParams;
  appParams.CommandLineParameters = "NewFile.txt";
  appParams.WorkFolder = "%USERPROFILE%";

  // This line launches Notepad and either prompts to create NewFile.txt
  // in the user profile folder, or opens an existing file with this name
  app.Run();
}

Python

def Test():
  # Add Notepad to TestedApps
  index = TestedApps.Add("%WINDIR%\\notepad.exe")
  app = TestedApps.Items[index]
  # Specify the working folder and command-line arguments for Notepad 
  # Note: ActiveParams refer to Simple mode parameters by default
  appParams = app.Params.ActiveParams
  appParams.CommandLineParameters = "NewFile.txt"
  appParams.WorkFolder = "%USERPROFILE%"
  # This line launches Notepad and either prompts to create NewFile.txt 
  # in the user profile folder, or opens an existing file with this name 
  app.Run()

VBScript

Sub Test
  Dim index, app, appParams

  ' Add Notepad to TestedApps
  index = TestedApps.Add("%WINDIR%\notepad.exe")
  Set app = TestedApps.Items(index)

  ' Specify the working folder and command-line arguments for Notepad
  ' Note: ActiveParams refer to Simple mode parameters by default
  Set appParams = app.Params.ActiveParams
  appParams.CommandLineParameters = "NewFile.txt"
  appParams.WorkFolder = "%USERPROFILE%"

  ' This line launches Notepad and either prompts to create NewFile.txt
  ' in the user profile folder, or opens an existing file with this name
  app.Run
End Sub

DelphiScript

procedure Test;
var index, app, appParams;
begin
  // Add Notepad to TestedApps
  index := TestedApps.Add('%WINDIR%\notepad.exe');
  app := TestedApps.Items[index];

  // Specify the working folder and command-line arguments for Notepad
  // Note: ActiveParams refer to Simple mode parameters by default
  appParams := app.Params.ActiveParams;
  appParams.CommandLineParameters := 'NewFile.txt';
  appParams.WorkFolder := '%USERPROFILE%';

  // This line launches Notepad and either prompts to create NewFile.txt
  // in the user profile folder, or opens an existing file with this name
  app.Run;
end;

C++Script, C#Script

function Test()
{
  // Add Notepad to TestedApps
  var index = TestedApps["Add"]("%WINDIR%\\notepad.exe");
  var app = TestedApps["Items"](index);

  // Specify the working folder and command-line arguments for Notepad
  // Note: ActiveParams refer to Simple mode parameters by default
  var appParams = app["Params"]["ActiveParams"];
  appParams["CommandLineParameters"] = "NewFile.txt";
  appParams["WorkFolder"] = "%USERPROFILE%";

  // This line launches Notepad and either prompts to create NewFile.txt
  // in the user profile folder, or opens an existing file with this name
  app["Run"]();
}

See Also

Run Modes and Parameters
Editing Desktop Application Parameters
Passing Command-Line Arguments to Tested Applications
WorkFolder Property
About Tested Applications

Highlight search results