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.
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}