-1

i want to pass the arguments from testcase to keyword.

what i am trying to do? i have the testcase with arguments like below

*** Test Cases ***
Test something happens
    Login
    ${val2} =  somevalue1
    ${val2} =  somevalue2
    ${name} =  somename
    Draw something  ${name}  ${val1}  ${val2}

*******keywords************
Draw something 
    Input Text    ${name_input}    ${name}
    Input Text    ${name_input}    ${val1} 
    Input Text    ${name_input}    ${val2}

How can i pass the arguments from testcase to keyword Draw something i was trying to pass it directly to keyword like below

*********keywords******* Draw something ${name} ${val1} ${val2}

but gives error keyword expected 0 arguments but got 3

could someone help me with this. thanks.

someuser2491
  • 1,848
  • 5
  • 27
  • 63

1 Answers1

0

Here is the documentation on how to use arguments with Robot Framework keywords: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-arguments

And here is an example printing out a full name based on arguments first and last:

*** Keywords ***
Print Name
    [Arguments]       ${FIRST}  ${LAST}
    Log To Console  ${FIRST} ${LAST}

*** Test Cases ***
Test printing a name
    Print Name  John  Doe

As you can see, you need to add the [Arguments] section under your keyword:

*** Keywords ***
Draw something
    [Arguments]   ${name}  ${val1}  ${val2}
    Input Text    ${name_input}    ${name}
    Input Text    ${name_input}    ${val1} 
    Input Text    ${name_input}    ${val2}
Joonas Köppä
  • 336
  • 1
  • 4
  • thanks is there a way that i pass the arguments augmented to the keyword itsef. – someuser2491 Sep 26 '19 at 13:12
  • There is, its called embedding arguments to keywords: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-names In this case you need to implement the keyword in a python code file. – Joonas Köppä Sep 27 '19 at 05:11