Variables
Variables can be defined in the source code but there are also predefined system variables that can be used (see chapter “List of All System Parameters”).
Note: The current values of variables can be shown in the source code editor by clicking the “Toggle Code Mining” button.
Basic Concepts
- Variables are always available globally (no scoping rules).
- Variables will be defined implicitly by assigning values.
- The type of the variable will be determined by the assigned value.
- Available types:
- Boolean
- String (surrounded by double quotation marks)
- Date (datenow is available as system variable)
- Time (timenow is available as system variable)
- Integer
- Variable replacement in strings (also location strings) can be done with {~~}.
Example:
myvar = "myadditionaltext"
myvar1 = "mytext {~myvar~}" is the same as myvar1 = "mytext myadditionaltext"
Logical Operators
You can use the following logical operators and save the result into a variable.
Integer and Date/Time
- Equal: ==
- Not equal: !=
- Bigger than: >
- Bigger than or equal: >=
- Smaller than: <
- Smaller than or equal: <=
Boolean
String
Arithmetic Operators
You can use the following arithmetic operators and save the result into a variable.
Integer and Date/Time
- Addition: + (adds days to a date value or seconds to a time value)
- Subtraction: - (subtracts days from a date value or seconds from a time value)
Integer
- Multiplication: *
- Division: /
- Modulo: %
- Exponentiation: ^
String
String
For manipulating strings following functions are offered:
- SplitLeft("STRING", "SEPERATOR")
Returns the left part of the STRING from the beginning until the SEPERATOR.
Example SplitLeft("Anthony.Brown", ".") returns the string "Anthony". - SplitRight("STRING", "SEPERATOR")
Returns the right part of the STRING beginning from SEPERATOR until the end of the defined string.
Example SplitRight("David.Porter", ".") returns the string "Porter". - SubStr("STRING", BEGININDEX, CHARNUMBER)
Returns a substring from the defined STRING. CHARNUMBER characters are returned beginning at BEGININDEX (the index is zero-based).
Example SubStr("Fabasoft app.test Agent", 9, 8) returns the string "app.test".
Note: If you do not enter a number of characters, the string is returned from the defined index until the end of the string, e.g. SubStr("app.test", 4) returns the string "test". - StrReplace("STRING", "TARGET", "REPLACEMENT")
Replaces each substring of the STRING that matches the literal TARGET sequence with the specified literal REPLACEMENT sequence.
Example StrReplace("abab", "b", "c") returns the string "acac". - StrLen("STRING")
Returns the length of the STRING.
Example StrLen("Brown") returns "5". - StrTrim("STRING")
Returns a copy of the STRING, with leading and trailing whitespace omitted.
Example StrTrim(" Brown ") returns the string "Brown". - IndexOf("STRING", "SUBSTRING")
Returns the index within the STRING of the first occurrence of the specified SUBSTRING. If the SUBSTRING does not occur as a substring, -1 is returned.
Example IndexOf("David", "Dav") returns "0". - Contains("STRING", "SUBSTRING")
Returns “true” if and only if the STRING contains the specified SUBSTRING.
Example Contains("David", "vi") returns "true". - Lower("STRING")
Converts all of the characters in the STRING to lower case.
Example Lower("David") returns the string "david". - Upper("STRING")
Converts all of the characters in the STRING to upper case.
Example Upper("David") returns the string "DAVID".
Date and Time
By default, Fabasoft app.test uses following format:
- dd.MM.yyyy (date)
- HH:mm:ss (time)
Date and time values can be formatted with following functions:
As locale the Java locale of Fabasoft app.test is used by default. But the locale can also be defined within the test.
Example |
Java.Locale = "en" Java.Locale = "de" // deletes the parameter Java.Locale = null |
For parsing and formatting date values the predefined Java format DateFormat.SHORT is used, for time values DateFormat.MEDIUM.
See http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.
Example |
// formats the current date or time based on the locale d = DateFormat() t = TimeFormat() // parses and formats the string based on the locale d = DateFormat("DATE") t = TimeFormat("TIME") // parses the string based on the locale and formats based on the pattern d = DateFormat("DATE", "PATTERN") t = TimeFormat("TIME", "PATTERN") // parses and formats the location value based on the locale d = DateFormat() @LOCATION t = TimeFormat() @LOCATION // parses the location value based on the locale and formats based on the pattern d = DateFormat("PATTERN") @LOCATION t = TimeFormat("PATTERN") @LOCATION // calculations d = DateFormat(datenow + 365) t = TimeFormat(timenow - 60) |