Expressions

An expression typically evaluates to a text. For example, the expression

"The author of the book " + Book.title + " is " + Book.author + "."

evaluates to the text "The author of the book Pet Sematary is Stephen King.", if the attributes title and author of the Book variable contain the texts "Pet Sematary" and "Stephen King", respectively.

You can do also numeric calculations within the expression. For example, if the attribute Book.price contains the price of a book, you can multiply this with 100 using the following expression:

Book.price * 100

Depending on where the expression occurs, an input text may be available for use in the expression. You can refer to this input text in the expression using the INPUT notation. For example, if the input text is "The time is " and you want to add the current time, you can use this expression:

INPUT + time(now())

Expression Types

The following types of expressions are available:

Expression Type Notation Meaning Examples
Constant "text" A fixed text.
You can use the backslash character (\) to enter special characters:
\n for line break
\r for carriage return
\f for form document
\t for horizontal tab
\b for backspace
\" for double quote
\' for single quote
\\ for backslash itself
\uxxxx for the unicode character with encoding xxxx, where xxxx is four hexadecimal digits.
"This is some \"quoted\" text."
"This a text with line break\n, tab \t and a unicode \u0035 character"
Constant >>text<< A fixed text. This notation can contain anything, including quote characters, except the end-symbol (<<). The backslash (\) character can not be used to enter special characters. >>This is some "quoted" text.<<
Variables variable.attribute
variable
The value of a variable. If the variable is of a complex type, an attribute name must also be supplied. Book.title
Integer
Input Text INPUT The input text, if any, to the expression. INPUT
Concatenation expr1 + expr2 The concatenation of the two expressions expr1 and expr2. "Title:" + Book.title
Subpattern Match $n If n > 0, the text that matches subpattern n in the pattern. If n = 0, the text that matches the entire pattern.
Note: This expression has meaning only if there is a pattern associated with the expression.
$1
Numeric Expression Operators: +, -, *, /, % The result of a numeric expression. Book.price * 100
Boolean Expression Operators: && (and), || (or) The result of a boolean expression. performTransactions && Book.price < 30
Conditional Expression condition ? expr1 : expr2 If condition evaluates to true, the value of expr1 is used, otherwise the value of expr2 is used. Book.price < 30 ? "cheap" : "expensive"
Function func(expr) The function func applied to the result of the expression expr. See below for the available functions. capitalize(Book.title)
Current URL URL The current URL. URL
Current Window WINDOW The unique ID of the current window. WINDOW
Robot Name Robot.name The name of the robot. Robot.name
Execution ID Robot.executionId The current execution ID of the robot. Robot.executionId
Execution Errors Robot.executionErrors The execution errors encountered in the previous branch of the nearest Try step. Robot.executionErrors

Note: The >>text<< notation for a text constant is useful if you want to specify a long text that contains many quote characters, for example HTML. Using the >>text<< notation, you can use the text as is, and simply place the >> and << symbols around it. If you use the "text" notation, you will have to replace all quote characters in the text with two consecutive quote characters.

Functions

The following functions are available:

Function Meaning
abs(arg) Returns the absolute value of the number.
base64Decode(arg) Decodes Base64 encoded data.
base64Encode(arg) Encodes binary data with Base64 encoding.
binaryToText(data[, encoding]) Decodes binary data into text. Uses the specified encoding if present, or otherwise defaults to UTF-8 encoding.
capitalize(arg) Makes the first letter of every word upper-case and all other letters lower-case.
ceil(arg) Rounds the number up to the nearest integer.
collapseSpaces(arg) Makes sure there are no two consecutive spaces.
contains(source, key) Returns whether or not the source contains the specified key.
date() Returns the current date in standard date format (yyyy-mm-dd).
day(args) Returns the day of month of the date given as argument.
endsWith(source, key) Returns true if the source string ends with the specified key, or false otherwise.
excelColStringToNumberFunction Converts a string from an Excel spreadsheet to a number.
excelNumberToColStringFunction Converts a number to a string in an Excel spreadsheet.
floor(arg) Rounds the number down to the nearest integer.
guid() Returns a randomly generated, globally unique ID (GUID).
hexDecode(arg) Decodes hex encoded data.
hexEncode(arg) Encodes binary data with hex encoding.
indexOf(source, key) Returns the first index of the key in the source, or -1 if not found.
length(arg) Counts the number of characters in the text, or the number of bytes if given binary data.
max(a, b) Returns the greatest of the two numbers.
md5(arg) Computes the MD5 checksum of the binary data given as argument.
min(a, b) Returns the smallest of the two numbers.
month(args) Returns the month of the date given as argument.
now() Returns the current date and time.
random() Returns a random number between 0 and 1.
removeSpaces(args) Removes all white space characters in the argument, e.g. SPACE, \t, \n.
replacePattern(source, pattern, newText) Replaces every occurrence of the pattern 'pattern' in text 'source' with the text 'newText'. The pattern match is case insensitive.
replaceText(source, oldText, newText) Replaces every occurrence of the text 'oldText' in the text 'source' with the text 'newText'. The match with 'oldText' is case insensitive.
resolveURL(arg) Converts a relative URL to an absolute one using the current URL.
round(arg) Rounds to the nearest integer.
shortTime(arg) Returns the time without fractional seconds (hh:mm:ss) of the date given as argument.
substring(source, startIndex, endIndex) Returns the portion of the source string starting at the startIndex and up to the endIndex, not including the character at endIndex. If no endIndex has been specified, the function will behave as if the length of the source string was given as endIndex.
startsWith(source, key) Returns true if the source string starts with the specified key, or false otherwise.
textToBinary(text[, encoding]) Encodes text to binary data. Uses the specified encoding if present, or otherwise defaults to UTF-8 encoding.
time(arg) Returns the time (hh:mm:ss.fff) of the date given as argument.
toInteger(args) Converts the text to an integer. This can be useful if you want to include it in calculations.
toNumber(args) Converts the text to a floating-point number. This can be useful if you want to include it in calculations.
toLowerCase(arg) Converts all of the characters in the text to lower case.
toUpperCase(arg) Converts all of the characters in the text to upper case.
trim(arg) Removes all space from both ends of the text.
urlDecode(arg) Decodes the URL encoded text.
urlEncode(arg) URL encodes the text.
weekday(arg) Returns the name of the weekday (in English) of the date given as argument.
year(args) Returns the year of the date given as argument.