我可以在 robotframework 中使用关键字作为参数吗?

can i use keywords as arguments in robotframework?

我想用 Screen Should ContainScreen Should Not Contain 替换 ${assertion_Keyword} 所以我想像关键字一样放置参数

check_element_and_its_representation      
    [Arguments]    ${assertion_Keyword}    ${payload}    ${on_click_payload}     
    ${assertion_Keyword}    ${payload}
    SikuliLibrary.Click    ${payload}    
    Screen Should Contain    ${on_click_payload} 

使用此代码,我编写了一个语法错误,未找到关键字:

这个动作怎么可能?还有其他方法吗?

谢谢。

运行 关键字命令将帮助您。以下是受您的示例代码启发的示例。我已经注释掉了 Sikuli 关键字,但保留了它们并添加了两个关键字来模拟在 Sikuly 库中找到的关键字。

*** Test Cases ***
TC Screen Should Contain
    Check Element And Its Representation    Screen Should Contain    payload    on_click_payload

TC Screen Should Not Contain
    Check Element And Its Representation    Screen Should Not Contain    payload    on_click_payload


*** Keywords ***

Check Element And Its Representation      
    [Arguments]    ${assertion_Keyword}=Screen Should Contain    ${payload}=None    ${on_click_payload}=None     
    Run Keyword    ${assertion_Keyword}    ${payload}
    # SikuliLibrary.Click    ${payload}    
    # Screen Should Contain    ${on_click_payload} 

Screen Should Contain
    [Arguments]    ${var}
    Log    Screen Should Contain

Screen Should Not Contain
    [Arguments]    ${var}
    Log    Screen Should Contain