我们可以为机器人框架

时间:2018-02-13 10:56:23

标签: robotframework

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

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

2 个答案:

答案 0 :(得分:4)

使用'运行关键字'

您可以运行关键字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

答案 1 :(得分:1)

错误说Check for Help选项卡不需要参数,但是给出了一个参数。给定的参数是第二个关键字:单击“帮助”按钮。

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

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