python-2.7 - 机器人框架中的 If Else-if

标签 python-2.7 testing if-statement automated-tests robotframework

我想通过使用 else if 从关键字获取值。

例子:

String text = ""  
If variable > 5
   text = "one";
else if variable <5
   text = "two";
else
   text = "three";

在机器人框架中

我用代码

${txt}    Set Variable
${txt}=    Run Keyword If    ${length} > 5    Some Keyword
\    ELSE IF    ${length} < 5    Some Keyword
\    ELSE    Some Keyword
Log       ${txt}

错误!!!

In Keyword ELSE IF  ;  Keyword name cannot be empty

最佳答案

只需在 ELSE IF 关键字前的第一个单元格中添加三个点 (...)

${txt}    Set Variable
${txt}=    Run Keyword If    ${lenght} > 5    Some Keyword
...    ELSE IF    ${lenght} < 5    Some Keyword
...    ELSE    Some Keyword
Log       ${txt}

关于python-2.7 - 机器人框架中的 If Else-if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28229676/

相关文章:

javascript - 帮助您显示答案的按钮

web-services - Weblogic Web 服务 + SSL

PHP 意外的 elseif

if-statement - 使用 if Controller 在 jmeter 中检查条件

python - 在将数据发送到数据库之前检查互联网可用性

ruby - 为程序编写测试文件

ruby - 在源文件中记录 Ruby 代码结果

比较两个字典列表中值的 Pythonic 方法

sql - 在bigquery中将DATETIME格式转换为自定义格式

python - 项目的结构化日志记录