Warm tip: This article is reproduced from serverfault.com, please click

How to reference yaml variable file present in github in robot framework test case file in github

发布于 2020-11-27 12:50:01

I ran Robot framework test cases(present in github) through azure pipeline. Test cases executed fine. Next I modified robot framework test case file to import yaml variable file (variable yaml file also present in same github repo folder) which has variables to be used by test cases file. yaml variable file looks like this

login:
 url: xxx.com
 email: abc@y.com 
 password: xyz

And my test cases file look like this

*** Settings ***
    Library           SeleniumLibrary
    Variables         variablesfile.yaml
  
  *** Test Cases ***
  Dev_TC01_AddProcess
  Open Browser    ${login.url}    chrome
  Input Text    id=email    ${login.email}
  Input Password    id=password    ${login.password}

And my yaml pipeline to trigger test scenarios looks like this

- script: |
    pip install pytest pytest-azurepipelines
    pytest
    robot --pythonpath . -x outputxunit.xml TestScenarios.robot
  displayName: 'Run Robot Scripts'

but on running the pipeline I get error, because test scenarios file is unable to reference variablesfile.yaml. got error message - Resolving variable '${login.url}' failed:

Can you please suggest how to reference variable file

Questioner
Komz
Viewed
0
Levi Lu-MSFT 2020-11-30 16:01:10

Above error seems to be caused by the variables yaml file not being found.

If you defined Variables file in the Settings section like what you defined in above example. You should put the variables yaml files in the same directory of the test robot file TestScenarios.robot.

If the variables files are not under the same directory. You can define the correct relative path in the Settings section like below example: See here.

Variables ../data/variables.yaml

Note:

Using YAML files with Robot Framework requires PyYAML module to be installed. If you have pip_ installed, you can install it simply by running pip install pyyaml.