【问题标题】:If robotframework has keyword to handle exception?如果机器人框架有关键字来处理异常?
【发布时间】:2019-12-18 15:38:51
【问题描述】:

我这样写一个关键字:

My Keyword
    [Argument]  ${param}
    Internal Keyword 1
    ...
    Internal Keyword n
    Run When Any of The Upper Keywords Failed

我希望关键字作为它的描述运行,谁能告诉我如何实现它?

【问题讨论】:

    标签: exception robotframework keyword


    【解决方案1】:

    有几种方法可以实现这一点,一种是使用Run Keyword And Return Status - 它返回一个布尔值真/假,包装的关键字是通过还是失败。在此基础上,您可以运行“异常”关键字:

    ${passed 1}=    Run Keyword And Return Status    Internal Keyword 1
    ${passed 2}=    Run Keyword And Return Status    Internal Keyword 2
    
    Run Keyword If    not ${passed 1} or not ${passed 2}    Run When Any of The Upper Keywords Failed
    

    【讨论】:

    • 您好,感谢您的回复,我必须将其视为一种变通方案,如果内部关键字是多个,我必须使用循环来处理。
    • 你可以循环执行,是的;您还可以将它们分组到关键字中,然后获取其状态。变通与否,这就是 RF 的异常处理能力——它的思想是如果一个步骤失败,则案例失败;因此尝试:除了:块有点麻烦。
    猜你喜欢
    • 1970-01-01
    • 2013-11-08
    • 2016-12-17
    • 2015-10-14
    • 2019-06-11
    • 2017-12-19
    • 2020-05-03
    • 2020-09-25
    • 1970-01-01
    相关资源
    最近更新 更多