Cogitek RIATest 6 Documentation Copyright © Cogitek Inc.

Global Object

There is a unique global object, which is created before control enters any execution context. Methods and properties of Global object are accessible directly from script.

Properties

PropertyDescription

NaN

The IEEE 'not a number'.

Methods

MethodDescription

assert

assert(argument[,failMessage])
Assert that argument evaluates to 'true'. Outputs verification passed or failed message to log. If assertion fails current script execution is aborted.

assertEqual

assertEqual(argument1,argument2)
Verify that argument1 strictly equals argument2. If arguments are not primitive types (e.g. are objects or arrays) all sub-components are verified to be equal as well (unlike == operator). Outputs verification passed or failed message to log. If assertion fails current script execution is aborted.

assertMatch

assertMatch(argument1,argument2)
Verify that argument1 matches argument2. If argument2 is RegExp pattern matching is performed. If argument2 is an Object it will be verified that specified properties exist on argument1 and they match specified values.If arguments are not primitive types (e.g. are objects or arrays) all sub-components are verified to be equal as well (unlike == operator). Outputs verification passed or failed message to log. If assertion fails current script execution is aborted.

closeBrowser

closeBrowser([browserProcess]);
Close browser window. If browserProcess is specified appropriate browser will be killed otherwise last open browser will be killed.

discardSysLocatorCache

discardSysLocatorCache()
Discard Windows UI Automation cache.

exec

exec(command)
Create a new process using provided 'command' line. Waits for the process to finish and returns the exit code.

exitProject

exitProject([exitCode])
Terminate execution of the project.If RIATest process is called from command line return exitCode (or 0 if ommited). No error is registered when this function is called.

exitScript

exitScript()
Gracefully terminate execution of the current script and proceed to the next script in the project (if any). No error is registered when this function is called.

externalCall

externalCall(funcName[,arguments,...])
Call function using Flex ExternalInterface.call()
For example: externalCall("window.resizeTo",800,600);
For more information see this page.

fileGetContents

fileGetContents(fileName)
Read entire file contents as a string. File is assumed to be encoded in UTF-8. If file is not found or read error occurs null is returned. For example to append a string to an existing file:
function appendToFile(fileName,content)
{
  var curContent = fileGetContents(fileName);
  if (curContent)
    curContent = curContent+content;
  else
    curContent = content;
  return filePutContents(fileName,curContent);
}

filePutContents

filePutContents(fileName,contents)
Write specified contents string to specified file using UTF-8 encoding. If file exists its content is overwritten. Returns true if operation was successfull.

getEnv

getEnv(variable)
Get environment variable.

getLastBrowser

getLastBrowser()
Return Process of the last opened browser (or AUT). This includes browser opened by RIATest automatically or via openBrowser script function

getMultipleMatches

getMultipleMatches(locator[,maxResultCount])
Return an array of specialized locators each matching only one of the objects that the original locator matches. Specialized locators may use whatever attributes are necessary to pinpoint the exact object (automationIndex will be likely used). The function will return at most maxResultCount items (if specified, otherwise all matching items will be returned). Here is an example that uses getMultipleMatches to find a descendant of a Flex object:
function findDescendant(parent,descendantLocator)
{
    var descendants = getMultipleMatches(descendantLocator);
    for (var i=0; i<descendants.length; i++)
    {
        var descendant = descendants[i];
        while (descendant)
        {
            if (isEqual(descendant,parent))
            {
                return descendants[i];
            }
            descendant = descendant=>automationParent;
        }
    }
    return null;
}

var d = findDescendant(FlexCanvas("Canvas"),FlexAccordion("Accordion"));
trace(d);

getProjectGlobal

getProjectGlobal(key)
Get the value from the project global value map corresponding to the specified key. Must be previously set by setProjectGlobal function.

getProjectOptions

getProjectOptions()
Return current project options. Returns an object with the following properties set: projectFileName,projectDir,launchApp,closeApp,appPathOrURL,waitForAgent

getScriptInfo

getScriptInfo()
Return currently executing script information. Returns an object with the following properties set: scriptFile,curLine. This example prints the currently executing script file name:
var si = getScriptInfo();
trace(si.scriptFile);

getSysError

getSysError([errorCode])
Get system error message corresponding to the errorCode. If errorCode is omitted return last system error message.

getSysErrorCode

getSysErrorCode()
Get last system error code. Returns GetLastError under Win32 and errno on Mac.

getSysInfo

getSysInfo()
Get system information object. For example to print the operating system name and version:
var si = getSysInfo();
trace(si.OSFamily);
trace(si.OSName);
trace(si.OSVersion);

getTimer

getTimer()
Return the time since startup of the execution in milliseconds.

getWaitTimeout

getWaitTimeout()
Returns current timeout value for waitFor operator in milliseconds.

isAppConnected

isAppConnected(appId)
Checks if the Flex application specified by its id is connected.

isEqual

isEqual(argument1,argument2)
Strictly compare argument1 with argument2. If arguments are not primitive types (e.g. are objects or arrays) all sub-components are compared as well (unlike == operator). Returns true if arguments are equal.

isFinite

isFinite(argument)
Returns true if argument is finite number.

isNaN

isNaN(argument)
Returns true if the argument is NaN.

isPresent

isPresent(locator)
Checks if the component specified by locator is present.

lastConnectedApp

lastConnectedApp()
Returns most recently connected application information. The result is an object with 'id' property set.

openBrowser

openBrowser(urlOrPath[, options]);
Open browser window and return a Process object of the browser.

urlOrPath must specify url to application or file path to load in browser.
options is a bitwise or-ed mask of various flags.
Use BR_PROJECTLOADTYPE, BR_STANDALONE or BR_USELOADER to specify loading type. Use BR_RIATESTOPTION, BR_SYSDEFAULT, BR_IE, BR_FIREFOX, BR_CUSTOM to specify which browser to open.

See also Controlling browser opening and closing.

parseFloat

parseFloat(string)
Converts the string to a number value.

parseInt

parseInt(string,radix)
Converts the string to an integer value according to the specified radix. Leading whitespace in the string is ignored. If radix is undefined or 0, it is assumed to be 10 except when the number begins with the character pairs 0x or 0X, in which case a radix of 16 is assumed. Any radix-16 number may also optionally begin with the character pairs 0x or 0X.

pause

pause(argument)
Pauses execution of the script for specified number of milliseconds.

putEnv

putEnv(variable,value)
Set environment variable value.

registerTeardown

registerTeardown(function,scope)
Register a terdown function. The function will be called when execution of the script completes. Multiple shutdown functions can be registered in which case they will be called in the reverse order of registration. spcoe can be SC_THISSCRIPT or SC_ALLSCRIPTS. For SC_THISSCRIPT scope the registration applies to current script only. For SC_ALLSCRIPTS the registration remains active for duration of project and teardown function will be called after every script in the project.

selectApp

selectApp(appId)
Select Flex application for testing. appId must be string equal to id of Application. Returns true on success.

setErrorMode

setErrorMode(operation,errorMode)
Set operation error mode.

operation must be one of the following: OP_ACTION, OP_PROPERTY_ACCESS, OP_WAITFOR.
errorMode must be one of the following: EM_NOTHROW, EM_THROW_EXCEPTION.

See setErrorMode usage article.

setExecutionDelay

setExecutionDelay(argument)
Set a delay in milliseconds to wait after every action execution. Returns the previous delay value. Default value is 0.

setImageSearchOpt

setImageSearchOpt(option, value)
Set image searching options. Currently supported option is SO_TOLERANCE. It specifies allowed difference between pixel RGB values. The value for tolerance should be an integer from 0 to 255. The tolerance of 0 requires exact matching of RGB values. The tolerance of 255 will match any two images The default value is 10.

setLocatorOption

setLocatorOption(option, value)
Set locator resolving option. The options define how the locators behave before an action is executed or a property is accessed. Returns previous value of the option.

The following options are supported:

  • LO_BEFORE_ACTION - set the behavior of RIATest when the script attempts to perform an action (execute an event). 'value' is a bitwise mask of LF_INITIALIZED,LF_VISIBLE, LF_ENABLED or LF_BUSYCURSOR flags. Before performing the action RIATest will verify that the object's state matches specified value.
    The meaning of the flags is as follows:
    LF_INITIALIZED - wait for object to be initialized.
    LF_VISIBLE - wait for object to be visible.
    LF_ENABLED - wait for object to be enabled.
    LF_BUSYCURSOR - wait until the standard cursor is shown (Flex applications only). Usually can be used to automatically wait while a busy cursor indicating an operation progress is shown.
    By default the actions will not operate on invisible objects (they will wait until the object becomes visible). An example to allow actions on invisible HTML objects:
    var myButton = HtmlDiv("MyButton");
    // Omit LF_VISIBLE flag to avoid waiting for insvisible objects
    setLocatorOption(LO_BEFORE_ACTION, LF_INITIALIZED);
    myButton.click();
  • LO_BEFORE_PROPACCESS - set the behavior of RIATest when the script attempts to access a property of a GUI object. 'value' is a bitwise mask of LF_INITIALIZED,LF_VISIBLE, LF_ENABLED or LF_BUSYCURSOR flags. See description of the flags above.
  • LO_ENCODE_UI_OBJECTS - set the behavior of RIATest when the script attempts to access a property of a GUI object and the value of the property is a GUI object itself. RIATest will encode the value of the property according to the specified 'value' flag. The meaning of the flag is as follows:
    LF_AS_LOCATOR - encode the value of the property as a Locator. This is default behavior in RIATest 4.
    LF_AS_OBJECT - encode the value of the property as an anonymous object. This behavior is compatible with RIATest 3.

setMaxValueNesting

setMaxValueNesting(maxNesting)
Set maximum nesting level for value retrieved from Agent. Default value is 5. Setting too a big value may result in very large object set being retrieved when accessing complex properties of objects (e.g. 'dataProvider' property of a Tree with lots of depth and large collection of items.)

setOption

setOption(option, value)
Set an execution option. Returns previous value of the option. If value is omitted the option will not be changed.

The following options are supported:

  • OPT_MOUSEEVENTSIMULATION - set the behavior of RIATest when the script attempts to perform a low level action, such as mouseMove, mouseDown, mouseUp or clickAt on a Flex or HTML object. 'value' is one of OPF_AUTO,OPF_SYSTEM or OPF_INTERNAL flags. The meaning of the flags is as follows:
    OPF_AUTO - Select simulation mode automatically. If UI Automation is enabled simulate mouse actions using system events, otherwise simulate using internal Flex or HTML events.
    OPF_SYSTEM - Simulate mouse actions using system events. If UI Automation is disabled the actions will fail.
    OPF_INTERNAL - Simulate mouse actions using internal Flex or HTML events.
  • Note: the value of the option will stay in effect during project execution unless it is changed again using setOption call.

setProjectGlobal

setProjectGlobal(key,value)
Set value in the project global value map and associate it with the key. Project global value map is preserved during execution of the project unlike plain global variables which persist only throughout single script execution.

setWaitTimeout

setWaitTimeout(argument)
Sets current timeout value for waitFor operator in milliseconds.

trace

trace()
Output argument value to message log

unregisterTeardown

unregisterTeardown(function,scope)
Unregister a previously registered teardown function.

verify

verify(argument[,failMessage])
Verify that argument evaluates to 'true'. Outputs verification passed or failed message to log.

verifyEqual

verifyEqual(argument1,argument2)
Verify that argument1 strictly equals argument2. If arguments are not primitive types (e.g. are objects or arrays) all sub-components are verified to be equal as well (unlike == operator). Outputs verification passed or failed message to log.

verifyImage

verifyImage(locator, image, options)
Verify that an image is found relative to the object specified by locator. options specify the area to search and is one of the following: SO_EXACT (image must match object exactly), SO_INSIDE (image must be inside object's area, i.e. object fully contains the image), SO_LEFT (image must be on the left of object's area), SO_TOP (image must be on the top of object's area), SO_RIGHT (image must be on the right of object's area), SO_BOTTOM (image must be on the bottom of object's area).

verifyMatch

verifyMatch(argument1,argument2)
Verify that argument1 matches argument2. If argument2 is a RegExp pattern matching is performed. If argument2 is an Object it will be verified that specified properties exist on argument1 and they match specified values.If arguments are not primitive types (e.g. are objects or arrays) all sub-components are verified to be matches as well. Outputs verification passed or failed message to log.

Found a typo? Have a suggestion? Please submit your request here.