Skip to content

1.4. Extend your first keyword

Goal

  • Modify the keyword named Print Your Name to take a name as an argument.
  • The keyword should work even if you do not specify a name, in this case the keyword should log Jane Doe.

Solution

Hints

You need to define the expected arguments in the [Arguments] setting inside the keyword table.

Click here to learn more about specifying arguments.

Solution: tests/01-greetings/01-greetings.robot
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
*** Test Cases ***
Greetings
    Print Your Name
    Print Your Name    ${YOUR_NAME}

*** Keywords ***
Print Your Name
    [Arguments]    ${your_name}=Jane Doe
    Log    ${your_name}

*** Variables ***
${YOUR_NAME}    Your Name

Results

Inside the tests folder, execute the following command.

1
robot .

You can check the generated log.html file to see how your test case worked.


Last update: June 22, 2020