机器人测试框架:运行关键字如果incurs User关键字不包含关键字

时间:2017-02-22 21:00:55

标签: robotframework

以下代码位于For循环中。

ELSE Enable Laser ${app_id} ${status}会导致用户关键字'启用激光'不包含关键字错误。但是,如果我将其更改为ELSE IF '${electricalApp}'=='True' Enable Laser ${app_id} ${status},则此行上没有错误,但下面的行Run Keyword If '${electricalApp}'=='True' Enable Laser ${app_id} ${status}会产生用户关键字'启用激光'不包含关键字错误。

\   ${electricalApp}    Is App Electrical    ${app}
\   ${status}    Set Variable    ON
\   ${validOptic}    Set Variable    False
\   ${validOptic}    Run Keyword If    '${electricalApp}'=='False'    Is Optic Valid For App    ${app_id}    ${app}
\   ...              ELSE    Enable Laser    ${app_id}    ${status}
\   Run Keyword If    '${validOptic}'=='True'    Enable Laser    ${app_id}    ${status}
\   ${status}    Set Variable    OFF
\   Run Keyword If    '${electricalApp}'=='True'    Enable Laser    ${app_id}    ${status}
\   Run Keyword If    '${validOptic}'=='True'    Enable Laser    ${app_id}    ${status}
\   Exit Current Running Apps

在我将上面的代码放到For循环之前,一切都运行良好。

编辑:启用激光:

Enable Laser    [Arguments]     ${app_id}   ${status}
[Documentation]     Turn on or off laser and then check Signal Sync Link. ${status} should be all upper case
    ${commmand}    Catenate    SEPARATOR=    ${app_id}    .0.SignalTx.LaserEnable
    send cmd    ${app_id}    a_goto_state    ${commmand}    ${status}
    ${inquiry}    Catenate    SEPARATOR=    ${app_id}    .0.SignalTx.LaserState
    ${payload}    send cmd    ${app_id}    r_get    ${inquiry}
    ${parameters}    Evaluate    $payload.parameters
    Run Keyword If    '${status}'=='ON'    Should Be Equal    '1'    ${parameters}    Current state should be 1
    Run Keyword If    '${status}'=='OFF'    Should Be Equal    '0'    ${parameters}    Current state should be 0
    Signal Sync Link Verification    ${app_id}    ${status}

1 个答案:

答案 0 :(得分:1)

事实证明,在Enable Laser的定义中,[Documentation]需要缩进。

像这样:

Enable Laser    [Arguments]     ${app_id}   ${status}
    [Documentation]     Turn on or off laser and then check Signal Sync Link. ${status} should be all upper case
    ${commmand}    Catenate    SEPARATOR=    ${app_id}    .0.SignalTx.LaserEnable
    send cmd    ${app_id}    a_goto_state    ${commmand}    ${status}