我是Robot框架的新手。我想运行多行IF语句,但出现以下错误:
错误:
“ 0 =评估,$ {G_NO_OF_RECIPIENTS} + $ {NUMBER_OF_CALLEE}失败 找到名称为“ 0 =”的关键字。 “
此错误发生在变量${REM_COUNT}
代码:
Log ${G_NO_OF_RECIPIENTS}
Log ${NUMBER_OF_CALLEE}
${REM_COUNT} Set Variable ${0}
Run Keyword If "${NUMBER_OF_CALLEE}" != "${G_NO_OF_RECIPIENTS}" Run Keywords
... ${REM_COUNT}= Evaluate ${G_NO_OF_RECIPIENTS}+${NUMBER_OF_CALLEE}
... AND Log "ITS WORKING"
相似的代码可以在其他地方使用,唯一的是我没有在其中使用多行if语句。如果能在此方面获得帮助,我将不胜感激。 谢谢
答案 0 :(得分:2)
Run Keywords
不允许在其块内进行变量分配,例如这行:
Run Keywords
... ${REM_COUNT}= Evaluate ${G_NO_OF_RECIPIENTS}+${NUMBER_OF_CALLEE}
... AND Log "ITS WORKING"
是非法语法。它试图用其值(0)代替${REM_COUNT}
并运行它-从而失败。
Run Keyword If
确实传递了任何返回值,因此您可以这样操作:
${REM_COUNT}= Run Keyword If "${NUMBER_OF_CALLEE}" != "${G_NO_OF_RECIPIENTS}"
... Evaluate ${G_NO_OF_RECIPIENTS}+${NUMBER_OF_CALLEE}
... ELSE Set Variable ${REM_COUNT} # if the condition is False, leave the variable to its previous value
Run Keyword If "${NUMBER_OF_CALLEE}" != "${G_NO_OF_RECIPIENTS}" Log "ITS WORKING"