Подключить переменные из .py файла в Robot Framework

Введение

В этой статье вы можете увидеть пример импорта переменных из внешнего Python файла.

В сам тест будет подключен .resource файл, а уже в нём в качестве Variables будет подключен .py файл

Пример

В этом примере вы можете увидеть как из одного .resource файла можно получить переменные как из блока Variables так и из блока Settings

demo |-- Libraries |-- Resources | |-- demo.resource | `-- my_vars.py `-- Tests `-- demo.robot

demo.robot

*** Settings *** Resource ../Resources/demo.resource *** Test Cases *** Using Var From Python File Log To Console \n OUTPUT: Log To Console ${URL} Log To Console ${HOSTING}

demo.resource

*** Settings *** Variables my_vars.py *** Variables *** ${HOSTING}= https://beget.com

my_vars.py

URL = "https://aredel.com/ru"

robot demo.robot

============================================================================== Demo ============================================================================== Using Var From Python File OUTPUT: .https://aredel.com/ru .https://beget.com Using Var From Python File | PASS | ------------------------------------------------------------------------------ Demo | PASS | 1 test, 1 passed, 0 failed ============================================================================== Output: C:\Users\Andrei\robot\demo\Tests\output.xml Log: C:\Users\Andrei\robot\demo\Tests\log.html Report: C:\Users\Andrei\robot\demo\Tests\report.html

Автор статьи: Андрей Олегович