Declare a variable in Robot Framework
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
Do not forget 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}
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}
& Dictionary
If you need to store a dictionary in a variable, you have 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