Built-In Variables in Robot Framework.

Robot Framework provides some built-in variables. It’s predefined by Robot Framework Creator.

1 . Operating System Variables

Built-In VariablesExplanation
${CURDIR}An absolute path to the directory where the test data file is located. This variable is case-sensitive.
${TEMPDIR}An absolute path to the temporary system directory. In UNIX-like systems, this is typically /tmp, and in Windows c:\Documents and Settings\<user>\Local Settings\Temp.
${EXECDIR}An absolute path to the directory where test execution was started from.
${/}The system directory path separator. / in UNIX-like systems and \ in Windows.
${:}The system path element separator. : in UNIX-like systems and ; in Windows.
${\n}The system line separator. \n in UNIX-like systems and \r\n in Windows.

2 . Number Variables

The variable syntax can be used to create integers and floating-point numbers, as illustrated in the example below. When a keyword intends to receive a number and not a string that looks like a number, it can be used here.

Integers can also be created from binary, octal, and hexadecimal values using 0b, 0o, and 0x prefixes. The syntax is case insensitive.


${80} --> representing integer value 80
${80.09} --> representing floating point value
${0b1011} --> representing binary value of 11
${0o10} --> reprsenting octal value of 8
${0xff} --> reprsenting hexadecimal value of 255

3. Boolean and None variables

Boolean values are True and False. A None variable in Python is equivalent to a null variable in Java.

The robot framework can also use these values as numbers.For example, ${True} and ${true} are equivalent, since these variables are case-insensitive.Also, when running tests on the Jython interpreter, None and null are automatically converted to the correct format when required. You can define boolean and none variables as shown below.


4. Space and Empty variables

In the robot framework, it is possible to create empty value variables and spaces using ${SPACE} and ${EMPTY}, respectively. It is possible to use more than one space by using ${SPACE * 5}.

Set Global Variable  @{list_variable}   @{EMPTY} # Creating empty list 
Set Global Variable  &{dict_variable}   &{EMPTY} # Creating empty dictionary
Set Global Variable  ${string_variable}   ${EMPTY}   #Creating empty string

Note:- Set Global Variable is used to make the variable available throughout all the sections of the test case. It is one of the built-in keywords in the robot framework.

Leave a Comment

Your email address will not be published.