首页 > 解决方案 > 使用“登录到控制台”通过控制台显示标签

问题描述

我正在尝试获取定义的test.robot文件内容[Tags]并将其显示在控制台上。这是我所拥有的:

[Tags]  cat  dog

现在,我想知道如何Log To Console输出标签?

到目前为止,我已经尝试了以下方法:

    ${TagVariable}=    Tags
    ${TagVariable1}=    Tags[0]
    ${TagVariable2}=    Tags[1]
    ${TagVariable3}=    [Tags]
    ${TagVariable4}=    [Tags][0]
    ${TagVariable5}=    [Tags][1]
    Log To Console  Tags
    Log To Console  [Tags]
    Log To Console  [Tags][0]
    Log To Console  [Tags][1]
    Log To Console  ${TagVariable}
    Log To Console  ${TagVariable1}
    Log To Console  ${TagVariable2}
    Log To Console  ${TagVariable3}
    Log To Console  ${TagVariable4}
    Log To Console  ${TagVariable5}

我似乎无法理解它。

标签: robotframework

解决方案


Robot 提供了几个自动变量。你可以在这里找到所有这些

你需要的就是这个

  • @{TEST TAGS}:按字母顺序包含当前测试用例的标签。可以使用 Set Tags 和 Remove Tags 关键字动态修改。

根据您的上下文,您可能需要\n@{TEST TAGS}在文件中将其打印为 , 。.robot


推荐阅读