When designing keywords to be used by automated test cases, there is always this question: How detailed should they be? This question also encompasses such other things as: Should it be a simple click? Should it be a specifically written sentence for specific set of actions? Or maybe I should cover entire functionality with that one keyword or sentence and parameterize everything but a kitchen sink?
There is never a right answer when it comes to things like that (a lot of it stems from your experience in automation and product knowledge) but there is something you can set in your head when designing automation: This keyword should cover a user event for a functional area (it will keep test case readable), it should not be too big (so as not to become a maintenance and design nightmare) and it should not duplicate activity of another keyword in the same functional area.
One of the examples is the Login keyword. When doing a login, a user typically fills out Username, Password and clicks on a Login button, so this is what your keyword should do: Fill out this information and click on the button. Doing anything more granular (using keywords like ‘Set Text’, ‘Set Text’, ‘Click’) and test case and keyword can become prone to maintenance issues or not being very readable. Doing anything more (like also including potential registration process in to keyword parameters) and you can run in to a maintenance issue when business flow changes and once again test case can become less readable (too much text especially since it’s not related to Login itself). But at the same time this keyword should still cover all the login related basis like for example if it has additional optional check box like ‘Remember Me’ it should give an option to set it.
Obviously the above Login example is more straight forward and engineers typically deal with more complex situations where it’s hard to draw a line where one keyword stops and another one begins. So as automation developers we keep this Goldilocks Principle in mind when designing any type of keywords whether it’s UI or back-end and at the end rely on our expertise to make a right decision.