StInitSession Function

Action

The StInitSession function connects to a Windows Terminal Server session and opens a remote desktop user session. When the connection is established, Silk Test is started in the session. If no username or password are provided, the function uses the user name and password that are saved in the profile settings. If you want to run the test on your local console, do not set user credentials in the profile settings or the script.
Note: Color depth settings defined using this function override profile settings configured via Silk Performer at Profile settings > GUI-Level Testing > General > Session settings. When the optional uColorDepth parameter is omitted, profile settings are used. The default color-depth setting is 16 bit.

The server may limit maximum color depth. The client can not force a color depth setting that is higher than is supported by the server. Please see Terminal Services Configuration documentation for details about your server version's color-depth limitations.

By default StInitSession raises an error with the severity SEVERITY_PROCESS_EXIT if the function fails to start a valid session. The severity of that error can be adjusted by a custom event handler function (see "Event Handler Section"). When an error with SEVERITY_PROCESS_EXIT occurs the rest of the script is ignored and no unsaved results data or measurements will be saved.

Include file

StAutomation.bdh

Syntax

StInitSession( sUser          : in string optional, 
               sPassword      : in string optional, 
               uColorDepth    : in number optional,
               uDesktopWidth  : in number optional,
               uDesktopHeight : in number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sUser Optional: The username of the remote desktop user. If no username or password are provided, the function uses the user name and password that are saved in the profile settings.
sPassword Optional: The password of the remote desktop user. If no username or password are provided, the function uses the user name and password that are saved in the profile settings.
uColorDepth Optional: The remote session's color depth setting. The default color-depth setting is 16 bit. Possible values are one of following constants of StAutomation.bdh:
ST_COLOR_256     := 8;
  ST_COLOR_15bit   := 15;
  ST_COLOR_16bit   := 16;
  ST_COLOR_24bit   := 24;
  ST_COLOR_32bit   := 32;
uDesktopWidth Optional: The remote session's screen width resolution size in pixels. Default is 1024.
uDesktopHeight Optional: The remote session's screen height resolution size in pixels. Default is 768.

Example

transaction TMain
var
  sUser     : string;
  sPassword : string;
begin
  AttributeGetString("Username", sUser);
  AttributeGetString("Password", sPassword);
  if (StInitSession(sUser, sPassword, ST_COLOR_16bit, 1600, 1200)) then
    StLoadProject("package.stp");
    StSetOption(ST_OPTION_TRUELOG_OPTIONS,ST_TRUELOG_ALL);
    StExecuteTestcase("scriptFile.t", "testcase", "\" testdata\",10", "MyTimer1");
    StLogoffSession();
  end;
end TMain;