Search code examples
robotframeworkkeywordrobotframework-ide

can i use keywords as arguments in robotframework?


I want to replace ${assertion_Keyword} by Screen Should Contain or Screen Should Not Contain so i want to put an Argument like a 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} 

With this code i code a syntax error no keyword found : enter image description here

How can this action be possible? is there other ways to do it ?

Thanks.


Solution

  • The Run Keyword command will help you with that. Below is an example inspired on your example code. I've commented out the Sikuli keywords, but kept them in place and added two keywords to mock those found in the Sikuly Library.

    *** 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