简体   繁体   中英

How to access variables from .yaml file to robot framework script?

I have Myvariable.yaml file and sample.robot file, I wanted to use the variables from .yaml file to robot file

  • Myvariable.yaml file:

     ACFC NEWS: Doc_Title: XPath=//div[@class='ng-scope'] Open_Selector: xpath=//button[@class='btn btn-default ng-binding]
  • Sample.robot file

     ***Settings**** Variables Myvariable.yaml ***Keywords**** Choose Topic: Input Text ${Doc_Title} "Some text" Click Button ${Open_Selector}

Error: Variable not found

It would be great if any one can help me in solving this issue.

you need to access the attributes of yaml file like ${DICT.one} more information here

https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/ResourceAndVariableFiles.rst#variable-file-as-yaml

your modified code

*** Settings ***
Variables    Myvariable.yaml

*** Test Case ***
Test
    Choose Topic
***Keywords****
Choose Topic
       Log   ${ACFC NEWS.Doc_Title}
       Log   ${ACFC NEWS.Open_Selector}

I am assuming you are running the script with below command

pybot -V myvariable.yaml sample.robot

This should solve your problem now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM