Keyword Driven Testing Framework with Example

Keyword Driven Framework

Keyword Driven Framework is a functional automation testing framework that divides test cases into four different parts in order to separate coding from test cases and test steps for better automation. Keyword driven testing framework divides the test cases as test steps, objects of test steps, actions on test steps and data for test objects for better understanding.

What is Keyword Driven Testing?

Keyword Driven Testing is a scripting technique that uses data files to contain the keywords related to the application being tested. These keywords describe the set of actions that is required to perform a specific step.

A keyword-driven test consists of high and low-level keywords, including the keyword arguments, which is composed to describe the action of a test case. It is also called table-driven testing or action word based testing.

In Keyword Driven Testing, you first identify a set of keywords and then associate an action (or function) related to these keywords. Here, every testing action like opening or closing of browser, mouse click, keystrokes, etc. is described by a keyword such as openbrowser, click, Typtext and so on.

For Example:

Keyword Driven Framework Testing - Complete Tutorial

  1. login to “guru99” website – Keyword “login” will be used in our automation framework, to the test the login function or action associated with it.
  2. logout to “guru99” website— Keyword “logout” will be used in our automation framework, to test the logout function or action associated with it.

We will see some more example further in the article.

Example of keywords

Keywords Description
Login Login to guru99 bank demo site
Emails Send Email
logouts Log out from guru99 bank demo site
Notifications Find unread notifications

In order to create a Keyword driven framework, you need following things

  1. Excel Sheet– Identify the keywords and store them in an Excel sheet
  2. Function Library– Function library consist of the function for the business flows ( login button for any website).So when test is executed, it will read the keyword from the Excel sheet and call the functions accordingly
  3. Data Sheets– Data sheets is used to store the test data that will be used in the application
  4. Object Repository– based on your keyword driven framework you can use an object repository
  5. Test Scripts– Based on the design of your framework, you can have test scripts for each manual Test Case or a single driver script

Why do Keyword Driven Testing

In Software Engineering, Keyword Driven Testing is done due to following reason

  • Common components handled by standard library
  • Using this approach tests can be written in a more abstract manner
  • High degree of reusability
  • The detail of the script is hidden from the users
  • Users don’t have to use the scripting languages
  • The test is concise, maintainable and flexible

How to perform Keyword Driven Testing

Keyword based testing can be done in both ways, manually as well as automated. But usually, it is used with automated testing.

The objective behind automating Keyword based testing is

  • It helps to reduce maintenance cost
  • Avoids duplicated specifications
  • Greater reuse of function scripting
  • Better testing support and portability
  • Achieve more testing with less or same effort

With keyword driven testing, you can create a simple functional tests in the earlier stages of development, testing the application piece-by-piece. The simplest way to compose keyword driven test is to record them. After recording, the test can be modified and customized as per the requirement.

Each keyword needs to be linked with atleast one command, test scripts or function, which implement the actions related to that keyword.

When test cases are executed, keywords are interpreted by a test library, which is called by a test automation framework.

The major activities involved in keyword driven testing are

  • Step 1. Identifying low level as well as high-level keywords
  • Step 2. Implementing the keywords as executable
  • Step 3. Creating test cases
  • Step 4. Creating the driver scripts
  • Step 5. Executing the automation test scripts

Tools used for Keyword Driven Testing

Few tools which are extensively used for Keyword driven testing.

Advantages of Keyword Driven Testing

  • It allows functional testers to plan test automation before the application is ready
  • Tests can be developed without programming knowledge
  • It is not dependent on a specific programming language or tool
  • Compatible with any automation tools available in the market

Sample test cases

  1. TC_01: Login to guru99 demo site, find out how many transactions is carried out today
  2. TC_02: Login to guru99 demo site, send an email to one of your customer and then logout
  3. TC_03: Login to guru99 demo site and check for any notification received

Summary:

  • A keyword-driven testing is a scripting technique that uses data files to contain the keywords related to the application being tested
  • A keyword-driven testing usually performed by automated testing.
  • Tests can be developed without programming knowledge
  • Tests are compatible with any automation tools available in the market