【问题标题】:Multiple Conditions IF/ELSE statement Robot Framework 4多重条件 IF/ELSE 语句 Robot Framework 4
【发布时间】:2021-12-17 21:18:26
【问题描述】:

在 RobotFramework 4 中,我们现在可以编写更传统的 if/else 语句。

比如:

*** Keywords ***
Do conditional execution
IF ${CONDITION}
Log True!
ELSE IF "cat" == "dog"
Log Dog!
ELSE
Log Not True!
END

有谁知道如何在多个条件下编写它?我目前正在做某事。如果我像这样写多个语句,它可以工作

        IF  "${error1}" == "False"
            Do Something

        ELSE IF  "${error2}" == "False"
            Do Something

        ELSE IF  "${error3}" == "False"
            Do Something

但如果我尝试这样写

IF  "${error1}" == "False"  or  "${error2}" == "False"  or    "${error3}" == "False"
   Write To Google Document

然后它告诉我

IF has more than one condition.

如果我写错了有什么想法吗?还是有更好的办法?

【问题讨论】:

    标签: python selenium testing robotframework qa


    【解决方案1】:

    在您的代码中,“或”之前有两个空格。表达式中不能有两个或更多空格。你的表达式中有“或或”。

    这应该可行:

    IF  "${error1}" == "False" or "${error2}" == "False" or "${error3}" == "False"
       Write To Google Document
    

    【讨论】:

    • 嘿,这是正确的。我有 2 个空间,因为 RF 似乎总是需要 2 个空间,但在这种情况下不是。这里的两个或只是一个错字。但很好发现都是一样的。谢谢@Bryan Oakley
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    • 2020-12-29
    相关资源
    最近更新 更多