'Else If'是保留关键字。当用作机器人框架中的“运行关键字如果”的标记时,它必须是大写(ELSE IF)

时间:2016-06-22 02:04:52

标签: robotframework

我收到以下错误 'Else If'是保留关键字。当用作'Run Keyword If'

的标记时,它必须是大写(ELSE IF)

Code snipet如下......任何人都可以帮我解决问题吗?感谢

Run Keyword If    '${intf_type}' == 'l3'    Run Keywords
            Execute         Load Configuration      @{target}[0]      commit_comment=configure isis   data=set interfaces xe-0/0/2:0 unit 0 family inet address 10.0.0.1/24 ${\n} set interfaces xe-0/0/2:0 unit 0 family iso ${\n} set protocols isis interface xe-0/0/2:0.0 ${\n} set protocols isis interface lo0.0                format=set
            Sleep   30s
            ELSE IF    '${intf_type}' == 'irb'    Run Keywords
            Execute         Load Configuration       @{target}[0]    commit_comment=configure isis    data=set interfaces xe-0/0/2:0 unit 0 family ethernet-switching interface-mode trunk ${\n} set interfaces xe-0/0/2:0 unit 0 family ethernet-switching vlan members v-10 ${\n} set interfaces irb unit 10 family inet address 10.0.0.1/24 ${\n} set interfaces irb unit 10 family iso ${\n} set protocols isis interface irb.10 ${\n} set protocols isis interface lo0.0 ${\n} set vlans v-10 vlan-id 10 ${\n} set vlans v-10 l3-interface irb.10       format=set

1 个答案:

答案 0 :(得分:3)

很难阅读您的代码段,因为它没有显示格式。 ELSE IF需要正确的格式。将ELSE IF放在同一个块中非常重要,并且行开头的“...”非常重要。以下是两个例子,他们对你有所帮助:

Set Variable
    ${x}=      Set Variable    1
    ${var1}=    Run Keyword If    ${x} == 2    Set Variable    2
    ...         ELSE IF     ${x} == 1    Set Variable    1
    Log    ${var1}

Run Keyword
    ${x}=    Set Variable    1
    Run Keyword If    ${x} == 2    Log    2
    ...    ELSE IF     ${x} == 1    Log    1