我有一个关键字文件供两个产品使用。然后这些产品有自己的调用关键字规则。 例如:
*** 关键字 ***
关键字 1
然后我想在产品A中调用Keyword 1是Product A Keyword 1,在产品B中是Product B Keyword 1
在 new python 类时,通过元类在 python 关键字中添加前缀。 有什么办法可以在 robotframework 关键字中重新使用它吗?
您可以在关键字前面加上它的资源文件名,然后您可以调用具有相同名称但来自不同资源文件的不同实现的关键字,如下所示:
main.robot
*** Settings ***
Resource MyResource1.resource
Resource MyResource2.resource
*** Tasks ***
testink
MyResource1.MyKeyword
MyResource2.MyKeyword
MyResource1.resource
*** Keywords ***
MyKeyword
Log To Console "This Is MyKeyword from MyResource1"
MyResource2.resource
*** Keywords ***
MyKeyword
Log To Console "MyKeyword from MyResource2 saying hi!"
不确定我是否正确理解了您的问题,但我觉得您正在寻找如何使用嵌入式关键字。这是一个例子:
*** Test Cases ***
Example
This is product_A keyword
This is product_B keyword
*** Keywords ***
This is ${product} keyword
Log To Console ${product}