RIATest Documentation Copyright © RIATest.com

Statements

The if statement

To check a condition in RIATest use if statement in one of the two forms:

if condition then statement1;
if condition then statement1 else statement2;

if statement will check the condition and if true will execute the statement following then otherwise if else part is present the second statement will be executed. For example the following code will check to see if the button is enabled and will click it:

if myButton=>enabled then myButton=>click();

To perform repeatitive actions use one of the loop statements: while, for, do.

The while statement

The while statement has following syntax:

while (condition) statement; 

For example the following code keep clicking the button until it becomes disabled:

while (myButton=>enabled) myButton=>click(); 

Note that this code will run infinitely if the button is never disabled as a result of click action.

The for statement

The for statement has following syntax:

for (init_expr;cond_expr;iter_expr) statement;

The init_expr is executed in the beginning and then the statement is executed until cond_expr becomes false. After each execution of statement the iter_expr is executed.

The following code repeats clicks on a button 10 times:

for (var x=1; x<=10; x++) myButton=>click();

The do statement

The do statement has following syntax:

do statement while (condition);

This is similar to while statement except that the statement is executed at least once even if condition is initially false.

do 
{
  myButton=>click();
  trace("clicked");
} while (myButton=>enabled);

Note the usage of block parenthesis {} to group multiple statements.

The return statement

return statement is used to return a value from function. The syntax is the following:

return [expression];

If expression is omited the result of function is null.

See also Functions.

The include statement

The include statement has following syntax:

include file-name;

inlcude statement reads the temporarily suspends execution of current script file, locates specified file, loads its content and executes it. After execution of the included file is finished execution returns to current script file and continues from the statement followin the include statement. Global variables and functions declared in the included script file are visible to the current script (and indistinguishable from variables and functions decalred in the current script).

include statement is typically used for writting common functions in a separate include file and then including it from several script files.