Declaring a variable in Robot Framework

Contents
Introduction
In block *** Variables ***
Inside test case
Set Suite Variable
& Dictionary
Related articles

Introduction

The first way is to create global variables at the beginning of the .robot file

The second is to use Set Variable

In the *** Variables *** block

Remember that there must be more than one space between the = sign and the value being assigned.

*** Settings *** # make at least two spaces beetween Documentation Simple example using SeleniumLibrary. Library SeleniumLibrary *** Variables *** ${WEBSITE_URL} = www.aredel.com *** Test Cases *** Test case number one [documentation] Web url test [tags] web Log To Console ${WEBSITE_URL}

Banner image

Inside the test case

*** Settings *** # make at least two spaces beetween Documentation Simple example using SeleniumLibrary. Library SeleniumLibrary *** Variables *** *** Test Cases *** Test case number one [documentation] Web url test [tags] web ${WEBSITE_URL} = Set Variable www.heihei.ru Log To Console ${WEBSITE_URL}

Official documentation

Set Suite Variable

To make a variable available to all tests in a suite, Set Suite Variable is used.

In the following example, the variable is set in the Setting Suite Var test case and is used in Using Suite Var

*** Test Cases *** Setting Suite Var Set Suite Variable ${ID} ${10} Using Suite Var Log To Console ${ID}

============================================================================== Setting Suite Var | PASS | ------------------------------------------------------------------------------ Using Suite Var 10 Using Suite Var | PASS |

& Dictionary

If you need to save a dictionary in a variable, you need to use &

*** Settings *** # make at least two spaces beetween Documentation Simple example using SeleniumLibrary. Library SeleniumLibrary *** Variables *** *** Test Cases *** Test case number one [documentation] Web url test [tags] web &{VARIABLE} = Some Keyword Log To Console ${VARIABLE}

Article author: Andrei Olegovich

Related articles
Robot Framework
Declare a variable
Change a variable value
Get Variable Value
Passing arguments to a keyword
Evaluate
PyCharm

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: