WorkFolder Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

A tested application can be run in RunAs mode. Use the WorkFolder property to obtain or set a working folder for the tested application that will be run in RunAS mode. TestComplete will only use these arguments if the RunAs run mode is chosen for the application.

The WorkFolder property value is the same as the Working folder value specified for the application in the Tested Applications editor.

Declaration

TestedAppRunAsParamsObj.WorkFolder

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 specifying the desired working folder.

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 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 command-line argument for the application
  RunAsParams.CommandLineParameters = "NotOpenApp";

  // Specifies a working folder for the tested application
  RunAsParams.WorkFolder = "D:\Work Folder";

  // 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 command-line argument for the application 
  RunAsParams.CommandLineParameters = "NotOpenApp"
  # Specifies a working folder for the tested application 
  RunAsParams.WorkFolder = "D:\Work Folder"
  # 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 command-line argument for the application
  RunAsParams.CommandLineParameters = "NotOpenApp"

  ' Specifies a working folder for the tested application
  RunAsParams.WorkFolder = "D:\Work Folder"

  ' 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 command-line argument for the application
  RunAsParams.CommandLineParameters := 'NotOpenApp';

  // Specifies a working folder for the tested application
  RunAsParams.WorkFolder := 'D:\Work Folder';

  // 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 the command-line argument for the application
  RunAsParams["CommandLineParameters"] = "NotOpenApp";

  // Specifies a working folder for the tested application
  RunAsParams["WorkFolder"] = "D:\Work Folder";

  // 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
CommandLineParameters Property
WorkFolder Property
WorkFolder Property

Highlight search results