How To Build a Keyword-driven Framework in Selenium?

April 13, 2026 · 23 min read · Tool Comparison

Blog / Insights /
How To Build a Keyword-driven Framework in Selenium?

How To Build a Keyword-driven Framework in Selenium?

Contributors Updated on

Learn with AI

Linkedin

Facebook

X (Twitter)

Mail

Learn with AI

 

Instead of compose the same automation code repeatedly for the same actions, you can create keywords for those actions. When writing tryout, you only need to call these keywords. This approach, know as creating a keyword-driven model, get tryout book more readable, maintainable, and efficient by debar redundancy.

What is a Keyword-driven Framework?

Keyword-driven framework is a model & nbsp; where trial scripts are indite of sequence of keywords. These keywords are code snippets for actions in the system.
 

For model, an especially common keyword is & nbsp;Click. It instructs the system to simulate a shiner click on a specified web component. The finish is to simplify interaction with the system into a keyword. They go the “ building block ” to help testers compose automated test cases without have to rely heavily on technical knowledge.

Example of Keyword-driven Framework in Action

Let ’ s look at a snapshot of the keyword library in & nbsp;:
 


 

There are quite a lot of keywords for quizzer to choose from. Testers only feature to choose the keywords for the activity they want to perform and thread them together to form a complete test case. Keywords can come with argument, which testers can assign a specific value on which to do the action.
 

Let ’ s say we want to quiz the next scenario:
 

Component

Details

Test Case ID

TC001

Description

Verify Login with Valid Credentials

Preconditions

User is on the Etsy login popup

Test Steps

1. Enter a valid email address.

2. Enter the corresponding valid password.

3. Click the `` Sign In '' button.

Test Data

Emailvaliduser @ example.com

Password: validpassword123

Expected Result

Users should be successfully logged in and redirected to the homepage or the previously destine page.

Literal Result

(To be filled in after execution)

Postconditions

User is logged in and the session is active

Pass/Fail Criteria

Pass: & nbsp;Test passes if the exploiter is logged in and redirected correctly.

Fail: Test miscarry if an mistake message is displayed or the user is not logged in.

Comments

Ensure the exam environment has net admittance and the server is operational.

We will demand the undermentioned keywords for these test steps:

  1. OpenBrowser [parameter: https: //etsy.com]
  2. Click [parameter: login_button_ID]
  3. Click [parameter: email_field]
  4. setText [parameter: username111]
  5. Click [argument: password_field]
  6. setText [parameter: password111]
  7. Click [parameter: login_form_button_ID]
  8. VerifyUserLoggedIn

With a collection of diverse keywords, you have a & nbsp;keyword library. You can use version control systems like Git to store and manage the Keyword Library. This helps in tracking changes, collaborating with team members, and maintaining a story of modifications.
 

Some test automation tools/frameworks also have built-in support for storing and managing keyword libraries within their IDE, such as & nbsp;Robot Framework or .

Benefits of a Keyword-driven Framework

  1. Ease of use: & nbsp;once the complexity of coding is abstracted into keywords, yet the non-technical people can publish and manage tests easily. On another tone, this too join stakeholders (occupation analysts, project managers, etc.) since it makes testing so much more accessible and understandable to them.
  2. Support Test Automation: & nbsp;as a result, a keyword-driven framework makes automation testing a breeze. Test cases can now be created quickly exactly by combining the correct keywords and setting parameter for them. These keywords are also extremely reusable across test cases, which promotes overall consistency in test design.
  3. Maintainability: & nbsp;one of the big challenges to automation examination is the maintenance. Considering the ever-changing nature of Agile testing, tryout cases can easily break when modification are made on the UI. Maintaining a large number of test cases is a sincerely daunting labor. With a keyword-driven framework, test example maintenance is more centralized since quizzer only need to update the corresponding keyword and not the entire test case.
  4. Potential Cost and Schedule Savings: & nbsp;all of the benefits name above translate into cost savings for the establishment. More functionality can be covered by machine-driven tests, which means higher examination coverage, lead to good alignment with Agile good practices.

Challenges of a Keyword-driven Framework

1. Keyword Maintenance: as the application under test evolves, the keywords and their implementations demand to be updated to speculate changes in the application ’ s UI or functionality. This alimony can become inapt, especially if the keyword library is extensive.
 

2. Complexity in Keyword Design: design a comprehensive set of keywords that accurately represent all necessary actions and are recyclable across different tests is a complex task. You ’ d want proficient expertise to make that happen. Ensuring that keywords are intuitive and cover edge cases requires careful preparation and design.
 

3. Limited Debugging Information: when tryout betray, debugging can be challenging because the error messages and logs might not provide sufficient circumstance about which keyword fail or why. This can create it difficult to pinpoint the exact grounds of the failure.Increased clip and endeavour may be required to diagnose and resolve issue, impacting the efficiency of the testing process.
 

4. Performance Overheads: keyword-driven fabric can inclose execution overhead due to the abstraction layer between the test scripts and the actual test executing. This may leave in obtuse test performance times compared to more unmediated approaching.

What is Keyword Driven Testing?

Keyword-driven testing is the test approach that leverages a keyword-driven framework to symbolize actions in test cases.

Setting Up a Keyword-driven Framework in Selenium

Let ’ s see how you can set up a keyword-driven framework in Selenium.

  1. Choose your tool to build it
  2. Setup environment
  3. Design framework construction
  4. Identify keywords and create classes
  5. Create Page Object Model
  6. Implement test datum handling
  7. Create keyword executor

Let ’ s try to create a simple keyword-driven framework in Selenium. The test measure include:

  1. Open Browser
  2. Navigate to URL
  3. Click Sign In Button
  4. Enter Email
  5. Enter Password
  6. Click Sign In
  7. Verify User Name
  8. Logout
  9. Verify Sign In Button
  10. Close Browser

 

Step 1: Setup Your Development Environment

First, you want to download and install the latest version of the & nbsp;Java Development Kit from Oracle ’ s website. You can set the & nbsp;JAVA_HOME environment variableto the JDK installation directory. & nbsp;Here ’ s a guide to do it from Atlassian.

After that, install & nbsp;EclipseIntelliJ IDEA, and then & nbsp;Maven. Make sure to set the M2_HOME and MAVEN_HOME surround variables to the Maven installation directory. After that, add Maven ’ s bin directory to the PATH environment variable. & nbsp;Here ’ s a StackOverflow usher to do it.
 

Once done, open your IDE and make a new Maven undertaking. You can use the & nbsp;maven-archetype-quickstarttemplet to set up the project construction.

Step 2: Add Dependencies To ‘ pom.xml ’

pom.xmlstands for `` Project Object Model '' XML file. It is the fundamental unit of employment in Maven. This file is located in the rootage directory of a Maven project and it contains information about the task and configuration details utilise by Maven to build the project.
 

Maven handles the downloading and linking of libraries expect for your labor. When you qualify a dependency in pom.xml, Maven automatically download the necessary library from the specified repository (e.g., Maven Central Repository) and includes it in your project 's classpath.
 

Here ’ s the colony you can add to your Maven project:

 

Essentially it include the Selenium WebDriver library for automatize web applications and the Apache POI for Excel readings (these Excel files are where we store our keywords). We besides have the TestNG to help write exam and Log4j for Logging resolution.
 

You can add more habituation as you wish to back your testing activities. For example, you can add the Cucumber colony to & nbsp;or RestAssured to test REST APIs.
 

Step 3: Create the Directory Structure

The directory structure is essential for organizing your project files in a coherent and achievable way. Go to & nbsp;src & gt; main & gt; java

You can set up the following booklet:
 

src/main/java

& nbsp; & nbsp; & nbsp; & nbsp; └── com

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; └── yourcompany

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; ├── substructure

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; ├── keywords

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; ├── utils

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; └── tests

src/test/resources

& nbsp; & nbsp; & nbsp; & nbsp; ├── testdata

& nbsp; & nbsp; & nbsp; & nbsp; └── config

 

Step 4: Create a Keyword Map Table in Excel

Create an Excel sheet that delimit all the keywords available for the test mechanisation project. Each row represents a step in a test case, including the keyword, locater, and value if needed.
 

You can simulate this table and paste it into Excel:
 

Step Number

Keyword

Locator

Value

1

openBrowser

   

2

navigate

 

URL

3

clickSignIn_h

//a [@ id='signin ']

 

4

enterEmail

(//div [@ class= ' css-1wa3eu0-placeholder ']) [1]

username

5

enterPassword

(//div [@ class= ' css-1wa3eu0-placeholder ']) [2]

password

6

clickSignIn

//button [@ id='login-btn ']

 

7

verifyUserName

//span [@ class='username ']

username

8

logout

//a [@ id='logout ']

 

9

verifySignBtn

//a [@ id='signin ']

Sign In

10

closeBrowser

   

Make sure that the Excel file is arrange correctly, with columns for each component of the exam steps.

 

Step 5: Copy into excelData directory

In your Java IDE (such as Eclipse, IntelliJ IDEA, etc.), locate your project in the project explorer venire. After that, right-click on your project and navigate to & nbsp;New & gt; Package. Name the package & nbsp;excelData.

SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.

This package will serve as a dedicated folder within your project to store data files, particularly your Excel file.

Once done, copy the Excel file (DemoFile.xlsx) and paste it into the & nbsp;excelDatadirectory.
 

ProjectName

├── src

& nbsp; & nbsp;├── main

& nbsp; & nbsp;& nbsp; & nbsp;├── java

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── com

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── keyword_driven_framework

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── utility

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── keywordDriven

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── excelUtility

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── executionEngine

& nbsp; & nbsp;& nbsp; & nbsp;├── resources

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── excelData

& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;& nbsp; & nbsp;├── DemoFile.xlsx

 

Placing the Excel file within the project structure allows for easy access by the code that will read from this file, control that file path are relative to the project and reducing potential file path errors.
 

Step 6: Create a Constants Class

Create a new software named utility and define constants like URL, filePath, and Excel data in a class identify Constants. These constants can be accessed throughout your projection to maintain consistency and easily make change in one spot if needed.
 

package com.keyword_driven_framework.utility;

public class Constants {

& nbsp; & nbsp; & nbsp;public static final String URL = `` https: //bstackdemo.com/ '';

& nbsp; & nbsp; & nbsp;public static final String filePath = `` D: \\DemoFile.xlsx '';

& nbsp; & nbsp; & nbsp;public static final String excelData = `` DemoFile.xlsx '';

& nbsp; & nbsp; & nbsp;public static final String username = `` Your_Username '';

& nbsp; & nbsp; & nbsp;public static final String password = `` Your_password '';

}
 

Step 7: Implement Action Keywords

Create a new package named & nbsp;keywordDrivenand define method for each action keyword in a class named & nbsp;Action_Keyword.
& nbsp; & nbsp;

Step 8: Implement Action Keywords

This step is when you create a consecrated package in your project to house the classes and methods that will execute the action keywords defined in your Excel file.
 

To do this, make another package named & nbsp;keywordDriven. Within it create a stratum file named & nbsp;Action_Keyword.
 

In the & nbsp;Action_Keywordclass, define methods for each action keyword identified in your Excel file. Each method will check to an action (e.g., open browser, navigate, click, enrol schoolbook). For example:
 

package com.keyword_driven_framework.keywordDriven;
 

import java.time.Duration;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.firefox.FirefoxOptions;

import com.keyword_driven_framework.utility.Constants;
 

public class Action_Keyword {

& nbsp; & nbsp; & nbsp;public static WebDriver driver;
 

& nbsp; & nbsp; & nbsp;public void openBrowser () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Set the itinerary to the WebDriver executable

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;System.setProperty (`` webdriver.gecko.driver '', `` path_to_driver '');

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Create a new case of the Firefox driver

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;FirefoxOptions options = new FirefoxOptions ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver = new FirefoxDriver (options);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Maximize the browser window

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.manage () .window () .maximize ();

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void navigate () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Implicit wait

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.manage () .timeouts () .implicitlyWait (Duration.ofSeconds (10));

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Navigate to the URL

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.get (Constants.URL);

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void clickSignIn_h () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Locate and click the Sign In button

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.findElement (By.xpath (`` //a [@ id='signin '] '')) .click ();

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void enterEmail () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Locate the email field and enter the email

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.findElement (By.xpath (`` (//div [@ class= ' css-1wa3eu0-placeholder ']) [1] '')) .sendKeys (Constants.username);

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void enterPassword () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Locate the password field and enter the countersign

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.findElement (By.xpath (`` (//div [@ class= ' css-1wa3eu0-placeholder ']) [2] '')) .sendKeys (Constants.password);

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void clickSignIn () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Locate and tick the Sign In button

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.findElement (By.xpath (`` //button [@ id='login-btn '] '')) .click ();

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void verifyUserName () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Verify the username

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String username = `` your_username '';

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;username.equals (driver.findElement (By.xpath (`` //span [@ class='username '] '')) .getText ());

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void logout() {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Locate and click the Logout button

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.findElement (By.xpath (`` //a [@ id='logout '] '')) .click ();

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void verifySignBtn () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Verify the Sign In button is present

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String signIn = "Sign In";

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;signIn.equals (driver.findElement (By.xpath (`` //a [@ id='signin '] '')) .getText ());

& nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp;public void closeBrowser () {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Close the browser

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;driver.quit ();

& nbsp; & nbsp; & nbsp;}

}

 

Here we have defined the following keywords:

  1. openBrowser
  2. Navigate
  3. slickSignIn_h
  4. enterEmail
  5. enterPassword
  6. clickSignIn
  7. verifyUsername
  8. logout
  9. verifySignBtn
  10. closeBrowser

By building this class, you promote code reuse and modularity. It becomes lots easier to preserve and update the fabric when the action methods are organized in a integrated manner.
 

Step 9: Read Data From Excel

This step allows the framework to dynamically say the keywords, locators, and values from your previously make Excel sheet. Since it is educe data from an outside beginning instead than hardcoding them into the test scripts, the framework is more flexible, maintainable, and scalable.
 

Here we ’ ll create another grade named & nbsp;ReadExcelSheet. In this class, we can define methods to say the keywords, locators, and values from the Excel sheet and store them in a suited information structure (e.g., ArrayList).
 

Here ’ s how the course might appear like:
 

package com.keyword_driven_framework.excelUtility;
 

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Iterator;

import org.apache.poi.ss.usermodel.Cell;

import org.apache.poi.ss.usermodel.Row;

import org.apache.poi.xssf.usermodel.XSSFSheet;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.keyword_driven_framework.utility.Constants;
 

public class ReadExcelSheet {
 

& nbsp; & nbsp; & nbsp;public ArrayList & lt;String> readExcelData (int colNo) throws IOException {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String filePath = Constants.filePath;

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;File file = new File (filePath);
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Create an aim of FileInputStream class and pass file as parameter to its builder.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;FileInputStream fis = new FileInputStream (file);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Create a workbook instance that refers to the Excel file.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;XSSFWorkbook wb = new XSSFWorkbook (fis);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Get the desired sheet from the workbook.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;XSSFSheet sheet = wb.getSheet ("Sheet1");
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Create an iterator to restate through the run-in of the sheet.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Iterator & lt; Row & gt; rowIterator = sheet.iterator ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Skip the head row.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;rowIterator.next ();
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Create an ArrayList to store the data.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;ArrayList & lt;String> data = new ArrayList & lt; & gt; ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Iterate through the row.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;while (rowIterator.hasNext ()) {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Row row = rowIterator.next ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Get the cell at the specified column index.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Cell cell = row.getCell (colNo);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Get the cell value as a twine.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String cellValue = cell.getStringCellValue ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Add the cell value to the ArrayList.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;data.add (cellValue);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Close the workbook and file input flow.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;wb.close ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;fis.close ();
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;// Print and return the data.

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;System.out.println ("List: " + data);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;return data;

& nbsp; & nbsp; & nbsp;}

}
 

Step 10: Build The Execution Engine

Finally, we ’ ll create another package named & nbsp;executionEngine & nbsp;in which we ’ ll have a class with the same name. It will be the main driver of your keyword-driven framework. It will read the keywords, locators, and values from the Excel sheet and invoke the corresponding methods in the Action_Keyword form.

 

package com.keyword_driven_framework.executionEngine;
 

import java.io.IOException;

import java.lang.reflect.InvocationTargetException;

import java.lang.reflect.Method;

import com.keyword_driven_framework.excelUtility.ReadExcelSheet;

import com.keyword_driven_framework.keywordDriven.Action_keyword;
 

public class ExecutionTest {

& nbsp; & nbsp; & nbsp;public static void main(String[] args) throws IOException, Exception, IllegalArgumentException, InvocationTargetException {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;ReadExcelSheet rs = new ReadExcelSheet ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Action_keyword actions = new Action_keyword ();

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Class & lt; Action_keyword & gt; actionClass = Action_keyword.class;

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;ArrayList & lt;String> keywords = rs.readExcelData (1);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;ArrayList & lt;String> locators = rs.readExcelData (2);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;ArrayList & lt;String> values = rs.readExcelData (3);
 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;for (int i = 0; i < keywords.size (); i++) {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String methodName = keywords.get (i);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String locator = locators.get (i);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;String value = values.get (i);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;Method method;

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;if (locator != null & amp; & amp; ! locator.isEmpty () & amp; & amp; value != null & amp; & amp; ! value.isEmpty ()) {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method = actionClass.getMethod (methodName, String.class, String.class);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method.invoke (actions, locator, value);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} else if (locator != null & amp; & amp; ! locator.isEmpty ()) {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method = actionClass.getMethod (methodName, String.class);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method.invoke (action, locator);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} else {

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method = actionClass.getMethod (methodName);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;method.invoke (actions);

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;}

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;System.out.println (`` Test fulfill successfully '');

& nbsp; & nbsp; & nbsp;}

} 

Run the & nbsp;ExecutionTestclass to mention the yield. The fabric will read the keywords and corresponding data from the Excel sheet and execute the machine-controlled tryout steps accordingly.

Keyword-driven Testing With Automation Testing Tools

To skip the hassle of building and maintaining a framework, you can shop around for an automation testing creature that comes with a keyword-driven framework built-in that is ready-to-use immediately.

For example, Katalon Studio offers a built-in keyword-driven test capability—alongside Page Object Model (POM), data-driven testing, and BDD/TDD—to cover a wide range of automation needs. You can explore alltesting methodology supported by Katalonto see how these approaches can streamline your summons, improve tryout reusability, and reduce maintenance overhead.

Explain

|

FAQs

What is a keyword-driven framework in Selenium?

+

It ’ s a model where test cases are written assuccessiveness of “ keywords ” (e.g., openBrowser, click, setText, verifyText) that map to reusable automation functions—so tests read more like step than code. & nbsp;

Why would a team use keyword-driven prove rather of plain Selenium scripts?

+

To reduce duplicated code, make exam more readable for non-dev testers, and centralize maintenance—when the UI changes, you update the keyword implementation once rather of editing many scripts.

What are the nucleus building cube you need to implement it?

+

Typically: a keyword library (action methods), a test definition root (Excel/CSV/JSON), a locater strategy (often Page Object Model/Object Repository), and an execution engine that say the keyword + locater + datum and calls the right method.

How do the “ execution engine ” really run keywords from an Excel sheet?

+

It reads each row (Keyword, Locator, Value), then slay to matching methods (much via a switch-case or Java Reflection). Depending on what ’ s present, it ring a method with 0 / 1 / 2 parameters (keyword only, keyword + locator, keyword + locator + value).

What are the bad pitfall, and how do you forfend them?

+

Common issues arekeyword bloat(too many overlap keywords),hard-to-debug failures, and brittle locators. Avoid them by: hold alittle, ordered keyword set, adding structured logging/reporting per footstep, using stable locater (data-testids), and separating locators from logic viaPOM/Object Repository.

 

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free