UserName Property

Applies to TestComplete 12.60, last modified on September 17, 2018

Description

A tested application can be run in RunAs mode. In this mode, TestComplete launches the tested application under a user account that differs from the account that TestComplete is running under. The UserName property specifies the user account that will be used for the run. TestComplete will use this property only if the RunAs run mode is chosen for the application.

The UserName property is the same as the User name value specified for the application in the Tested Applications editor.

Declaration

TestedAppRunAsParamsObj.UserName

Read-Write Property String
TestedAppRunAsParamsObj An expression, variable or parameter that specifies a reference to a TestedAppRunAsParams object

Applies To

The property is applied to the following object:

Property Value

A string that specifies the desired user account.

Note: Specify an account that has a password. TestComplete will not launch the tested application under an account that does not have a password.

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.

Example

The following example demonstrates how to modify the tested application’s parameters in script:

JavaScript, JScript

function Test()
{

  var TestApp, Params, RunAsParams;
  TestApp = TestedApps.Items("SampleApp");
  // Obtains the tested application's parameters
  Params = TestApp.Params;
  // Obtains the parameters of the RunAs mode
  RunAsParams = Params.RunAsParams;

  // Modifies the parameters of the RunAs mode:
  // Specifies a domain for the user account under which the application will be run
  RunAsParams.Domain = "CompanyDomain";

  // Specifies the user account under which the application will be run
  RunAsParams.UserName = "jsmith";

  // Specifies a password for the user account under which the application will be run
  RunAsParams.Password = "jsmithpswrd";

  // Applies the modified parameters and activates the RunAs mode
  RunAsParams.Activate();

  // Launches the tested application in the RunAs mode under the specified user account
  TestApp.Run();

}

Python

def Test():
  TestApp = TestedApps.Items["SampleApp"]
  # Obtains the tested application's parameters 
  Params = TestApp.Params
  # Obtains the parameters of the RunAs mode 
  RunAsParams = Params.RunAsParams
  # Modifies the parameters of the RunAs mode: 
  # Specifies a domain for the user account under which the application will be run 
  RunAsParams.Domain = "CompanyDomain"
  # Specifies the user account under which the application will be run 
  RunAsParams.UserName = "jsmith"
  # Specifies a password for the user account under which the application will be run 
  RunAsParams.Password = "jsmithpswrd"
  # Applies the modified parameters and activates the RunAs mode 
  RunAsParams.Activate()
  # Launches the tested application in the RunAs mode under the specified user account 
  TestApp.Run()

VBScript

Sub Test

  Dim TestApp, Params, RunAsParams
  Set TestApp = TestedApps.Items("SampleApp")
  ' Obtains the tested application's parameters
  Set Params = TestApp.Params
  ' Obtains the parameters of the RunAs mode
  Set RunAsParams = Params.RunAsParams

  ' Modifies the parameters of the RunAs mode:
  ' Specifies a domain for the user account under which the application will be run
  RunAsParams.Domain = "CompanyDomain"

  ' Specifies the user account under which the application will be run
  RunAsParams.UserName = "jsmith"

  ' Specifies a password for the user account under which the application will be run
  RunAsParams.Password = "jsmithpswrd"

  ' Applies the modified parameters and activates the RunAs mode
  RunAsParams.Activate

  ' Launches the tested application in the RunAs mode under the specified user account
  TestApp.Run

End Sub

DelphiScript

procedure Test();
var TestApp, Params, RunAsParams;
begin

  TestApp := TestedApps.Items('SampleApp');
  // Obtains the tested application's parameters
  Params := TestApp.Params;
  // Obtains the parameters of the RunAs mode
  RunAsParams := Params.RunAsParams;

  // Modifies the parameters of the RunAs mode:
  // Specifies a domain for the user account under which the application will be run
  RunAsParams.Domain := 'CompanyDomain';

  // Specifies the user account under which the application will be run
  RunAsParams.UserName := 'jsmith';

  // Specifies a password for the user account under which the application will be run
  RunAsParams.Password := 'jsmithpswrd';

  // Applies the modified parameters and activates the RunAs mode
  RunAsParams.Activate;

  // Launches the tested application in the RunAs mode under the specified user account
  TestApp.Run;

end;

C++Script, C#Script

function Test()
{

  var TestApp, Params, RunAsParams;
  TestApp = TestedApps["Items"]("SampleApp");
  // Obtains the tested application's parameters
  Params = TestApp["Params"];
  // Obtains the parameters of the RunAs mode
  RunAsParams = Params["RunAsParams"];

  // Modifies the parameters of the RunAs mode:
  // Specifies a domain for the user account under which the application will be run
  RunAsParams["Domain"] = "CompanyDomain";

  // Specifies the user account under which the application will be run
  RunAsParams["UserName"] = "jsmith";

  // Specifies a password for the user account under which the application will be run
  RunAsParams["Password"] = "jsmithpswrd";

  // Applies the modified parameters and activates the RunAs mode
  RunAsParams["Activate"]();

  // Launches the tested application in the RunAs mode under the specified user account
  TestApp["Run"]();

}

See Also

Run Modes and Parameters
Testing Applications Running Under Another User Account
Editing Desktop Application Parameters
Domain Property
Password Property
About Tested Applications

Highlight search results