As we have seen, Robot can be expanded with libraries that can add more keywords. That can be a convenient feature also for us when writing tests. If we have a set of instructions that we are going to repeat frequently in our tests, it would be convenient to factor them into a single keyword that we can reuse. Furthermore, Robot can be expanded with new custom commands that we can implement in Python.
Adding custom keywords
To see how extending Robot with custom keywords works, we are going to create a very simple customkeywords.robot test file, where we are going to write a basic script that only greets us:
*** Test Cases ***
Use Custom Keywords
Echo Hello
Running the script will fail as we have not yet implemented the Echo Hello keyword, so how can we provide it? For this purpose, Robot supports a *** Keywords *** section, where we can declare all our custom keywords, so let's declare our keyword there:
*** Keywords ***
Echo Hello
Log Hello!
**...