Keyword as a Robot Framework decorator

Introduction

In the robot, you can use Run Keyword to pass one keyword to the arguments of another.

In essence, one keyword will work as a decorator for the second.

Example

Let's write a keyword Find Negative Values In, which will return only negative numbers from the results of another keyword.

*** Settings *** Documentation Keyword as decorator *** Variables *** @{array} ${-4} ${-3} ${-2} ${-1} ${0} ${1} ${2} *** Test Cases *** Negative Even Numbers ${negative_even} Find Negative Values In Fetch Even Numbers From List ${array} Log To Console ${negative_even} *** Keywords *** Find Negative Values In [Arguments] ${keyword} @{args} &{kwargs} ${list} Run Keyword ${keyword} @{args} &{kwargs} ${negative_numbers} Evaluate [i for i in $list if i < 0] RETURN ${negative_numbers} Fetch Even Numbers From List [Arguments] ${list} ${even_numbers} Evaluate [i for i in ${list} if i % 2 == 0] RETURN ${even_numbers}

============================================================================== Demo :: Keyword as decorator ============================================================================== Negative Even Numbers .[-4, -2] Negative Even Numbers | PASS | ------------------------------------------------------------------------------ Demo :: Keyword as decorator | PASS | 1 test, 1 passed, 0 failed ==============================================================================

Article author: Andrei Olegovich

Похожие статьи
Robot Framework
Architecture
Logs
__init__.robot
Create custom .py libs
Path to libs and resources
Keyword as decorator
Template
Parametrize
Demo with pywinauto
Изображение баннера

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

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

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

@aofeed

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

@aofeedchat

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