If statement ';其他';是Robot Framework脚本中的保留关键字错误

If statement ';其他';是Robot Framework脚本中的保留关键字错误,if-statement,syntax-error,keyword,robotframework,reserved,If Statement,Syntax Error,Keyword,Robotframework,Reserved,我犯了一个错误 “Else”是保留关键字 代码如下,有人能告诉我解决方法吗 :FOR ${key} IN @{keys} \ ${item}= Get From Dictionary ${services} ${key} \ Run Keyword If '${item}' == '1' Log Service: ${key} is Running \ Else If '${item}' == '2' Log

我犯了一个错误

“Else”是保留关键字

代码如下,有人能告诉我解决方法吗

   :FOR ${key} IN @{keys}
   \           ${item}= Get From Dictionary ${services} ${key}
   \           Run Keyword If '${item}' == '1' Log Service: ${key} is Running
   \          Else If '${item}' == '2' Log
   \          ... Service: ${key} is not running

您忘记使用连续字符了。所有“else”和“elseif”单词以及其他关键字和参数都必须是“run关键字if”关键字的参数

:FOR ${key} IN @{keys}
\    ${item}= Get From Dictionary ${services} ${key}
\    Run Keyword If    '${item}' == '1' 
\    ...    Log    Service: ${key} is Running
\    ...    Else If    '${item}' == '2' Log
\    ...    Log    Service: ${key} is not running