top of page

Blog

Explore the World of Software Testing. 

Read. Learn. Innovate.

Keyword Driven Automation Framework

A Keyword-Driven Automation Framework is a type of test automation framework that uses keywords to represent actions or functions within the test scripts. Each keyword corresponds to a specific action (like "click," "enter text," or "verify"), which allows non-technical users to define test cases without needing to write code. This framework separates the test logic from the actual script, making it highly reusable, maintainable, and accessible.


Key Features of Keyword-Driven Automation Frameworks


  1. Keyword Abstraction:

    • Each test step is defined by keywords, which represent a particular action or function, such as "Login," "Add to Cart," or "Search." Keywords are then mapped to specific code functions in the automation framework.

  2. Separation of Test Logic from Script Code:

    • The framework allows business users or testers to create test cases by combining keywords in a sequence. The actual script code that performs each action is stored separately, making it easier to update or modify test cases without changing the code.

  3. Modularity and Reusability:

    • Since each keyword represents a modular action, these can be reused across different test cases. For instance, a "Login" keyword can be used in multiple tests without rewriting code.

  4. Easy Maintenance:

    • If an application’s UI or workflow changes, updates are often limited to keyword definitions rather than modifying individual test scripts. This reduces maintenance time and effort.

  5. Reduced Coding Skills Required:

    • Keyword-driven frameworks make it easier for testers with minimal coding experience to create test cases by using pre-defined keywords, enabling better collaboration between technical and non-technical team members.


Pros and Cons of Keyword-Driven Automation Frameworks

Pros

Cons

High reusability due to modular keywords

Initial setup and framework development can be time-consuming

Enables non-technical users to create test cases

Requires significant initial planning and keyword definition

Easier to maintain as test logic is separate from code

Can become complex with a large number of keywords

Reduces code duplication across test cases

Requires detailed documentation for effective use

Use Cases


  • E-commerce Applications: Reusing keywords like "Login," "Search Product," "Add to Cart," and "Checkout" across different test cases.

  • Banking Applications: Modular keywords for actions like "Open Account," "Deposit Funds," "Transfer Money," and "Logout."

  • Login Scenarios: Different test cases using keywords for steps such as "Enter Username," "Enter Password," and "Click Login."


Common Tools for Keyword-Driven Frameworks


  1. Selenium WebDriver: Combined with a testing framework like TestNG, Selenium can be customized for keyword-driven approaches.

  2. Appium: Can be adapted for mobile testing with a keyword-driven approach.

  3. Robot Framework: An open-source framework specifically designed for keyword-driven testing and highly compatible with various libraries (including Selenium).

  4. UFT (Unified Functional Testing): Built-in support for keyword-driven testing, making it easier for testers to define keywords directly within the tool.


Example of Keyword-Driven Testing


Imagine a test for logging into an application. Keywords like "Open Browser," "Navigate to Login Page," "Enter Username," "Enter Password," and "Click Login" would each be mapped to a function that executes that action. Here’s a simple conceptual example in Java using Selenium:


  1. Define Keywords in an External File (e.g., Excel)

Test Case

Keyword

Parameter 1

Parameter 2

TC1

OpenBrowser

Chrome


TC1

NavigateTo


TC1

EnterText

usernameField

testUser

TC1

EnterText

passwordField

testPass

TC1

Click

loginButton


TC1

VerifyText

welcomeMessage

Welcome back!

  1. Implementation of Keyword Actions


The framework reads each keyword and calls the associated function. Here’s a sample Java code:

public void executeKeyword(String keyword, String param1, String param2) { 

switch (keyword) { 

case "OpenBrowser": driver = new ChromeDriver(); break; 

case "NavigateTo": driver.get(param1); break; 

case "EnterText": driver.findElement(By.id(param1)).sendKeys(param2); break;

case "Click": driver.findElement(By.id(param1)).click(); break; 

case "VerifyText": String actualText = driver.findElement(By.id(param1)).getText(); Assert.assertEquals(actualText, param2); break; 

// Add more keywords as needed 

                } 
       }

In this example, each keyword is associated with a specific function that performs the action defined by the keyword. When executed, the test script reads keywords and parameters, then calls the relevant methods to perform each step.


Summary


Keyword-Driven Frameworks are highly modular and suitable for large projects with repetitive test steps. They are beneficial for teams with both technical and non-technical members, as they allow test cases to be created without deep programming knowledge. However, they require careful planning and setup, as defining and managing a large set of keywords can become complex.

Related Posts

See All

Hybrid Automation Framework

A Hybrid Automation Framework  combines elements from multiple test automation frameworks to leverage their strengths and minimize their...

Modular Driven Automation Framework

A Modular Driven Framework  is a test automation framework where the application under test is divided into smaller, independent modules,...

bottom of page