在机器人框架中,关键字"Call Method"用于调用一个自定义的关键字或者函数。它的作用是在测试用例中调用其他的关键字或者函数,从而实现代码的复用性。
以下是一个示例代码,演示如何在机器人框架中使用"Call Method"关键字:
*** Settings ***
Library Collections
*** Test Cases ***
Example Test
${result} Call Method My Custom Keyword Hello, world!
Log ${result}
*** Keywords ***
My Custom Keyword
[Arguments] ${message}
Log Received message: ${message}
[Return] Message processed successfully
在上面的示例中,我们首先导入了"Collections"库,以便在测试用例中使用"Call Method"关键字。然后,我们定义了一个测试用例"Example Test",在该测试用例中,我们使用"Call Method"关键字调用了自定义的关键字"My Custom Keyword"。然后,我们使用"Log"关键字打印出了"My Custom Keyword"关键字的返回值。
在关键字"My Custom Keyword"中,我们定义了一个输入参数"${message}",并通过"Log"关键字打印出了接收到的消息。最后,我们使用"[Return]"关键字返回了一个字符串。
当我们运行上面的测试用例时,输出结果将会是:
Received message: Hello, world!
Message processed successfully
这表明我们成功地在测试用例中调用了关键字"My Custom Keyword",并成功地处理了传递的参数。