【问题标题】:Robot Framework: Continue FOR loop if any keyword fails inside the loop机器人框架:如果任何关键字在循环内失败,则继续 FOR 循环
【发布时间】:2020-09-01 04:19:14
【问题描述】:

在机器人框架中,即使循环内的任何关键字失败,我也想继续循环。比如我有如下代码:

FOR    ${member}    IN    @{all data members}
      Keyword 1   ${member}
      Keyword 2   ${member}
      ..............
      Keyword n   ${member}
END

如果任何关键字(例如关键字 2)失败,FOR 循环应该继续执行。

【问题讨论】:

    标签: selenium selenium-webdriver automated-tests robotframework ui-automation


    【解决方案1】:

    您可以在每个关键字之前使用关键字Run Keyword And Continue On Failure 或使用关键字Run Keyword And Return Status 并手动处理错误。

    【讨论】:

    • 似乎我们没有 try...catch 这样的东西可以在机器人框架的 for 循环中使用。我们能否将关键字“Run Keyword And Continue On Failure”自定义为“Run Keyword And Continue On Failure with Failure Status”,这样它也可以返回status(true, false)并显示失败异常。
    • 您可以尝试使用关键字Run Keyword And Ignore Error。它返回字符串PASSFAIL 并返回发生的值或错误robotframework.org/robotframework/latest/libraries/…
    • 非常感谢。看来可以在一定程度上解决我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 2017-04-20
    • 2017-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多