Declaring a variable in Robot Framework

Содержание
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}

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

Похожие статьи
Robot Framework
Declare a variable
Change a variable value
Get Variable Value
Passing arguments to a keyword
Evaluate
PyCharm

Поиск по сайту

Подпишитесь на Telegram канал @aofeed чтобы следить за выходом новых статей и обновлением старых

Перейти на канал

@aofeed

Задать вопрос в Телеграм-группе

@aofeedchat

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящую по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: