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 system temporary 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 for creating both integers and floating-point numbers, as illustrated in the example below. This is useful when a keyword expects to get an actual number, and not a string that just looks like a number, as an argument.

It is possible to create integers also from binary, octal, and hexadecimal values using 0b0o and 0x prefixes, respectively. 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, False. None variables are None in python and null in Java.

We can use these values similarly in the robot framework as numbers. These variables are case-insensitive, so for example ${True} and ${true} are equivalent. Additionally, ${None} and ${null} are synonyms, because when running tests on the Jython interpreter, Jython automatically converts None and null to the correct format when necessary. You can define boolean and none variables as shown below.


4. Space and Empty variables

In the robot framework, it is also possible to create empty value variables and spaces using ${SPACE} and ${EMPTY}, respectively. If more than one space is needed, it is possible to use like ${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 built-in keywords in the robot framework.

Leave a Comment

Your email address will not be published. Required fields are marked *