Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

BuiltIn

Calls the named method of the given object with the provided arguments.

Arguments

ArgumentTypeDefault value
objectnull
method_namenull
argsnull
kwargsnull

The possible return value from the method is returned and can be assigned to a variable. Keyword fails both if the object does not have a method with the given name or if executing the method raises an exception.

Possible equal signs in arguments must be escaped with a backslash like \=.

Examples:

Call Method${hashtable}putmynamemyvalue
${isempty} =Call Method${hashtable}isEmpty
Should Not Be True${isempty}
${value} =Call Method${hashtable}getmyname
Should Be Equal${value}myvalue
Call Method${object}kwargsname=valuefoo=bar
Call Method${object}positionalescaped\=equals

Catenates the given items together and returns the resulted string.

Arguments

ArgumentTypeDefault value
itemsnull

By default, items are catenated with spaces, but if the first item contains the string SEPARATOR=<sep>, the separator <sep> is used instead. Items are converted into strings when necessary.

Examples:

${str1} =CatenateHelloworld
${str2} =CatenateSEPARATOR=---Helloworld
${str3} =CatenateSEPARATOR=Helloworld

=>

${str1} = 'Hello world' ${str2} = 'Hello---world' ${str3} = 'Helloworld'

Displays the given messages in the log file as keyword arguments.

Arguments

ArgumentTypeDefault value
messagesnull

This keyword does nothing with the arguments it receives, but as they are visible in the log, this keyword can be used to display simple messages. Given arguments are ignored so thoroughly that they can even contain non-existing variables. If you are interested about variable values, you can use the Log or Log Many keywords.

Skips the current FOR loop iteration and continues from the next.


NOTE: Robot Framework 5.0 added support for native CONTINUE statement that is recommended over this keyword. In the examples below, Continue For Loop can simply be replaced with CONTINUE. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

IF '${var}' == 'CONTINUE' CONTINUE

This keyword will eventually be deprecated and removed.


Skips the remaining keywords in the current FOR loop iteration and continues from the next one. Starting from Robot Framework 5.0, this keyword can only be used inside a loop, not in a keyword used in a loop.

Usage

FOR${var}IN@{VALUES}
Run Keyword If'${var}' == 'CONTINUE'Continue For Loop
Do Something${var}
END

See Continue For Loop If to conditionally continue a FOR loop without using Run Keyword If or other wrapper keywords.

Skips the current FOR loop iteration if the condition is true.

Arguments

ArgumentTypeDefault value
conditionnull

NOTE: Robot Framework 5.0 added support for native CONTINUE statement and for inline IF, and that combination should be used instead of this keyword. For example, Continue For Loop If usage in the example below could be replaced with

IF '${var}' == 'CONTINUE' CONTINUE

This keyword will eventually be deprecated and removed.


A wrapper for Continue For Loop to continue a FOR loop based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Usage

FOR${var}IN@{VALUES}
Continue For Loop If'${var}' == 'CONTINUE'
Do Something${var}
END

Converts the given item to a binary string.

Arguments

ArgumentTypeDefault value
itemnull
baseNone
prefixNone
lengthNone

The item, with an optional base, is first converted to an integer using Convert To Integer internally. After that it is converted to a binary number (base 2) represented as a string such as 1011.

The returned value can contain an optional prefix and can be required to be of minimum length (excluding the prefix and a possible minus sign). If the value is initially shorter than the required length, it is padded with zeros.

Examples:

${result} =Convert To Binary10# Result is 1010
${result} =Convert To BinaryFbase=16prefix=0b# Result is 0b1111
${result} =Convert To Binary-2prefix=Blength=4# Result is -B0010

See also Convert To Integer, Convert To Octal and Convert To Hex.

Converts the given item to Boolean true or false.

Arguments

ArgumentTypeDefault value
itemnull

Handles strings True and False (case-insensitive) as expected, otherwise returns item's truth value using Python's bool() method.

Converts the given input to bytes according to the input_type.

Arguments

ArgumentTypeDefault value
inputnull
input_typetext

Valid input types are listed below:

  • text: Converts text to bytes character by character. All characters with ordinal below 256 can be used and are converted to bytes with same values. Many characters are easiest to represent using escapes like \x00 or \xff. Supports both Unicode strings and bytes.
  • int: Converts integers separated by spaces to bytes. Similarly as with Convert To Integer, it is possible to use binary, octal, or hex values by prefixing the values with 0b, 0o, or 0x, respectively.
  • hex: Converts hexadecimal values to bytes. Single byte is always two characters long (e.g. 01 or FF). Spaces are ignored and can be used freely as a visual separator.
  • bin: Converts binary values to bytes. Single byte is always eight characters long (e.g. 00001010). Spaces are ignored and can be used freely as a visual separator.

In addition to giving the input as a string, it is possible to use lists or other iterables containing individual characters or numbers. In that case numbers do not need to be padded to certain length and they cannot contain extra spaces.

Examples (last column shows returned bytes):

${bytes} =Convert To Byteshyvä# hyv\xe4
${bytes} =Convert To Byteshyv\xe4# hyv\xe4
${bytes} =Convert To Bytes\xff\x07# \xff\x07
${bytes} =Convert To Bytes82 70int# RF
${bytes} =Convert To Bytes0b10 0x10int# \x02\x10
${bytes} =Convert To Bytesff 00 07hex# \xff\x00\x07
${bytes} =Convert To Bytes52462121hex# RF!!
${bytes} =Convert To Bytes0000 1000bin# \x08
${input} =Create List1212
${bytes} =Convert To Bytes${input}int# \x01\x02\x0c
${bytes} =Convert To Bytes${input}hex# \x01\x02\x12

Use Encode String To Bytes in String library if you need to convert text to bytes using a certain encoding.

Converts the given item to a hexadecimal string.

Arguments

ArgumentTypeDefault value
itemnull
baseNone
prefixNone
lengthNone
lowercaseFalse

The item, with an optional base, is first converted to an integer using Convert To Integer internally. After that it is converted to a hexadecimal number (base 16) represented as a string such as FF0A.

The returned value can contain an optional prefix and can be required to be of minimum length (excluding the prefix and a possible minus sign). If the value is initially shorter than the required length, it is padded with zeros.

By default the value is returned as an upper case string, but the lowercase argument a true value (see Boolean arguments) turns the value (but not the given prefix) to lower case.

Examples:

${result} =Convert To Hex255# Result is FF
${result} =Convert To Hex-10prefix=0xlength=2# Result is -0x0A
${result} =Convert To Hex255prefix=Xlowercase=yes# Result is Xff

See also Convert To Integer, Convert To Binary and Convert To Octal.

Converts the given item to an integer number.

Arguments

ArgumentTypeDefault value
itemnull
baseNone

If the given item is a string, it is by default expected to be an integer in base 10. There are two ways to convert from other bases:

  • Give base explicitly to the keyword as base argument.
  • Prefix the given string with the base so that 0b means binary (base 2), 0o means octal (base 8), and 0x means hex (base 16). The prefix is considered only when base argument is not given and may itself be prefixed with a plus or minus sign.

The syntax is case-insensitive and possible spaces are ignored.

Examples:

${result} =Convert To Integer100# Result is 100
${result} =Convert To IntegerFF AA16# Result is 65450
${result} =Convert To Integer1008# Result is 64
${result} =Convert To Integer-1002# Result is -4
${result} =Convert To Integer0b100# Result is 4
${result} =Convert To Integer-0x100# Result is -256

See also Convert To Number, Convert To Binary, Convert To Octal, Convert To Hex, and Convert To Bytes.

Converts the given item to a floating point number.

Arguments

ArgumentTypeDefault value
itemnull
precisionNone

If the optional precision is positive or zero, the returned number is rounded to that number of decimal digits. Negative precision means that the number is rounded to the closest multiple of 10 to the power of the absolute precision. If a number is equally close to a certain precision, it is always rounded away from zero.

Examples:

${result} =Convert To Number42.512# Result is 42.512
${result} =Convert To Number42.5121# Result is 42.5
${result} =Convert To Number42.5120# Result is 43.0
${result} =Convert To Number42.512-1# Result is 40.0

Notice that machines generally cannot store floating point numbers accurately. This may cause surprises with these numbers in general and also when they are rounded. For more information see, for example, these resources:

If you want to avoid possible problems with floating point numbers, you can implement custom keywords using Python's decimal or fractions modules.

If you need an integer number, use Convert To Integer instead.

Converts the given item to an octal string.

Arguments

ArgumentTypeDefault value
itemnull
baseNone
prefixNone
lengthNone

The item, with an optional base, is first converted to an integer using Convert To Integer internally. After that it is converted to an octal number (base 8) represented as a string such as 775.

The returned value can contain an optional prefix and can be required to be of minimum length (excluding the prefix and a possible minus sign). If the value is initially shorter than the required length, it is padded with zeros.

Examples:

${result} =Convert To Octal10# Result is 12
${result} =Convert To Octal-Fbase=16prefix=0# Result is -017
${result} =Convert To Octal16prefix=octlength=4# Result is oct0020

See also Convert To Integer, Convert To Binary and Convert To Hex.

Converts the given item to a Unicode string.

Arguments

ArgumentTypeDefault value
itemnull

Strings are also NFC normalized.

Use Encode String To Bytes and Decode Bytes To String keywords in String library if you need to convert between Unicode and byte strings using different encodings. Use Convert To Bytes if you just want to create byte strings.

Creates and returns a dictionary based on the given items.

Arguments

ArgumentTypeDefault value
itemsnull

Items are typically given using the key=value syntax same way as &{dictionary} variables are created in the Variable table. Both keys and values can contain variables, and possible equal sign in key can be escaped with a backslash like escaped\=key=value. It is also possible to get items from existing dictionaries by simply using them like &{dict}.

Alternatively items can be specified so that keys and values are given separately. This and the key=value syntax can even be combined, but separately given items must be first. If same key is used multiple times, the last value has precedence.

The returned dictionary is ordered, and values with strings as keys can also be accessed using a convenient dot-access syntax like ${dict.key}. Technically the returned dictionary is Robot Framework's own DotDict instance. If there is a need, it can be converted into a regular Python dict instance by using the Convert To Dictionary keyword from the Collections library.

Examples:

&{dict} =Create Dictionarykey=valuefoo=bar# key=value syntax
Should Be True${dict} == {'key': 'value', 'foo': 'bar'}
&{dict2} =Create Dictionarykeyvaluefoobar# separate key and value
Should Be Equal${dict}${dict2}
&{dict} =Create Dictionary${1}=${2}&{dict}foo=new# using variables
Should Be True${dict} == {1: 2, 'key': 'value', 'foo': 'new'}
Should Be Equal${dict.key}value# dot-access

Returns a list containing given items.

Arguments

ArgumentTypeDefault value
itemsnull

The returned list can be assigned both to ${scalar} and @{list} variables.

Examples:

@{list} =Create Listabc
${scalar} =Create Listabc
${ints} =Create List${1}${2}${3}

Evaluates the given expression in Python and returns the result.

Arguments

ArgumentTypeDefault value
expressionnull
modulesNone
namespaceNone

expression is evaluated in Python as explained in the Evaluating expressions section.

modules argument can be used to specify a comma separated list of Python modules to be imported and added to the evaluation namespace.

namespace argument can be used to pass a custom evaluation namespace as a dictionary. Possible modules are added to this namespace.

Variables used like ${variable} are replaced in the expression before evaluation. Variables are also available in the evaluation namespace and can be accessed using the special $variable syntax as explained in the Evaluating expressions section.

Starting from Robot Framework 3.2, modules used in the expression are imported automatically. There are, however, two cases where they need to be explicitly specified using the modules argument:

  • When nested modules like rootmod.submod are implemented so that the root module does not automatically import sub modules. This is illustrated by the selenium.webdriver example below.
  • When using a module in the expression part of a list comprehension. This is illustrated by the json example below.

Examples (expecting ${result} is number 3.14):

${status} =Evaluate0 < ${result} < 10# Would also work with string '3.14'
${status} =Evaluate0 < $result < 10# Using variable itself, not string representation
${random} =Evaluaterandom.randint(0, sys.maxsize)
${options} =Evaluateselenium.webdriver.ChromeOptions()modules=selenium.webdriver
${items} =Evaluate[json.loads(item) for item in ('1', '"b"')]modules=json
${ns} =Create Dictionaryx=${4}y=${2}
${result} =Evaluatex*10 + ynamespace=${ns}

=>

${status} = True ${random} = <random integer> ${options} = ChromeOptions instance ${items} = [1, 'b'] ${result} = 42

NOTE: Prior to Robot Framework 3.2 using modules=rootmod.submod was not enough to make the root module itself available in the evaluation namespace. It needed to be taken into use explicitly like modules=rootmod, rootmod.submod.

Stops executing the enclosing FOR loop.


NOTE: Robot Framework 5.0 added support for native BREAK statement that is recommended over this keyword. In the examples below, Exit For Loop can simply be replaced with BREAK. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

IF '${var}' == 'EXIT' BREAK

This keyword will eventually be deprecated and removed.


Exits the enclosing FOR loop and continues execution after it. Starting from Robot Framework 5.0, this keyword can only be used inside a loop, not in a keyword used in a loop.

Usage

FOR${var}IN@{VALUES}
Run Keyword If'${var}' == 'EXIT'Exit For Loop
Do Something${var}
END

See Exit For Loop If to conditionally exit a FOR loop without using Run Keyword If or other wrapper keywords.

Stops executing the enclosing FOR loop if the condition is true.

Arguments

ArgumentTypeDefault value
conditionnull

NOTE: Robot Framework 5.0 added support for native BREAK statement and for inline IF, and that combination should be used instead of this keyword. For example, Exit For Loop If usage in the example below could be replaced with

IF '${var}' == 'EXIT' BREAK

This keyword will eventually be deprecated and removed.


A wrapper for Exit For Loop to exit a FOR loop based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Usage

FOR${var}IN@{VALUES}
Exit For Loop If'${var}' == 'EXIT'
Do Something${var}
END

Fails the test with the given message and optionally alters its tags.

Arguments

ArgumentTypeDefault value
msgNone
tagsnull

The error message is specified using the msg argument. It is possible to use HTML in the given error message, similarly as with any other keyword accepting an error message, by prefixing the error with *HTML*.

It is possible to modify tags of the current test case by passing tags after the message. Tags starting with a hyphen (e.g. -regression) are removed and others added. Tags are modified using Set Tags and Remove Tags internally, and the semantics setting and removing them are the same as with these keywords.

Examples:

FailTest not ready# Fails with the given message.
Fail*HTML*<b>Test not ready</b># Fails using HTML in the message.
FailTest not readynot-ready# Fails and adds 'not-ready' tag.
FailOS not supported-regression# Removes tag 'regression'.
FailMy messagetag-t*# Removes all tags starting with 't' except the newly added 'tag'.

See Fatal Error if you need to stop the whole test execution.

Stops the whole test execution.

Arguments

ArgumentTypeDefault value
msgNone

The test or suite where this keyword is used fails with the provided message, and subsequent tests fail with a canned message. Possible teardowns will nevertheless be executed.

See Fail if you only want to stop one test case unconditionally.

Returns and logs how many times item is found from container.

Arguments

ArgumentTypeDefault value
containernull
itemnull

This keyword works with Python strings and lists and all objects that either have count method or can be converted to Python lists.

Usage

${count} =Get Count${some item}interesting value
Should Be True5 < ${count} < 10

Returns and logs the length of the given item as an integer.

Arguments

ArgumentTypeDefault value
itemnull

The item can be anything that has a length, for example, a string, a list, or a mapping. The keyword first tries to get the length with the Python function len, which calls the item's __len__ method internally. If that fails, the keyword tries to call the item's possible length and size methods directly. The final attempt is trying to get the value of the item's length attribute. If all these attempts are unsuccessful, the keyword fails.

Examples:

${length} =Get LengthHello, world!
Should Be Equal As Integers${length}13
@{list} =Create ListHello,world!
${length} =Get Length${list}
Should Be Equal As Integers${length}2

See also Length Should Be, Should Be Empty and Should Not Be Empty.

Returns the currently active instance of the specified library.

Arguments

ArgumentTypeDefault value
nameNone
allFalse

This keyword makes it easy for libraries to interact with other libraries that have state. This is illustrated by the Python example below:

from robot.libraries.BuiltIn import BuiltIn def title_should_start_with(expected): seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary') title = seleniumlib.get_title() if not title.startswith(expected): raise AssertionError("Title '%s' did not start with '%s'" % (title, expected))

It is also possible to use this keyword in the test data and pass the returned library instance to another keyword. If a library is imported with a custom name, the name used to get the instance must be that name and not the original library name.

If the optional argument all is given a true value, then a dictionary mapping all library names to instances will be returned.

Usage

&{all libs} =Get library instanceall=True

Returns the given time in the requested format.

Arguments

ArgumentTypeDefault value
formattimestamp
time_NOW

NOTE: DateTime library contains much more flexible keywords for getting the current date and time and for date and time handling in general.

How time is returned is determined based on the given format string as follows. Note that all checks are case-insensitive.

1) If format contains the word epoch, the time is returned in seconds after the UNIX epoch (1970-01-01 00:00:00 UTC). The return value is always an integer.

2) If format contains any of the words year, month, day, hour, min, or sec, only the selected parts are returned. The order of the returned parts is always the one in the previous sentence and the order of words in format is not significant. The parts are returned as zero-padded strings (e.g. May -> 05).

3) Otherwise (and by default) the time is returned as a timestamp string in the format 2006-02-24 15:08:31.

By default this keyword returns the current local time, but that can be altered using time argument as explained below. Note that all checks involving strings are case-insensitive.

1) If time is a number, or a string that can be converted to a number, it is interpreted as seconds since the UNIX epoch. This documentation was originally written about 1177654467 seconds after the epoch.

2) If time is a timestamp, that time will be used. Valid timestamp formats are YYYY-MM-DD hh:mm:ss and YYYYMMDD hhmmss.

3) If time is equal to NOW (default), the current local time is used.

4) If time is equal to UTC, the current time in UTC is used.

5) If time is in the format like NOW - 1 day or UTC + 1 hour 30 min, the current local/UTC time plus/minus the time specified with the time string is used. The time string format is described in an appendix of Robot Framework User Guide.

Examples (expecting the current local time is 2006-03-29 15:06:21):

${time} =Get Time
${secs} =Get Timeepoch
${year} =Get Timereturn year
${yyyy}${mm}${dd} =Get Timeyear,month,day
@{time} =Get Timeyear month day hour min sec
${y}${s} =Get Timeseconds and year

=>

${time} = '2006-03-29 15:06:21' ${secs} = 1143637581 ${year} = '2006' ${yyyy} = '2006', ${mm} = '03', ${dd} = '29' @{time} = ['2006', '03', '29', '15', '06', '21'] ${y} = '2006' ${s} = '21'

Examples (expecting the current local time is 2006-03-29 15:06:21 and UTC time is 2006-03-29 12:06:21):

${time} =Get Time1177654467# Time given as epoch seconds
${secs} =Get Timesec2007-04-27 09:14:27# Time given as a timestamp
${year} =Get TimeyearNOW# The local time of execution
@{time} =Get Timehour min secNOW + 1h 2min 3s# 1h 2min 3s added to the local time
@{utc} =Get Timehour min secUTC# The UTC time of execution
${hour} =Get TimehourUTC - 1 hour# 1h subtracted from the UTC time

=>

${time} = '2007-04-27 09:14:27' ${secs} = 27 ${year} = '2006' @{time} = ['16', '08', '24'] @{utc} = ['12', '06', '21'] ${hour} = '11'

Returns variable value or default if the variable does not exist.

Arguments

ArgumentTypeDefault value
namenull
defaultNone

The name of the variable can be given either as a normal variable name like ${name} or in escaped format like $name or \${name}. For the reasons explained in the Using variables with keywords creating or accessing variables section, using the escaped format is recommended.

Examples:

${x} = Get Variable Value $a default ${y} = Get Variable Value $a ${b} ${z} = Get Variable Value $z

=>

  • ${x} gets value of ${a} if ${a} exists and string default otherwise
  • ${y} gets value of ${a} if ${a} exists and value of ${b} otherwise
  • ${z} is set to Python None if it does not exist previously

Returns a dictionary containing all variables in the current scope.

Arguments

ArgumentTypeDefault value
no_decorationFalse

Variables are returned as a special dictionary that allows accessing variables in space, case, and underscore insensitive manner similarly as accessing variables in the test data. This dictionary supports all same operations as normal Python dictionaries and, for example, Collections library can be used to access or modify it. Modifying the returned dictionary has no effect on the variables available in the current scope.

By default variables are returned with ${}, @{} or &{} decoration based on variable types. Giving a true value (see Boolean arguments) to the optional argument no_decoration will return the variables without the decoration.

Usage

${example_variable} =Set Variableexample value
${variables} =Get Variables
Dictionary Should Contain Key${variables}\${example_variable}
Dictionary Should Contain Key${variables}\${ExampleVariable}
Set To Dictionary${variables}\${name}value
Variable Should Not Exist\${name}
${no decoration} =Get Variablesno_decoration=Yes
Dictionary Should Contain Key${no decoration}example_variable

Imports a library with the given name and optional arguments.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This functionality allows dynamic importing of libraries while tests are running. That may be necessary, if the library itself is dynamic and not yet available when test data is processed. In a normal case, libraries should be imported using the Library setting in the Setting section.

This keyword supports importing libraries both using library names and physical paths. When paths are used, they must be given in absolute format or found from search path. Forward slashes can be used as path separators in all operating systems.

It is possible to pass arguments to the imported library and also named argument syntax works if the library supports it. WITH NAME syntax can be used to give a custom name to the imported library.

Examples:

Import LibraryMyLibrary
Import Library${CURDIR}/Lib.pyarg1named=arg2WITH NAMECustom

Imports a resource file with the given path.

Arguments

ArgumentTypeDefault value
pathnull

Resources imported with this keyword are set into the test suite scope similarly when importing them in the Setting table using the Resource setting.

The given path must be absolute or found from search path. Forward slashes can be used as path separator regardless the operating system.

Examples:

Import Resource${CURDIR}/resource.txt
Import Resource${CURDIR}/../resources/resource.html
Import Resourcefound_from_pythonpath.robot

Imports a variable file with the given path and optional arguments.

Arguments

ArgumentTypeDefault value
pathnull
argsnull

Variables imported with this keyword are set into the test suite scope similarly when importing them in the Setting table using the Variables setting. These variables override possible existing variables with the same names. This functionality can thus be used to import new variables, for example, for each test in a test suite.

The given path must be absolute or found from search path. Forward slashes can be used as path separator regardless the operating system.

Examples:

Import Variables${CURDIR}/variables.py
Import Variables${CURDIR}/../vars/env.pyarg1arg2
Import Variablesfile_from_pythonpath.py

Fails unless the given keyword exists in the current scope.

Arguments

ArgumentTypeDefault value
namenull
msgNone

Fails also if there are more than one keywords with the same name. Works both with the short name (e.g. Log) and the full name (e.g. BuiltIn.Log).

The default error message can be overridden with the msg argument.

See also Variable Should Exist.

Verifies that the length of the given item is correct.

Arguments

ArgumentTypeDefault value
itemnull
lengthnull
msgNone

The length of the item is got using the Get Length keyword. The default error message can be overridden with the msg argument.

Logs the given message with the given level.

Arguments

ArgumentTypeDefault value
messagenull
levelINFO
htmlFalse
consoleFalse
reprDEPRECATED
formatterstr

Valid levels are TRACE, DEBUG, INFO (default), HTML, WARN, and ERROR. Messages below the current active log level are ignored. See Set Log Level keyword and --loglevel command line option for more details about setting the level.

Messages logged with the WARN or ERROR levels will be automatically visible also in the console and in the Test Execution Errors section in the log file.

If the html argument is given a true value (see Boolean arguments), the message will be considered HTML and special characters such as < are not escaped. For example, logging <img src="image.png"> creates an image when html is true, but otherwise the message is that exact string. An alternative to using the html argument is using the HTML pseudo log level. It logs the message as HTML using the INFO level.

If the console argument is true, the message will be written to the console where test execution was started from in addition to the log file. This keyword always uses the standard output stream and adds a newline after the written message. Use Log To Console instead if either of these is undesirable,

The formatter argument controls how to format the string representation of the message. Possible values are str (default), repr, ascii, len, and type. They work similarly to Python built-in functions with same names. When using repr, bigger lists, dictionaries and other containers are also pretty-printed so that there is one item per row. For more details see String representations.

The old way to control string representation was using the repr argument. This argument has been deprecated and formatter=repr should be used instead.

Examples:

LogHello, world!# Normal INFO message.
LogWarning, world!WARN# Warning.
Log<b>Hello</b>, world!html=yes# INFO message as HTML.
Log<b>Hello</b>, world!HTML# Same as above.
Log<b>Hello</b>, world!DEBUGhtml=true# DEBUG as HTML.
LogHello, console!console=yes# Log also to the console.
LogNull is \x00formatter=repr# Log 'Null is \x00'.

See Log Many if you want to log multiple messages in one go, and Log To Console if you only want to write to the console.

Formatter options type and log are new in Robot Framework 5.0.

Logs the given messages as separate entries using the INFO level.

Arguments

ArgumentTypeDefault value
messagesnull

Supports also logging list and dictionary variable items individually.

Examples:

Log ManyHello${var}
Log Many@{list}&{dict}

See Log and Log To Console keywords if you want to use alternative log levels, use HTML, or log to the console.

Logs the given message to the console.

Arguments

ArgumentTypeDefault value
messagenull
streamSTDOUT
no_newlineFalse
format

By default uses the standard output stream. Using the standard error stream is possible by giving the stream argument value STDERR (case-insensitive).

By default appends a newline to the logged message. This can be disabled by giving the no_newline argument a true value (see Boolean arguments).

By default adds no alignment formatting. The format argument allows, for example, alignment and customized padding of the log message. Please see the format specification for detailed alignment possibilities. This argument is new in Robot Framework 5.0.

Examples:

Log To ConsoleHello, console!
Log To ConsoleHello, stderr!STDERR
Log To ConsoleMessage starts here and isno_newline=true
Log To Consolecontinued without newline.
Log To Consolecenter message with * padformat=*^60
Log To Console30 spaces before msg startsformat=>30

This keyword does not log the message to the normal log file. Use Log keyword, possibly with argument console, if that is desired.

Logs all variables in the current scope with given log level.

Arguments

ArgumentTypeDefault value
levelINFO

Does absolutely nothing.

Skips rest of the current test, setup, or teardown with PASS status.

Arguments

ArgumentTypeDefault value
messagenull
tagsnull

This keyword can be used anywhere in the test data, but the place where used affects the behavior:

  • When used in any setup or teardown (suite, test or keyword), passes that setup or teardown. Possible keyword teardowns of the started keywords are executed. Does not affect execution or statuses otherwise.
  • When used in a test outside setup or teardown, passes that particular test case. Possible test and keyword teardowns are executed.

Possible continuable failures before this keyword is used, as well as failures in executed teardowns, will fail the execution.

It is mandatory to give a message explaining why execution was passed. By default the message is considered plain text, but starting it with *HTML* allows using HTML formatting.

It is also possible to modify test tags passing tags after the message similarly as with Fail keyword. Tags starting with a hyphen (e.g. -regression) are removed and others added. Tags are modified using Set Tags and Remove Tags internally, and the semantics setting and removing them are the same as with these keywords.

Examples:

Pass ExecutionAll features available in this version tested.
Pass ExecutionDeprecated test.deprecated-regression

This keyword is typically wrapped to some other keyword, such as Run Keyword If, to pass based on a condition. The most common case can be handled also with Pass Execution If:

Run Keyword If${rc} < 0Pass ExecutionNegative values are cool.
Pass Execution If${rc} < 0Negative values are cool.

Passing execution in the middle of a test, setup or teardown should be used with care. In the worst case it leads to tests that skip all the parts that could actually uncover problems in the tested application. In cases where execution cannot continue do to external factors, it is often safer to fail the test case and make it non-critical.

Conditionally skips rest of the current test, setup, or teardown with PASS status.

Arguments

ArgumentTypeDefault value
conditionnull
messagenull
tagsnull

A wrapper for Pass Execution to skip rest of the current test, setup or teardown based the given condition. The condition is evaluated similarly as with Should Be True keyword, and message and *tags have same semantics as with Pass Execution.

Usage

FOR${var}IN@{VALUES}
Pass Execution If'${var}' == 'EXPECTED'Correct value was found
Do Something${var}
END

Returns each argument string escaped for use as a regular expression.

Arguments

ArgumentTypeDefault value
patternsnull

This keyword can be used to escape strings to be used with Should Match Regexp and Should Not Match Regexp keywords.

Escaping is done with Python's re.escape() function.

Examples:

${escaped} =Regexp Escape${original}
@{strings} =Regexp Escape@{strings}

Rechecks what keywords the specified library provides.

Arguments

ArgumentTypeDefault value
name_or_instancenull

Can be called explicitly in the test data or by a library itself when keywords it provides have changed.

The library can be specified by its name or as the active instance of the library. The latter is especially useful if the library itself calls this keyword as a method.

Removes given tags from the current test or all tests in a suite.

Arguments

ArgumentTypeDefault value
tagsnull

Tags can be given exactly or using a pattern with *, ? and [chars] acting as wildcards. See the Glob patterns section for more information.

This keyword can affect either one test case or all test cases in a test suite similarly as Set Tags keyword.

The current tags are available as a built-in variable @{TEST TAGS}.

Usage

Remove Tagsmytagsomething-*?ython

See Set Tags if you want to add certain tags and Fail if you want to fail the test case after setting and/or removing tags.

Executes the specified keyword multiple times.

Arguments

ArgumentTypeDefault value
repeatnull
namenull
argsnull

name and args define the keyword that is executed similarly as with Run Keyword. repeat specifies how many times (as a count) or how long time (as a timeout) the keyword should be executed.

If repeat is given as count, it specifies how many times the keyword should be executed. repeat can be given as an integer or as a string that can be converted to an integer. If it is a string, it can have postfix times or x (case and space insensitive) to make the expression more explicit.

If repeat is given as timeout, it must be in Robot Framework's time format (e.g. 1 minute, 2 min 3 s). Using a number alone (e.g. 1 or 1.5) does not work in this context.

If repeat is zero or negative, the keyword is not executed at all. This keyword fails immediately if any of the execution rounds fails.

Examples:

Repeat Keyword5 timesGo to Previous Page
Repeat Keyword${var}Some Keywordarg1arg2
Repeat Keyword2 minutesSome Keywordarg1arg2

Replaces variables in the given text with their current values.

Arguments

ArgumentTypeDefault value
textnull

If the text contains undefined variables, this keyword fails. If the given text contains only a single variable, its value is returned as-is and it can be any object. Otherwise this keyword always returns a string.

Usage

The file template.txt contains Hello ${NAME}! and variable ${NAME} has the value Robot.

${template} =Get File${CURDIR}/template.txt
${message} =Replace Variables${template}
Should Be Equal${message}Hello Robot!

Returns from the enclosing user keyword.

Arguments

ArgumentTypeDefault value
return_valuesnull

NOTE: Robot Framework 5.0 added support for native RETURN statement that is recommended over this keyword. In the examples below, Return From Keyword can simply be replaced with RETURN. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

IF ${rc} < 0 RETURN

This keyword will eventually be deprecated and removed.


This keyword can be used to return from a user keyword with PASS status without executing it fully. It is also possible to return values similarly as with the [Return] setting. For more detailed information about working with the return values, see the User Guide.

This keyword is typically wrapped to some other keyword, such as Run Keyword If, to return based on a condition:

Run Keyword If ${rc} < 0 Return From Keyword

It is possible to use this keyword to return from a keyword also inside a for loop. That, as well as returning values, is demonstrated by the Find Index keyword in the following somewhat advanced example. Notice that it is often a good idea to move this kind of complicated logic into a library.

*** Variables *** @{LIST} = foo baz *** Test Cases *** Example ${index} = Find Index baz @{LIST} Should Be Equal ${index} ${1} ${index} = Find Index non existing @{LIST} Should Be Equal ${index} ${-1} *** Keywords *** Find Index [Arguments] ${element} @{items} ${index} = Set Variable ${0} FOR ${item} IN @{items} Run Keyword If '${item}' == '${element}' Return From Keyword ${index} ${index} = Set Variable ${index + 1} END Return From Keyword ${-1}

The most common use case, returning based on an expression, can be accomplished directly with Return From Keyword If. See also Run Keyword And Return and Run Keyword And Return If.

Returns from the enclosing user keyword if condition is true.

Arguments

ArgumentTypeDefault value
conditionnull
return_valuesnull

NOTE: Robot Framework 5.0 added support for native RETURN statement and for inline IF, and that combination should be used instead of this keyword. For example, Return From Keyword usage in the example below could be replaced with

IF '${item}' == '${element}' RETURN ${index}

This keyword will eventually be deprecated and removed.


A wrapper for Return From Keyword to return based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Given the same example as in Return From Keyword, we can rewrite the Find Index keyword as follows:

*** Keywords *** Find Index [Arguments] ${element} @{items} ${index} = Set Variable ${0} FOR ${item} IN @{items} Return From Keyword If '${item}' == '${element}' ${index} ${index} = Set Variable ${index + 1} END Return From Keyword ${-1}

See also Run Keyword And Return and Run Keyword And Return If.

Executes the given keyword with the given arguments.

Arguments

ArgumentTypeDefault value
namenull
argsnull

Because the name of the keyword to execute is given as an argument, it can be a variable and thus set dynamically, e.g. from a return value of another keyword or from the command line.

Runs the keyword and continues execution even if a failure occurs.

Arguments

ArgumentTypeDefault value
namenull
argsnull

The keyword name and arguments work as with Run Keyword.

Usage

Run Keyword And Continue On FailureFailThis is a stupid example
LogThis keyword is executed

The execution is not continued if the failure is caused by invalid syntax, timeout, or fatal exception.

Runs the keyword and checks that the expected error occurred.

Arguments

ArgumentTypeDefault value
expected_errornull
namenull
argsnull

The keyword to execute and its arguments are specified using name and *args exactly like with Run Keyword.

The expected error must be given in the same format as in Robot Framework reports. By default it is interpreted as a glob pattern with *, ? and [chars] as wildcards, but that can be changed by using various prefixes explained in the table below. Prefixes are case-sensitive and they must be separated from the actual message with a colon and an optional space like PREFIX: Message or PREFIX:Message.

PrefixExplanation
EQUALSExact match. Especially useful if the error contains glob wildcards.
STARTSError must start with the specified error.
REGEXPRegular expression match.
GLOBSame as the default behavior.

See the Pattern matching section for more information about glob patterns and regular expressions.

If the expected error occurs, the error message is returned and it can be further processed or tested if needed. If there is no error, or the error does not match the expected error, this keyword fails.

Examples:

Run Keyword And Expect ErrorMy errorKeywordarg
Run Keyword And Expect ErrorValueError: *Some Keyword
Run Keyword And Expect ErrorSTARTS: ValueError:Some Keyword
Run Keyword And Expect ErrorEQUALS:No match for '//input[@type="text"]'
...Find Element//input[@type="text"]
${msg} =Run Keyword And Expect Error*
...Keywordarg1arg2
Log To Console${msg}

Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword.

NOTE: Regular expression matching used to require only the beginning of the error to match the given pattern. That was changed in Robot Framework 5.0 and nowadays the pattern must match the error fully. To match only the beginning, add .* at the end of the pattern like REGEXP: Start.*.

NOTE: Robot Framework 5.0 introduced native TRY/EXCEPT functionality that is generally recommended for error handling. It supports same pattern matching syntax as this keyword.

Runs the given keyword with the given arguments and ignores possible error.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword returns two values, so that the first is either string PASS or FAIL, depending on the status of the executed keyword. The second value is either the return value of the keyword or the received error message. See Run Keyword And Return Status If you are only interested in the execution status.

The keyword name and arguments work as in Run Keyword. See Run Keyword If for a usage example.

Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails.

NOTE: Robot Framework 5.0 introduced native TRY/EXCEPT functionality that is generally recommended for error handling.

Runs the specified keyword and returns from the enclosing user keyword.

Arguments

ArgumentTypeDefault value
namenull
argsnull

The keyword to execute is defined with name and *args exactly like with Run Keyword. After running the keyword, returns from the enclosing user keyword and passes possible return value from the executed keyword further. Returning from a keyword has exactly same semantics as with Return From Keyword.

Usage

Run Keyword And ReturnMy Keywordarg1arg2
# Above is equivalent to:
${result} =My Keywordarg1arg2
Return From Keyword${result}

Use Run Keyword And Return If if you want to run keyword and return based on a condition.

Runs the specified keyword and returns from the enclosing user keyword.

Arguments

ArgumentTypeDefault value
conditionnull
namenull
argsnull

A wrapper for Run Keyword And Return to run and return based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Usage

Run Keyword And Return If${rc} > 0My Keywordarg1arg2
# Above is equivalent to:
Run Keyword If${rc} > 0Run Keyword And ReturnMy Keyword arg1arg2

Use Return From Keyword If if you want to return a certain value based on a condition.

Runs the given keyword with given arguments and returns the status as a Boolean value.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword returns Boolean True if the keyword that is executed succeeds and False if it fails. This is useful, for example, in combination with Run Keyword If. If you are interested in the error message or return value, use Run Keyword And Ignore Error instead.

The keyword name and arguments work as in Run Keyword.

Usage

${passed} =Run Keyword And Return StatusKeywordargs
Run Keyword If${passed}Another keyword

Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails.

Runs the specified keyword logs a warning if the keyword fails.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword is similar to Run Keyword And Ignore Error but if the executed keyword fails, the error message is logged as a warning to make it more visible. Returns status and possible return value or error message exactly like Run Keyword And Ignore Error does.

Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails.

New in Robot Framework 4.0.

Runs the given keyword with the given arguments, if condition is true.

Arguments

ArgumentTypeDefault value
conditionnull
namenull
argsnull

NOTE: Robot Framework 4.0 introduced built-in IF/ELSE support and using that is generally recommended over using this keyword.

The given condition is evaluated in Python as explained in the Evaluating expressions section, and name and *args have same semantics as with Run Keyword.

Example, a simple if/else construct:

Run Keyword If'${status}' == 'OK'Some Actionarg
Run Keyword If'${status}' != 'OK'Another Action

In this example, only either Some Action or Another Action is executed, based on the value of the ${status} variable.

Variables used like ${variable}, as in the examples above, are replaced in the expression before evaluation. Variables are also available in the evaluation namespace and can be accessed using special $variable syntax as explained in the Evaluating expressions section.

Usage

Run Keyword If$result is None or $result == 'FAIL'Keyword

This keyword supports also optional ELSE and ELSE IF branches. Both of them are defined in *args and must use exactly format ELSE or ELSE IF, respectively. ELSE branches must contain first the name of the keyword to execute and then its possible arguments. ELSE IF branches must first contain a condition, like the first argument to this keyword, and then the keyword to execute and its possible arguments. It is possible to have ELSE branch after ELSE IF and to have multiple ELSE IF branches. Nested Run Keyword If usage is not supported when using ELSE and/or ELSE IF branches.

Given previous example, if/else construct can also be created like this:

Run Keyword If'${status}' == 'PASS'Some ActionargELSEAnother Action

The return value of this keyword is the return value of the actually executed keyword or Python None if no keyword was executed (i.e. if condition was false). Hence, it is recommended to use ELSE and/or ELSE IF branches to conditionally assign return values from keyword to variables (see Set Variable If you need to set fixed values conditionally). This is illustrated by the example below:

${var1} =Run Keyword If${rc} == 0Some keyword returning a value
...ELSE IF0 < ${rc} < 42Another keyword
...ELSE IF${rc} < 0Another keyword with args${rc}arg2
...ELSEFinal keyword to handle abnormal cases${rc}
${var2} =Run Keyword If${condition}Some keyword

In this example, ${var2} will be set to None if ${condition} is false.

Notice that ELSE and ELSE IF control words must be used explicitly and thus cannot come from variables. If you need to use literal ELSE and ELSE IF strings as arguments, you can escape them with a backslash like \ELSE and \ELSE IF.

Runs the given keyword with the given arguments, if all tests passed.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword can only be used in a suite teardown. Trying to use it anywhere else results in an error.

Otherwise, this keyword works exactly like Run Keyword, see its documentation for more details.

Runs the given keyword with the given arguments, if one or more tests failed.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword can only be used in a suite teardown. Trying to use it anywhere else results in an error.

Otherwise, this keyword works exactly like Run Keyword, see its documentation for more details.

Runs the given keyword with the given arguments, if the test failed.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword can only be used in a test teardown. Trying to use it anywhere else results in an error.

Otherwise, this keyword works exactly like Run Keyword, see its documentation for more details.

Runs the given keyword with the given arguments, if the test passed.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword can only be used in a test teardown. Trying to use it anywhere else results in an error.

Otherwise, this keyword works exactly like Run Keyword, see its documentation for more details.

Runs the given keyword if either a test or a keyword timeout has occurred.

Arguments

ArgumentTypeDefault value
namenull
argsnull

This keyword can only be used in a test teardown. Trying to use it anywhere else results in an error.

Otherwise, this keyword works exactly like Run Keyword, see its documentation for more details.

DEPRECATED since RF 5.0. Use Native IF/ELSE or Run Keyword If instead.

Arguments

ArgumentTypeDefault value
conditionnull
namenull
argsnull

Runs the given keyword with the given arguments if condition is false.

See Run Keyword If for more information and an example. Notice that this keyword does not support ELSE or ELSE IF branches like Run Keyword If does.

Executes all the given keywords in a sequence.

Arguments

ArgumentTypeDefault value
keywordsnull

This keyword is mainly useful in setups and teardowns when they need to take care of multiple actions and creating a new higher level user keyword would be an overkill.

By default all arguments are expected to be keywords to be executed.

Examples:

Run KeywordsInitialize databaseStart serversClear logs
Run Keywords${KW 1}${KW 2}
Run Keywords@{KEYWORDS}

Keywords can also be run with arguments using upper case AND as a separator between keywords. The keywords are executed so that the first argument is the first keyword and proceeding arguments until the first AND are arguments to it. First argument after the first AND is the second keyword and proceeding arguments until the next AND are its arguments. And so on.

Examples:

Run KeywordsInitialize databasedb1ANDStart serversserver1server2
Run KeywordsInitialize database${DB NAME}ANDStart servers@{SERVERS}ANDClear logs
Run Keywords${KW}AND@{KW WITH ARGS}

Notice that the AND control argument must be used explicitly and cannot itself come from a variable. If you need to use literal AND string as argument, you can either use variables or escape it with a backslash like \AND.

Makes a variable available globally in all tests and suites.

Arguments

ArgumentTypeDefault value
namenull
valuesnull

Variables set with this keyword are globally available in all subsequent test suites, test cases and user keywords. Also variables created Variables sections are overridden. Variables assigned locally based on keyword return values or by using Set Suite Variable, Set Test Variable or Set Local Variable override these variables in that scope, but the global value is not changed in those cases.

In practice setting variables with this keyword has the same effect as using command line options --variable and --variablefile. Because this keyword can change variables everywhere, it should be used with care.

See Set Suite Variable for more information and usage examples. See also the Using variables with keywords creating or accessing variables section for information why it is recommended to give the variable name in escaped format like $name or \${name} instead of the normal ${name}.

Sets the resolution order to use when a name matches multiple keywords.

Arguments

ArgumentTypeDefault value
search_ordernull

The library search order is used to resolve conflicts when a keyword name in the test data matches multiple keywords. The first library (or resource, see below) containing the keyword is selected and that keyword implementation used. If the keyword is not found from any library (or resource), test executing fails the same way as when the search order is not set.

When this keyword is used, there is no need to use the long LibraryName.Keyword Name notation. For example, instead of having

MyLibrary.Keywordarg
MyLibrary.Another Keyword
MyLibrary.Keywordxxx

you can have

Set Library Search OrderMyLibrary
Keywordarg
Another Keyword
Keywordxxx

This keyword can be used also to set the order of keywords in different resource files. In this case resource names must be given without paths or extensions like:

Set Library Search Orderresourceanother_resource

NOTE:

  • The search order is valid only in the suite where this keywords is used.
  • Keywords in resources always have higher priority than keywords in libraries regardless the search order.
  • The old order is returned and can be used to reset the search order later.
  • Library and resource names in the search order are both case and space insensitive.

Makes a variable available everywhere within the local scope.

Arguments

ArgumentTypeDefault value
namenull
valuesnull

Variables set with this keyword are available within the local scope of the currently executed test case or in the local scope of the keyword in which they are defined. For example, if you set a variable in a user keyword, it is available only in that keyword. Other test cases or keywords will not see variables set with this keyword.

This keyword is equivalent to a normal variable assignment based on a keyword return value. For example,

${var} = Set Variable value @{list} = Create List item1 item2 item3

are equivalent with

Set Local Variable @var value Set Local Variable @list item1 item2 item3

The main use case for this keyword is creating local variables in libraries.

See Set Suite Variable for more information and usage examples. See also the Using variables with keywords creating or accessing variables section for information why it is recommended to give the variable name in escaped format like $name or \${name} instead of the normal ${name}.

See also Set Global Variable and Set Test Variable.

Sets the log threshold to the specified level and returns the old level.

Arguments

ArgumentTypeDefault value
levelnull

Messages below the level will not logged. The default logging level is INFO, but it can be overridden with the command line option --loglevel.

The available levels: TRACE, DEBUG, INFO (default), WARN, ERROR and NONE (no logging).

Sets documentation for the current test suite.

Arguments

ArgumentTypeDefault value
docnull
appendFalse
topFalse

By default the possible existing documentation is overwritten, but this can be changed using the optional append argument similarly as with Set Test Message keyword.

This keyword sets the documentation of the current suite by default. If the optional top argument is given a true value (see Boolean arguments), the documentation of the top level suite is altered instead.

The documentation of the current suite is available as a built-in variable ${SUITE DOCUMENTATION}.

Sets metadata for the current test suite.

Arguments

ArgumentTypeDefault value
namenull
valuenull
appendFalse
topFalse

By default possible existing metadata values are overwritten, but this can be changed using the optional append argument similarly as with Set Test Message keyword.

This keyword sets the metadata of the current suite by default. If the optional top argument is given a true value (see Boolean arguments), the metadata of the top level suite is altered instead.

The metadata of the current suite is available as a built-in variable ${SUITE METADATA} in a Python dictionary. Notice that modifying this variable directly has no effect on the actual metadata the suite has.

Makes a variable available everywhere within the scope of the current suite.

Arguments

ArgumentTypeDefault value
namenull
valuesnull

Variables set with this keyword are available everywhere within the scope of the currently executed test suite. Setting variables with this keyword thus has the same effect as creating them using the Variables section in the data file or importing them from variable files.

Possible child test suites do not see variables set with this keyword by default, but that can be controlled by using children=<option> as the last argument. If the specified <option> is given a true value (see Boolean arguments), the variable is set also to the child suites. Parent and sibling suites will never see variables set with this keyword.

The name of the variable can be given either as a normal variable name like ${NAME} or in escaped format as \${NAME} or $NAME. For the reasons explained in the Using variables with keywords creating or accessing variables section, using the escaped format is highly recommended.

Variable value can be specified using the same syntax as when variables are created in the Variables section. Same way as in that section, it is possible to create scalar values, lists and dictionaries. The type is got from the variable name prefix $, @ and &, respectively.

If a variable already exists within the new scope, its value will be overwritten. If a variable already exists within the current scope, the value can be left empty and the variable within the new scope gets the value within the current scope.

Examples:

Set Suite Variable $SCALAR Hello, world! Set Suite Variable $SCALAR Hello, world! children=True Set Suite Variable @LIST First item Second item Set Suite Variable &DICT key=value foo=bar ${ID} = Get ID Set Suite Variable $ID

To override an existing value with an empty value, use built-in variables ${EMPTY}, @{EMPTY} or &{EMPTY}:

Set Suite Variable $SCALAR ${EMPTY} Set Suite Variable @LIST @{EMPTY} Set Suite Variable &DICT &{EMPTY}

See also Set Global Variable, Set Test Variable and Set Local Variable.

Adds given tags for the current test or all tests in a suite.

Arguments

ArgumentTypeDefault value
tagsnull

When this keyword is used inside a test case, that test gets the specified tags and other tests are not affected.

If this keyword is used in a suite setup, all test cases in that suite, recursively, gets the given tags. It is a failure to use this keyword in a suite teardown.

The current tags are available as a built-in variable @{TEST TAGS}.

See Remove Tags if you want to remove certain tags and Fail if you want to fail the test case after setting and/or removing tags.

Makes a variable available everywhere within the scope of the current task.

Arguments

ArgumentTypeDefault value
namenull
valuesnull

This is an alias for Set Test Variable that is more applicable when creating tasks, not tests.

Sets documentation for the current test case.

Arguments

ArgumentTypeDefault value
docnull
appendFalse

By default the possible existing documentation is overwritten, but this can be changed using the optional append argument similarly as with Set Test Message keyword.

The current test documentation is available as a built-in variable ${TEST DOCUMENTATION}. This keyword can not be used in suite setup or suite teardown.

Sets message for the current test case.

Arguments

ArgumentTypeDefault value
messagenull
appendFalse

If the optional append argument is given a true value (see Boolean arguments), the given message is added after the possible earlier message by joining the messages with a space.

In test teardown this keyword can alter the possible failure message, but otherwise failures override messages set by this keyword. Notice that in teardown the message is available as a built-in variable ${TEST MESSAGE}.

It is possible to use HTML format in the message by starting the message with *HTML*.

Examples:

Set Test MessageMy message
Set Test Messageis continued.append=yes
Should Be Equal${TEST MESSAGE}My message is continued.
Set Test Message*HTML* <b>Hello!</b>

This keyword can not be used in suite setup or suite teardown.

Makes a variable available everywhere within the scope of the current test.

Arguments

ArgumentTypeDefault value
namenull
valuesnull

Variables set with this keyword are available everywhere within the scope of the currently executed test case. For example, if you set a variable in a user keyword, it is available both in the test case level and also in all other user keywords used in the current test. Other test cases will not see variables set with this keyword. It is an error to call Set Test Variable outside the scope of a test (e.g. in a Suite Setup or Teardown).

See Set Suite Variable for more information and usage examples. See also the Using variables with keywords creating or accessing variables section for information why it is recommended to give the variable name in escaped format like $name or \${name} instead of the normal ${name}.

When creating automated tasks, not tests, it is possible to use Set Task Variable. See also Set Global Variable and Set Local Variable.

Returns the given values which can then be assigned to a variables.

Arguments

ArgumentTypeDefault value
valuesnull

This keyword is mainly used for setting scalar variables. Additionally it can be used for converting a scalar variable containing a list to a list variable or to multiple scalar variables. It is recommended to use Create List when creating new lists.

Examples:

${hi} =Set VariableHello, world!
${hi2} =Set VariableI said: ${hi}
${var1}${var2} =Set VariableHelloworld
@{list} =Set Variable${list with some items}
${item1}${item2} =Set Variable${list with 2 items}

Variables created with this keyword are available only in the scope where they are created. See Set Global Variable, Set Test Variable and Set Suite Variable for information on how to set variables so that they are available also in a larger scope.

Sets variable based on the given condition.

Arguments

ArgumentTypeDefault value
conditionnull
valuesnull

The basic usage is giving a condition and two values. The given condition is first evaluated the same way as with the Should Be True keyword. If the condition is true, then the first value is returned, and otherwise the second value is returned. The second value can also be omitted, in which case it has a default value None. This usage is illustrated in the examples below, where ${rc} is assumed to be zero.

${var1} =Set Variable If${rc} == 0zerononzero
${var2} =Set Variable If${rc} > 0value1value2
${var3} =Set Variable If${rc} > 0whatever

=>

${var1} = 'zero' ${var2} = 'value2' ${var3} = None

It is also possible to have 'else if' support by replacing the second value with another condition, and having two new values after it. If the first condition is not true, the second is evaluated and one of the values after it is returned based on its truth value. This can be continued by adding more conditions without a limit.

${var} =Set Variable If${rc} == 0zero
...${rc} > 0greater than zeroless then zero
${var} =Set Variable If
...${rc} == 0zero
...${rc} == 1one
...${rc} == 2two
...${rc} > 2greater than two
...${rc} < 0less than zero

Use Get Variable Value if you need to set variables dynamically based on whether a variable exist or not.

Verifies that the given item is empty.

Arguments

ArgumentTypeDefault value
itemnull
msgNone

The length of the item is got using the Get Length keyword. The default error message can be overridden with the msg argument.

Fails if the given objects are unequal.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
ignore_caseFalse
formatterstr
strip_spacesFalse
collapse_spacesFalse

Optional msg, values and formatter arguments specify how to construct the error message if this keyword fails:

  • If msg is not given, the error message is <first> != <second>.
  • If msg is given and values gets a true value (default), the error message is <msg>: <first> != <second>.
  • If msg is given and values gets a false value (see Boolean arguments), the error message is simply <msg>.
  • formatter controls how to format the values. Possible values are str (default), repr and ascii, and they work similarly as Python built-in functions with same names. See String representations for more details.

If ignore_case is given a true value (see Boolean arguments) and both arguments are strings, comparison is done case-insensitively. If both arguments are multiline strings, this keyword uses multiline string comparison.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Examples:

Should Be Equal${x}expected
Should Be Equal${x}expectedCustom error message
Should Be Equal${x}expectedCustom messagevalues=False
Should Be Equal${x}expectedignore_case=Trueformatter=repr

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if objects are unequal after converting them to integers.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
baseNone

See Convert To Integer for information how to convert integers from other bases than 10 using base argument or 0b/0o/0x prefixes.

See Should Be Equal for an explanation on how to override the default error message with msg and values.

Examples:

Should Be Equal As Integers42${42}Error message
Should Be Equal As IntegersABCDabcdbase=16
Should Be Equal As Integers0b101111

Fails if objects are unequal after converting them to real numbers.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
precision6

The conversion is done with Convert To Number keyword using the given precision.

Examples:

Should Be Equal As Numbers${x}1.1# Passes if ${x} is 1.1
Should Be Equal As Numbers1.1231.1precision=1# Passes
Should Be Equal As Numbers1.1231.4precision=0# Passes
Should Be Equal As Numbers112.375precision=-2# Passes

As discussed in the documentation of Convert To Number, machines generally cannot store floating point numbers accurately. Because of this limitation, comparing floats for equality is problematic and a correct approach to use depends on the context. This keyword uses a very naive approach of rounding the numbers before comparing them, which is both prone to rounding errors and does not work very well if numbers are really big or small. For more information about comparing floats, and ideas on how to implement your own context specific comparison algorithm, see http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/.

If you want to avoid possible problems with floating point numbers, you can implement custom keywords using Python's decimal or fractions modules.

See Should Not Be Equal As Numbers for a negative version of this keyword and Should Be Equal for an explanation on how to override the default error message with msg and values.

Fails if objects are unequal after converting them to strings.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
formatterstr
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg, values and formatter.

If ignore_case is given a true value (see Boolean arguments), comparison is done case-insensitively. If both arguments are multiline strings, this keyword uses multiline string comparison.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Strings are always NFC normalized.

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if the given condition is not true.

Arguments

ArgumentTypeDefault value
conditionnull
msgNone

If condition is a string (e.g. ${rc} < 10), it is evaluated as a Python expression as explained in Evaluating expressions and the keyword status is decided based on the result. If a non-string item is given, the status is got directly from its truth value.

The default error message (<condition> should be true) is not very informative, but it can be overridden with the msg argument.

Examples:

Should Be True${rc} < 10
Should Be True'${status}' == 'PASS'# Strings must be quoted
Should Be True${number}# Passes if ${number} is not zero
Should Be True${list}# Passes if ${list} is not empty

Variables used like ${variable}, as in the examples above, are replaced in the expression before evaluation. Variables are also available in the evaluation namespace, and can be accessed using special $variable syntax as explained in the Evaluating expressions section.

Examples:

Should Be True$rc < 10
Should Be True$status == 'PASS'# Expected string must be quoted

Fails if container does not contain item one or more times.

Arguments

ArgumentTypeDefault value
containernull
itemnull
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

Works with strings, lists, and anything that supports Python's in operator.

See Should Be Equal for an explanation on how to override the default error message with arguments msg and values.

If ignore_case is given a true value (see Boolean arguments) and compared items are strings, it indicates that comparison should be case-insensitive. If the container is a list-like object, string items in it are compared case-insensitively.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Examples:

Should Contain${output}PASS
Should Contain${some list}valuemsg=Failure!values=False
Should Contain${some list}valueignore_case=True

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if container does not contain any of the *items.

Arguments

ArgumentTypeDefault value
containernull
itemsnull
configurationnull

Works with strings, lists, and anything that supports Python's in operator.

Supports additional configuration parameters msg, values, ignore_case and strip_spaces, and collapse_spaces which have exactly the same semantics as arguments with same names have with Should Contain. These arguments must always be given using name=value syntax after all items.

Note that possible equal signs in items must be escaped with a backslash (e.g. foo\=bar) to avoid them to be passed in as **configuration.

Examples:

Should Contain Any${string}substring 1substring 2
Should Contain Any${list}item 1item 2item 3
Should Contain Any${list}item 1item 2item 3ignore_case=True
Should Contain Any${list}@{items}msg=Custom messagevalues=False

Fails if container does not contain item count times.

Arguments

ArgumentTypeDefault value
containernull
itemnull
countnull
msgNone
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

Works with strings, lists and all objects that Get Count works with. The default error message can be overridden with msg and the actual count is always logged.

If ignore_case is given a true value (see Boolean arguments) and compared items are strings, it indicates that comparison should be case-insensitive. If the container is a list-like object, string items in it are compared case-insensitively.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Examples:

Should Contain X Times${output}hello2
Should Contain X Times${some list}value3ignore_case=True

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if the string str1 does not end with the string str2.

Arguments

ArgumentTypeDefault value
str1null
str2null
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values, as well as for semantics of the ignore_case, strip_spaces, and collapse_spaces options.

Fails if the given string does not match the given pattern.

Arguments

ArgumentTypeDefault value
stringnull
patternnull
msgNone
valuesTrue
ignore_caseFalse

Pattern matching is similar as matching files in a shell with *, ? and [chars] acting as wildcards. See the Glob patterns section for more information.

If ignore_case is given a true value (see Boolean arguments) and compared items are strings, it indicates that comparison should be case-insensitive.

See Should Be Equal for an explanation on how to override the default error message with msg and values.

Fails if string does not match pattern as a regular expression.

Arguments

ArgumentTypeDefault value
stringnull
patternnull
msgNone
valuesTrue

See the Regular expressions section for more information about regular expressions and how to use then in Robot Framework test data.

Notice that the given pattern does not need to match the whole string. For example, the pattern ello matches the string Hello world!. If a full match is needed, the ^ and $ characters can be used to denote the beginning and end of the string, respectively. For example, ^ello$ only matches the exact string ello.

Possible flags altering how the expression is parsed (e.g. re.IGNORECASE, re.MULTILINE) must be embedded to the pattern like (?im)pattern. The most useful flags are i (case-insensitive), m (multiline mode), s (dotall mode) and x (verbose).

If this keyword passes, it returns the portion of the string that matched the pattern. Additionally, the possible captured groups are returned.

See the Should Be Equal keyword for an explanation on how to override the default error message with the msg and values arguments.

Examples:

Should Match Regexp${output}\\d{6}# Output contains six numbers
Should Match Regexp${output}^\\d{6}$# Six numbers and nothing more
${ret} =Should Match RegexpFoo: 42(?i)foo: \\d+
${match}${group1}${group2} =
...Should Match RegexpBar: 43(Foo|Bar): (\\d+)

=>

${ret} = 'Foo: 42' ${match} = 'Bar: 43' ${group1} = 'Bar' ${group2} = '43'

Verifies that the given item is not empty.

Arguments

ArgumentTypeDefault value
itemnull
msgNone

The length of the item is got using the Get Length keyword. The default error message can be overridden with the msg argument.

Fails if the given objects are equal.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values.

If ignore_case is given a true value (see Boolean arguments) and both arguments are strings, comparison is done case-insensitively.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if objects are equal after converting them to integers.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
baseNone

See Convert To Integer for information how to convert integers from other bases than 10 using base argument or 0b/0o/0x prefixes.

See Should Be Equal for an explanation on how to override the default error message with msg and values.

See Should Be Equal As Integers for some usage examples.

Fails if objects are equal after converting them to real numbers.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
precision6

The conversion is done with Convert To Number keyword using the given precision.

See Should Be Equal As Numbers for examples on how to use precision and why it does not always work as expected. See also Should Be Equal for an explanation on how to override the default error message with msg and values.

Fails if objects are equal after converting them to strings.

Arguments

ArgumentTypeDefault value
firstnull
secondnull
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values.

If ignore_case is given a true value (see Boolean arguments), comparison is done case-insensitively.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Strings are always NFC normalized.

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if the given condition is true.

Arguments

ArgumentTypeDefault value
conditionnull
msgNone

See Should Be True for details about how condition is evaluated and how msg can be used to override the default error message.

Fails if container contains item one or more times.

Arguments

ArgumentTypeDefault value
containernull
itemnull
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

Works with strings, lists, and anything that supports Python's in operator.

See Should Be Equal for an explanation on how to override the default error message with arguments msg and values. ignore_case has exactly the same semantics as with Should Contain.

If strip_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done without leading and trailing spaces. If strip_spaces is given a string value LEADING or TRAILING (case-insensitive), the comparison is done without leading or trailing spaces, respectively.

If collapse_spaces is given a true value (see Boolean arguments) and both arguments are strings, the comparison is done with all white spaces replaced by a single space character.

Examples:

Should Not Contain${some list}value
Should Not Contain${output}FAILEDignore_case=True

strip_spaces is new in Robot Framework 4.0 and collapse_spaces is new in Robot Framework 4.1.

Fails if container contains one or more of the *items.

Arguments

ArgumentTypeDefault value
containernull
itemsnull
configurationnull

Works with strings, lists, and anything that supports Python's in operator.

Supports additional configuration parameters msg, values, ignore_case and strip_spaces, and collapse_spaces which have exactly the same semantics as arguments with same names have with Should Contain. These arguments must always be given using name=value syntax after all items.

Note that possible equal signs in items must be escaped with a backslash (e.g. foo\=bar) to avoid them to be passed in as **configuration.

Examples:

Should Not Contain Any${string}substring 1substring 2
Should Not Contain Any${list}item 1item 2item 3
Should Not Contain Any${list}item 1item 2item 3ignore_case=True
Should Not Contain Any${list}@{items}msg=Custom messagevalues=False

Fails if the string str1 ends with the string str2.

Arguments

ArgumentTypeDefault value
str1null
str2null
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values, as well as for semantics of the ignore_case, strip_spaces, and collapse_spaces options.

Fails if the given string matches the given pattern.

Arguments

ArgumentTypeDefault value
stringnull
patternnull
msgNone
valuesTrue
ignore_caseFalse

Pattern matching is similar as matching files in a shell with *, ? and [chars] acting as wildcards. See the Glob patterns section for more information.

If ignore_case is given a true value (see Boolean arguments), the comparison is case-insensitive.

See Should Be Equal for an explanation on how to override the default error message with msg and `values.

Fails if string matches pattern as a regular expression.

Arguments

ArgumentTypeDefault value
stringnull
patternnull
msgNone
valuesTrue

See Should Match Regexp for more information about arguments.

Fails if the string str1 starts with the string str2.

Arguments

ArgumentTypeDefault value
str1null
str2null
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values, as well as for semantics of the ignore_case, strip_spaces, and collapse_spaces options.

Fails if the string str1 does not start with the string str2.

Arguments

ArgumentTypeDefault value
str1null
str2null
msgNone
valuesTrue
ignore_caseFalse
strip_spacesFalse
collapse_spacesFalse

See Should Be Equal for an explanation on how to override the default error message with msg and values, as well as for semantics of the ignore_case, strip_spaces, and collapse_spaces options.

Skips the rest of the current test if the condition is True.

Arguments

ArgumentTypeDefault value
conditionnull
msgNone

Skips the remaining keywords in the current test and sets the given message to the test. If msg is not given, the condition will be used as the message. If the test has teardown, it will be executed.

If the condition evaluates to False, does nothing.

Pauses the test executed for the given time.

Arguments

ArgumentTypeDefault value
time_null
reasonNone

time may be either a number or a time string. Time strings are in a format such as 1 day 2 hours 3 minutes 4 seconds 5milliseconds or 1d 2h 3m 4s 5ms, and they are fully explained in an appendix of Robot Framework User Guide. Optional reason can be used to explain why sleeping is necessary. Both the time slept and the reason are logged.

Examples:

Sleep42
Sleep1.5
Sleep2 minutes 10 seconds
Sleep10sWait for a reply

Fails unless the given variable exists within the current scope.

Arguments

ArgumentTypeDefault value
namenull
msgNone

The name of the variable can be given either as a normal variable name like ${name} or in escaped format like $name or \${name}. For the reasons explained in the Using variables with keywords creating or accessing variables section, using the escaped format is recommended.

The default error message can be overridden with the msg argument.

See also Variable Should Not Exist and Keyword Should Exist.

Fails if the given variable exists within the current scope.

Arguments

ArgumentTypeDefault value
namenull
msgNone

The name of the variable can be given either as a normal variable name like ${name} or in escaped format like $name or \${name}. For the reasons explained in the Using variables with keywords creating or accessing variables section, using the escaped format is recommended.

The default error message can be overridden with the msg argument.

See also Variable Should Exist and Keyword Should Exist.

Runs the specified keyword and retries if it fails.

Arguments

ArgumentTypeDefault value
retrynull
retry_intervalnull
namenull
argsnull

name and args define the keyword that is executed similarly as with Run Keyword. How long to retry running the keyword is defined using retry argument either as timeout or count. retry_interval is the time to wait between execution attempts.

If retry is given as timeout, it must be in Robot Framework's time format (e.g. 1 minute, 2 min 3 s, 4.5) that is explained in an appendix of Robot Framework User Guide. If it is given as count, it must have times or x postfix (e.g. 5 times, 10 x). retry_interval must always be given in Robot Framework's time format.

By default retry_interval is the time to wait after a keyword has failed. For example, if the first run takes 2 seconds and the retry interval is 3 seconds, the second run starts 5 seconds after the first run started. If retry_interval start with prefix strict:, the execution time of the previous keyword is subtracted from the retry time. With the earlier example the second run would thus start 3 seconds after the first run started. A warning is logged if keyword execution time is longer than a strict interval.

If the keyword does not succeed regardless of retries, this keyword fails. If the executed keyword passes, its return value is returned.

Examples:

Wait Until Keyword Succeeds2 min5 secMy keywordargument
${result} =Wait Until Keyword Succeeds3x200msMy keyword
${result} =Wait Until Keyword Succeeds3xstrict: 200msMy keyword

All normal failures are caught by this keyword. Errors caused by invalid syntax, test or keyword timeouts, or fatal exceptions (caused e.g. by Fatal Error) are not caught.

Running the same keyword multiple times inside this keyword can create lots of output and considerably increase the size of the generated output files. It is possible to remove unnecessary keywords from the outputs using --RemoveKeywords WUKS command line option.

Support for "strict" retry interval is new in Robot Framework 4.1.