【问题标题】:Robot Framework: How can I pass a list to a keyword in an if statement?Robot Framework:如何将列表传递给 if 语句中的关键字?
【发布时间】:2017-11-03 19:27:55
【问题描述】:

我需要有关 Robot Framework 语法的帮助。 首次使用 Log My List 关键字很好,完美记录列表。第二种用法,在 if 语句中不断告诉我:

变量“@{MyList}”的值不是列表或类似列表

有谁知道问题出在哪里?

*** Settings ***
Documentation    Problematic Suite

*** Variables ***
${condition}    0

*** Keywords ***
Log My List ${MyList}
    Log Many   @{MyList}

*** Test Cases ***
LD_0: Pass List in If Statement.
    [Documentation]    Problem example.
    [Tags]    Problem
    @{LIST}=    Create List    item1    item2    item3
    Log My List ${LIST}
    Run Keyword If  ${condition} == 0    Log My List ${LIST}

【问题讨论】:

    标签: syntax robotframework


    【解决方案1】:

    这似乎是机器人中的一个错误。如果您从使用嵌入式参数切换到传统参数,它将起作用。

    *** Settings ***
    Documentation    Problematic Suite
    
    *** Variables ***
    ${condition}    0
    
    *** Keywords ***
    Log My List
        [Arguments]  ${MyList}
        Log Many   @{MyList}
    
    *** Test Cases ***
    LD_0: Pass List in If Statement.
        [Documentation]    Problem example.
        [Tags]    Problem
        @{LIST}=    Create List    item1    item2    item3
        Log My List  ${LIST}
        Run Keyword If  ${condition} == 0    Log My List  ${LIST}
    

    【讨论】:

      猜你喜欢
      • 2018-01-17
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      • 2014-07-14
      • 2014-01-06
      相关资源
      最近更新 更多