【问题标题】:Robot framework Using yaml list in for loop机器人框架在 for 循环中使用 yaml 列表
【发布时间】:2020-06-23 23:27:24
【问题描述】:

我遇到了 for 循环的问题。

收到错误“FOR 循环不包含关键字”。

我有一个要导入的 yaml 文件。

test_sequence_1:
  - test_name: "Test"
    test_items:
      - test_name1
      - test_name2

然后我将其导入并尝试对其进行迭代。

*** Settings ***
Library  BuiltIn
Library  Collections

Variables  ../vars/vrf_test_cases.yaml
*** Test Cases ***
Run Sequential Tests
    Launch test cases sequence  @{test_sequence_1}

然后运行关键字,我尝试了不同的 for 循环和各种其他选项。我一辈子都无法让第二个 For 循环工作

Launch test cases sequence
    #TODO add a default empty value for extra_vars_dict
    [Documentation]         Launch a given set of workflow templates from a yaml dictionary
    [Arguments]             @{test_sequence_dict}
    FOR  ${sequence}  IN  @{test_sequence_dict}
        Log to Console  \n\n\n Launching: ${sequence['test_name']}
        @{test_list}=    Convert To List    ${sequence['test_items']}
        Log to Console  \n Run Tests var: @{test_list}[0]
        #FOR  ${test}  IN  @{sequence['test_items']}
            #Log to Console  ${test}
            #Run Keyword  ${test}
        #END
        FOR  ${test}  IN  @{test_list}
            Log to Console  ${test}
        END        
    END

我觉得我错过了什么,想知道缺少的部分是什么。

【问题讨论】:

    标签: yaml robotframework


    【解决方案1】:

    robot 框架不支持嵌套 for 循环。

    来自用户指南,在标题为 Nested for loops 的部分中

    不直接支持嵌套 for 循环,但可以在 for 循环中使用用户关键字,并在其中有另一个 for 循环。

    【讨论】:

    • 谢谢,我不知道,甚至没想到问题是嵌套循环。
    猜你喜欢
    • 2016-03-15
    • 2020-12-29
    • 2020-02-19
    • 2016-11-18
    • 2017-04-20
    • 2017-07-02
    • 2021-07-17
    • 2018-08-09
    • 2020-11-15
    相关资源
    最近更新 更多