Implement Keyword Driven Framework


Following on our discussion with frameworks, in our previous section, we read about keyword driven framework. We mentioned that keywords are blocks of functionality that are abstracted from step definitions and so we just call keywords/modules when needed. We also mentioned technical keywords and business -ish keywords. We will move forward in this section to get into implementation details and we will go with the latter i.e. business keywords.

In this section, we are going to take a concrete example on an e-commerce website and see how we can implement this capability. We are also going to build on top of data driven capabilities we build in our previous section on data-driven frameworks.

For example, each of the below capabilities will still exist in our framework and we will build the keywords on top of the below capabilities.


  1. You have completed the section “Set up Env” and have your environment ready with JDK, maven and Eclipse (+plugins)
  2. You have read and understood HTML DOM
  3. You were able to comprehend “Find Element Strategies” post
  4. You downloaded the project code base for Keyword driven framework under – and imported into Intellij and the structure should look as below


If imported into eclipse, it looks as below


Use Case:

As part of my framework, I need the following features viz.

  • visit url – url being user supplied value
  • sign_in (username,password) – signs in to application
  • Contact us – fill the contact us page and submits

As we see above, the keywords are readable, so we can re-use them in future in other step definitions too.

Object Repository:

We hear this term a lot in the Automation space and QTP has made it very popular. Object repository as the name suggests is a repository that contains the objects we want to interact with. With the advent of Selenium and more mature tools, that are open source and configurable/flexible, we can create object repository with one single line in some cases. Anyways, for this framework, I would like to externalize the locator (html locator) information instead of hard-coding it in the step definitions. We will simply use Java Properties library and hence will maintain it as Key=value pairs in a file

I will simply create‘‘ file in src/test/resources folder and read it using a class Since I want the locators information on sign and contact us page along with home page, below is how the file contents look.

Keywords Module(s):

Keywords or modules are blocks of code that can be called to implement a certain set of actions. We hear many synonymous words for this – keywords, modules, actions etc. It is a repeatable model.

Below we will be creating two modules i.e. and

Entire Cucumber Feature:

Step Definitions

Execution Output

IntelliJ Execution (how to execute is explained in previous post)



Command line output (mvn test) 


CI Server output