【问题标题】:can we provide 2 actions with "Run keyword if" built in function for robot framework我们可以为机器人框架内置功能“运行关键字 if”提供 2 个动作吗
【发布时间】:2018-07-23 17:26:25
【问题描述】:
    Run Keyword If    '${var1}'=='@{var2}[1]'    Run Keyword And Return Status    Check for Help Tab  Click on Help button

这是示例代码,我必须执行。我必须使用带有 RIDE 平台的机器人框架为此执行两个操作,但它向我显示错误,如预期的 0 个参数,得到 1。我理解错误,但是如果我必须自己执行 2 个操作或者我必须把第一个关键字中的另一个关键字“单击帮助按钮”以“检查帮助选项卡”。

【问题讨论】:

    标签: robotframework


    【解决方案1】:

    使用“运行关键字”

    您可以运行关键字run keywords,此时您可以运行多个关键字。

    例子:

    *** Test cases ***
    Example
        run keyword if  1 == 1  run keywords
        ...  log  this is a normal log
        ...  AND  log  this is a warning  WARN
        ...  AND  log to console  this is a log to the console
    

    使用自定义关键字

    您的另一个选择是创建一个自定义关键字来完成您需要做的所有事情,然后调用该关键字:

    例子:

    *** Keywords ***
    Do some logging
        log  this is a normal log
        log  this is a warning  WARN
        log to console  this is a log to the console
    
    *** Test cases ***
    Example
        run keyword if  1 == 1  Do some logging
    

    【讨论】:

    • 感谢 Bryan 的建议。
    【解决方案2】:

    错误表明检查帮助选项卡不需要参数,但给出了一个。给定的参数是第二个关键字:点击帮助按钮。

    我知道有两种方法可以做到这一点,我推荐第一种:

    1) 定义一个新的关键字:

    Check Help Tab and Click Help Button
        Check for Help Tab
        Click on Help Button
    

    并像这样使用它:

    Run Keyword If    '${var1}'=='@{var2}[1]'    Run Keyword And Return Status    Check Help Tab and Click Help button
    

    或 2)

    Run Keyword If    '${var1}'=='@{var2}[1]'    Run Keyword And Return Status    Check Help Tab 
    Run Keyword If    '${var1}'=='@{var2}[1]'    Run Keyword And Return Status    Click Help button
    

    【讨论】:

    • 感谢您的回复。我会以同样的方式实现
    • 正如 Bryan 所强调的,这可以使用标准关键字来实现。
    猜你喜欢
    • 2015-11-07
    • 2018-11-27
    • 2018-12-03
    • 2022-12-29
    • 1970-01-01
    • 2020-11-06
    • 2021-04-16
    • 2017-10-13
    • 1970-01-01
    相关资源
    最近更新 更多