Global

Global object. Use it to perform actions not related to a particular object. You do not need to record or learn this object, it is always automatically available in any test.

Action Summary

Action Description
DoAnalogPlay Performs Analog Playback of events recorded in a file.
DoAppActivate Activates window with the specified title.
DoClick Performs mouse click at the current position.
DoCompareJsObjects Compares two JavaScript objects and prints differences to the report.
DoDecrypt Decrypts a piece of text.
DoEncrypt Encrypts a piece of text.
DoInvokeTest Invokes another test (aka subtest).
DoInvokeTestParallel
DoKillByName Terminates a given process.
DoKillByPid Terminates a given process or the last process created by DoLaunch if 'pid' is not specified.
DoLaunch Executes a command specified in cmdLine.
DoLoadObjects Loads objects from external .objects.js file.
DoMessageBox

Shows message box (popup message) to a user.

DoMouseMove Moves mouse to the specified position.
DoPlayManual Executes a manual test.
DoRunTestSet Executes a test set.
DoSendKeys Sends series of keystrokes to a currently focused application.
DoSleep Pauses execution for given number of milliseconds (1000 = 1 second).
DoTrim Strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string.
DoTypePassword Types encrypted password into a control which has a focus.
DoWaitFor Waits for object specified by objectId to become available.
DoWaitForProperty Waits for specified value of object's property.
GetClipboardText Reads text stored in the windows clipboard.
GetCurrentDir Gets current directory path.
GetFileAsByteArray Reads file and returns its content as array of bytes.
GetFirstDayOfWeek Returns first day of week for current user.
GetFullPath Constructs an absolute file name using working directory (WORKDIR) of the test.
GetOsOwner Reads OS registered owner from the registry.
GetOsPath Returns OS root path.
GetOsType Reads OS type from the registry.
GetOsVersion Reads OS service pack version from the registry.
GetProperty Reads property value from %WORKDIR%\Config.json.
GetSpecialFolderPath Returns path to a special folder specified by one of possible values.
SetClipboardText Updates clipboard text
SetFileAsByteArray Creates or rewrites file and fills with contents of the provided byte array.
SetProperty Sets property value to %WORKDIR%\Config.json.

Action Detail

DoAnalogPlay(path, left, top)

Performs Analog Playback of events recorded in a file.

Parameters:

Name Type Description
path string This is a path to a file with recorded analog events.
left number X-coordinate of top-left corner of the analog area.
top number Y-coordinate of the top-left corner of the analog area.

DoAppActivate(title)

Activates window with the specified title. I.e. Global.DoAppActivate("Calculator") will bring running instance (if any) of Windows Calculator to the foreground.

Parameters:

Name Type Description
title string Title of an application window.

See:

MSDN Article for AppActivate

DoClick(clickType)

Performs mouse click at the current position.

Parameters:

Name Type Description
clickType string Type of click, can be one of "L" - left click, "LD" - double left click, "R" - right click, "RD" - double right click, "M" - middle click, "MD" - double middle click, "N" - don't click
Optional, Default: L.

DoCompareJsObjects(msg, obj1, obj2)

Compares two JavaScript objects and prints differences to the report.

Parameters:

Name Type Description
msg string Message to write into report.
obj1 object First object.
obj2 object Second object.

Returns:

boolean: 'true' if two objects are equal, 'false' otherwise.

DoDecrypt(encryptedText)

Decrypts a piece of text.

Parameters:

Name Type Description
encryptedText string Text to decrypt.

Returns:

string: Decrypted text.

DoEncrypt(plainText)

Encrypts a piece of text.

Parameters:

Name Type Description
plainText string Text to encrypt.

Returns:

string: Encrypted text.

DoInvokeTest(pathToTest, optionalParams)

Invokes another test (aka subtest). The subtest should have the set of libraries as calling test. Otherwise it may lead to a conflict.

Parameters:

Name Type Description
pathToTest string Path to .sstest file.
optionalParams object Parameters to pass into entry point Test() function of the subtest. I.e. it is called as Test(optionalParams).
Optional, Default: [object Object].

Returns:

boolean: 'true' if the test passed, 'false' otherwise.

DoInvokeTestParallel(testPath, threads, commonParams)

Parameters:

Name Type Description
testPath
threads
commonParams

DoKillByName(processName)

Terminates a given process.

Parameters:

Name Type Description
processName string Executable name to kill (such as 'iexplore.exe').

Returns:

boolean: 'true' if the process was terminated, 'false' otherwise.

DoKillByPid(pid)

Terminates a given process or the last process created by DoLaunch if 'pid' is not specified.

Parameters:

Name Type Description
pid number ID of the process.
Optional.

Returns:

boolean: 'true' if the process was terminated, 'false' otherwise.

DoLaunch(cmdLine, wrkDir, attachIfExists, attachToWindow)

Executes a command specified in cmdLine. Optionally one may specify working dir, and window name to attach if it is already launched.

Parameters:

Name Type Description
cmdLine string Command line to an executable with parameters.
wrkDir string Working directory. By default it is a directory of the test.
Optional, Default: ..
attachIfExists boolean Try to find a process with the same executable path instead of launching it.
Optional, Default: false.
attachToWindow string When attachIfExists is 'true' this parameter may be used to specify top window name to find a process to attach to.
Optional, Default: null.

Returns:

number: ID of the new process (positive number) or an error code (negative number)

DoLoadObjects(objectsFilePath)

Loads objects from external .objects.js file.

Parameters:

Name Type Description
objectsFilePath string Path to *.objects.js file.

Returns:

object: saved_script_objects or null if the load was unsuccessful.

DoMessageBox(prompt, buttons)

Shows message box (popup message) to a user.


'buttons' is a value or a sum of values that specifies the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. Default value is 0.

    0 = vbOKOnly - OK button only
    1 = vbOKCancel - OK and Cancel buttons
    2 = vbAbortRetryIgnore - Abort, Retry, and Ignore buttons
    3 = vbYesNoCancel - Yes, No, and Cancel buttons
    4 = vbYesNo - Yes and No buttons
    5 = vbRetryCancel - Retry and Cancel buttons
    16 = vbCritical - Critical Message icon
    32 = vbQuestion - Warning Query icon
    48 = vbExclamation - Warning Message icon
    64 = vbInformation - Information Message icon
    0 = vbDefaultButton1 - First button is default
    256 = vbDefaultButton2 - Second button is default
    512 = vbDefaultButton3 - Third button is default
    768 = vbDefaultButton4 - Fourth button is default
    0 = vbApplicationModal - Application modal (the current application will not work until the user responds to the message box)
    4096 = vbSystemModal - System modal (all applications wont work until the user responds to the message box)
                

We can divide the buttons values into four groups: The first group (0–5) describes the buttons to be displayed in the message box, the second group (16, 32, 48, 64) describes the icon style, the third group (0, 256, 512, 768) indicates which button is the default; and the fourth group (0, 4096) determines the modality of the message box. When adding numbers to create a final value for the buttons parameter, use only one number from each group.


The function returns a number representation of a button pressed by user:

vbOK1OK button was clicked.
vbCancel2Cancel button was clicked.
vbAbort3Abort button was clicked.
vbRetry4Retry button was clicked.
vbIgnore5Ignore button was clicked.
vbYes6Yes button was clicked.
vbNo7No button was clicked.

Parameters:

Name Type Description
prompt string Message to display.
buttons number Buttons to show.
Optional, Default: 0.

Returns:

number: A number representation of a button pressed by user.

DoMouseMove(x, y, duration)

Moves mouse to the specified position.

Parameters:

Name Type Description
x number Absolute X-coordinate of the target mouse position.
y number Absolute Y-coordinate of the target mouse position.
duration number Mouse move duration. If 0 - do immediate move.
Optional, Default: 0.

DoPlayManual(rmtFilePath, rmtParams)

Executes a manual test. Results are shown in the report of the calling test.

Parameters:

Name Type Description
rmtFilePath string Path to manual test (.rmt) file.
rmtParams object Additional parameters to pass to the manual test executor.
Optional.

Returns:

boolean: 'true' if the manual test passed, 'false' otherwise.

DoRunTestSet(testSetFilePath, testSetParams)

Executes a test set. Results are shown in the report of the calling test.

Parameters:

Name Type Description
testSetFilePath string Path to a test set file.
testSetParams object Additional parameters to pass for each test in the test set.
Optional.

DoSendKeys(keys)

Sends series of keystrokes to a currently focused application.

Parameters:

Name Type Description
keys string Keystrokes, including special characters and control symbols.

DoSleep(millis=1000)

Pauses execution for given number of milliseconds (1000 = 1 second).

Parameters:

Name Type Description
millis=1000 number Number of milliseconds to sleep.

DoTrim(str, global, trimChars)

Strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. Whitespace characters are [\f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].

Parameters:

Name Type Description
str string String to trim.
global boolean If 'true' then global trim is performed (whitespaces in the middle are substituted with a single space). If 'false' only ends are trimmed.
Optional, Default: false.
trimChars string String with each char to be subject for trim.
Optional.

Returns:

string: Trimmed string.

DoTypePassword(encryptedPassword)

Types encrypted password into a control which has a focus.

Parameters:

Name Type Description
encryptedPassword string Password to type. Encrypted.

Returns:

string: 'true'

DoWaitFor(objectId, timeout, sleepTimeIfFound)

Waits for object specified by objectId to become available. Function returns if object was found or timeout.

Parameters:

Name Type Description
objectId objectid | string Id of an object to wait for.
timeout number Maximum time to wait (milliseconds).
Optional, Default: 10000.
sleepTimeIfFound number Wait time (milliseconds) after object is found.
Optional, Default: 0.

Returns:

SeSObject |
boolean: Found object or 'false'.

DoWaitForProperty(obj, getterName, propValue, timeout, params)

Waits for specified value of object's property. Function returns object handle if object was found and specified property equals to desired value or 'false' in the case of timeout.

Parameters:

Name Type Description
obj string | SeSObject Id of an object to wait for or object itself.
getterName string Property getter function name.
propValue string | number boolean
timeout number Maximum time to wait (milliseconds).
Optional, Default: 10000.
params array | string number

Returns:

SeSObject |
boolean: Found object or 'false'.

GetClipboardText()

Reads text stored in the windows clipboard.

Returns:

string: Clipboard text

GetCurrentDir()

Gets current directory path.

Returns:

string: Path of the current directory.

GetFileAsByteArray(fileName)

Reads file and returns its content as array of bytes. May be useful for binary files and for passing data to web services.

Parameters:

Name Type Description
fileName string Filename to read (recommended to use absolute file name).

Returns:

object: Array of bytes.

GetFirstDayOfWeek()

Returns first day of week for current user.

Returns:

number: 0 - Sunday, 1 - Monday.

GetFullPath(fileName)

Constructs an absolute file name using working directory (WORKDIR) of the test.

Parameters:

Name Type Description
fileName string Name of a file.

Returns:

string: Absolute file name.

GetOsOwner()

Reads OS registered owner from the registry.

Returns:

string: OS registered owner.

GetOsPath()

Returns OS root path.

Returns:

string: OS root path without the trailing backslash, e.g. 'C:\Windows'.

GetOsType()

Reads OS type from the registry.

Returns:

string: OS type string.

GetOsVersion()

Reads OS service pack version from the registry.

Returns:

string: Service pack version.

GetProperty(name, defValue)

Reads property value from %WORKDIR%\Config.json.

Parameters:

Name Type Description
name string Name of a property
defValue string | number boolean

Returns:

string |
number |
boolean: Propery value. If a property does not exist then defValue is returned. If defValue is not set then null is returned.

GetSpecialFolderPath(folder=MyDocuments)

Returns path to a special folder specified by one of possible values.


Possible values:
ApplicationDataThe directory that serves as a common repository for application-specific data for the current roaming user.
CommonApplicationDataThe directory that serves as a common repository for application-specific data that is used by all users.
CommonProgramFilesThe directory for components that are shared across applications.
CookiesThe directory that serves as a common repository for Internet cookies.
DesktopThe logical Desktop rather than the physical file system location.
DesktopDirectoryThe directory used to physically store file objects on the desktop.
FavoritesThe directory that serves as a common repository for the user's favorite items.
HistoryThe directory that serves as a common repository for Internet history items.
InternetCacheThe directory that serves as a common repository for temporary Internet files.
LocalApplicationDataThe directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.
MyComputerThe "My Computer" folder.
MyDocumentsThe "My Documents" folder.
MyMusicThe "My Music" folder.
MyPicturesThe "My Pictures" folder.
PersonalThe directory that serves as a common repository for documents.
ProgramFilesThe program files directory.
ProgramsThe directory that contains the user's program groups.
RecentThe directory that contains the user's most recently used documents.
SendToThe directory that contains the Send To menu items.
StartMenuThe directory that contains the Start menu items.
StartupThe directory that corresponds to the user's Startup program group.
SystemThe System directory.
TemplatesThe directory that serves as a common repository for document templates.

Parameters:

Name Type Description
folder=MyDocuments string Folder Id.

Returns:

string: System specified folder path without the trailing backslash, e.g. 'C:\Program Files'.

SetClipboardText(txt)

Updates clipboard text

Parameters:

Name Type Description
txt string Text to store into clipboard.

Returns:

boolean: 'true' when clipboard is set.

SetFileAsByteArray(fileName, bytes)

Creates or rewrites file and fills with contents of the provided byte array.

Parameters:

Name Type Description
fileName string Filename to write (recommended to use absolute file name).
bytes array Array of bytes to write.

Returns:

number: Number of bytes written.

SetProperty(name, value)

Sets property value to %WORKDIR%\Config.json. If the file does not exist it will be created.

Parameters:

Name Type Description
name string Name of a property.
value string | number boolean

Returns:

boolean: 'true' if property value set successfully, 'false' otherwise.