My question is surely stupid but I need to understand the real utility.
I often see the tag “Argument” before using the corresponding keyword
Ex :
My Keyword
[Arguments] ${my_variable1} ${my_variable2}
All my keyword are done without arguments. It works fine but I think I haven’t understand something lol…
*** Test Cases ***
Check XYZ Page as Standard User
Open Login Page
Input Text id:username usr0001
Input Password id:password mysecret01
Navigate to xyz page
Check XYZ Page as Admin User
Open Login Page
Input Text id:username Admin
Input Password id:password Super01Secret
Navigate to xyz page
*** Keywords ***
Open Login Page
Open Browser ${applicationurl} chrome
Wait Until Page Contains Element id:username
Navigate to xyz page
Click Link abc
Click Link xyz
Wait Until Page Contains X,Y & Z
Here is effectively the same tests with a keyword with arguments:
*** Test Cases ***
Check XYZ Page as Standard User
Login To Application usr0001 mysecret01
Navigate to xyz page
Check XYZ Page as Admin User
Login To Application Admin Super01Secret
Navigate to xyz page
*** Keywords ***
Login To Application
[Arguments] ${username} ${password}
Open Login Page
Input Text id:username username
Input Password id:password password
Open Login Page
Open Browser ${applicationurl} chrome
Wait Until Page Contains Element id:username
Navigate to xyz page
Click Link abc
Click Link xyz
Wait Until Page Contains X,Y & Z
Now if you have 20 different user roles and you need to test all 20 roles with this page, plus the combinations of users having 2, 3, 4, 5 of these roles at the same time, the test cases will add up quickly and this is just for one page test.
This becomes even more useful when you put these keywords in a library that can be imported into many test cases.
Hi Centaure,
If you want you can also use Embedded keywords in RF. Derivated from BDD (Behavior Driven Development) Gherkin syntax.
In such case Dave’s scenario would look like:
*** Test Cases ***
Standard user login
When User with name Standard is logged in
Then User can navigate to XYZ page
Admin user login
When User with name Admin is logged in
Then User can navigate to ZYX page
*** Keywords ***
User with name ${user_name} is logged in
Open Browser ${applicationurl} chrome
Wait Until Page Contains Element id:username
Input Text id:username ${user_name}
Input Password id:password mysecret01
User can navigate to ${url} page
Navigate to ${url} page
Click Link abc
Click Link xyz
Wait Until Page Contains ${url}
This could surely be elaborated more and written nicer, but it is enough to give you basic overview how the argument is passed from keyword name to lower keywords.