TravelTest Keyword Driven Framework (KDF)

Business Scenario

Welcome to the QA Automation Team at TravelTest Pvt. Ltd.

The QA Manager has assigned you the task of implementing a Keyword Driven Framework (KDF) for the TravelTest Web Application Automation Project.

As part of this lab, you will define Reusable Keywords for various application actions such as Login, Click, EnterText, and Logout. You will map these Keywords to Selenium Automation Methods and store Test Steps in an Excel File for Keyword-Based Execution. You will also execute Automated Test Cases using Keywords and

Pre-Lab Preparation

  • Configure Java, Selenium WebDriver, and TestNG.

  • Ensure the TravelTest project runs successfully.

  • Understand the basics of Keyword Driven Framework (KDF).

  • Learn Selenium actions like Click, SendKeys, and Login.

  • Prepare an Excel file for storing keywords.

  • Add Apache POI libraries for Excel handling.

  • Verify browser drivers and application access are working properly.

git pull origin branchName

Git Pull

improve the Reusability, Maintainability, and Flexibility of the TravelTest Automation Framework.

Task 1: Define Keywords for Actions 

Open the TravelTest Project

1

  • Launch Eclipse or IntelliJ IDEA.

  • Open the TravelTest automation project.

Create Excel File for Keywords

2

  • Create an Excel file named Keywords.xlsx.

  • Add columns such as:

 

TestCase

Keyword

Object

Value

  • Save the file inside the testdata folder.

Add Sample Keywords

3

  • Enter reusable action keywords in the Excel sheet.

Example

TestCaseKeywordObjectValue
LoginTestOpenBrowserChrome
LoginTestEnter TextUsernameadmin
LoginTestEnter TextPasswordPasss123
LoginTestClickLoginButton
LoginTestVerifyTitle Dashboard

Create a Keyword Class

4

  • Create a Java class named KeywordActions.

  • This class will contain reusable Selenium methods.

Example:

public class KeywordActions {

}

Define Browser Action Keyword

5

  • Create a method for opening the browser.

Example:

public void openBrowser() {

   driver = new ChromeDriver();

}

Define EnterText Keyword

6

Define Click Keyword

7

  • Create a reusable method for entering text.

Example:

public void enterText(By locator, String value)

{

   driver.findElement(locator).sendKeys(value);

}

  • Create a reusable click action method.

Example:

public void click(By locator)

 {

   driver.findElement(locator).click();

}

Define Validation Keyword

8

  • Create a method to validate application output.

Example:

public void verifyTitle(String expectedTitle)

 {

   Assert.assertEquals(driver.getTitle(), expectedTitle);

}

Save and Organize Keywords

9

  • Store all reusable methods inside the KeywordActions class.

  • Maintain proper naming conventions for keywords.

Execute Basic Keyword Actions

10

  • Run the script to verify all keyword methods work successfully.

  • Ensure actions perform correctly in the browser.

Task 1 : Map Keywords to Methods

Open the TravelTest Project

1

  • Launch Eclipse or IntelliJ IDEA.

  • Open the TravelTest automation project.

Prepare Keyword Excel File

2

  • Open the Keywords.xlsx file.

  • Ensure keywords are stored properly.

Example:

TestCaseKeywordObjectValue
LoginTestOpenBrowserChrome
LoginTestEnter TextUsernameadmin
LoginTestClickLogin Button

Create Keyword Action Class

3

Create Keyword Execution Class

4

  • Create a Java class named KeywordActions.

  • Add reusable Selenium methods for each keyword.

Example:

public void click(By locator) {

   driver.findElement(locator).click();

}

  • Create a new class named KeywordEngine.

  • This class will read keywords from Excel and execute corresponding methods.

Example:

public class KeywordEngine {

}

Read Keywords from Excel

5

  • Use Apache POI to read keyword values row by row.

Example:

String keyword = sheet.getRow(i).getCell(1).getStringCellValue();

 

 

Apply Conditional Mapping

6

  • Use if-else or switch statements to map keywords to methods.

Example:

if(keyword.equalsIgnoreCase("Click")) {

   action.click(locator);

}

OR

 

switch(keyword) {

case "OpenBrowser":

   action.openBrowser();

   break;

case "Click":

   action.click(locator);

   break;

}

Map EnterText Keyword

7

  • Connect the EnterText keyword with the corresponding Selenium method.

Example:

case "EnterText":

   action.enterText(locator, value);

   break;

Map Validation Keyword

8

Execute the Keyword Engine

9

Validate Execution

10

  • Connect validation keywords to assertion methods.

Example:

case "VerifyTitle":

   action.verifyTitle(value);

   break;

  • Run the KeywordEngine class.

  • Verify that keywords are executed sequentially from Excel.

  • Observe browser actions during execution.

  • Confirm that each keyword correctly triggers its mapped Selenium method

Task 2:  Execute Tests Using Keywords  

Open the TravelTest Project

1

  • Launch Eclipse or IntelliJ IDEA.

  • Open the TravelTest automation project.

Prepare Keyword Excel File

2

Open the Keyword Engine Class

3

  • Open the Keywords.xlsx file.

  • Verify all test steps and keywords are added properly.

​Example:

TestCaseKeywordObjectValue
LoginTestOpenBrowserChrome
LoginTestEnter TextUsernameadmin
LoginTestEnter TextPasswordPasss123
LoginTestClickLoginButton
LoginTestVerifyTitle Dashboard
  • Open the KeywordEngine class.

  • Ensure it reads keywords from Excel correctly.

Example:

String keyword = sheet.getRow(i).getCell(1).getStringCellValue();

Initialize Keyword Actions

4

  • Create an object of the KeywordActions class.

Example:

KeywordActions action = new KeywordActions();

Execute Keywords Sequentially

5

Map Keywords to Methods

6

  • Use loop statements to execute all keywords one by one.

Example:

for(int i=1; i<=rowCount; i++) {

}

 

 

  • Execute methods based on keyword values.

Example:

if(keyword.equalsIgnoreCase("Click")) {

   action.click(locator);

}

 

 

Execute Browser Actions

7

Run the Keyword Engine

8

  • Run actions such as:

    • OpenBrowser

    • EnterText

    • Click

    • VerifyTitle

  • Observe browser execution during runtime.

  • Right-click the KeywordEngine class.

          Run As → Java Application

OR

  • Execute through TestNG if configured.

Verify Test Execution

9

  • Open the login automation test class.

  • Locate the login test method.

Enter Test Data

4

  • Execute the parameterized script using data from Excel.

Example:

driver.findElement(By.id("username")).sendKeys(username);

 

driver.findElement(By.id("password")).sendKeys(password);

driver.findElement(By.id("login")).click();

 Capture Actual Output

5

  • Capture the application result after execution.

Example:

String actualTitle = driver.getTitle();

OR

String actualMessage = driver.findElement(By.id("message")).getText();

Define Expected Output

6

  • Store the expected result in a variable.

Example:

String expectedTitle = "Travel Dashboard";

Apply Validation Using Assertions

7

  • Compare actual and expected results using TestNG assertions.

Example:

Assert.assertEquals(actualTitle, expectedTitle);

OR

Assert.assertTrue(actualMessage.contains("Welcome"));

Execute the Test Script

8

  • Right-click the test class.

  • Select:

    • Run As → TestNG Test

Observe Validation Results

9

Check TestNG Report

10

  • Verify whether the test passes or fails.

  • Passed result indicates correct output validation.

  • Failed result indicates mismatch between expected and actual outputs.

  • Open the test-output folder.

  • Verify execution status and validation results in the TestNG report.

Repeat Validation for Multiple Data Sets

11

  • Execute the script with different Excel data records.

  • Validate outputs for all scenarios successfully.

 

Good Job!!

You have successfully completed your lab on TravelTest Data Driven Framework (DDF), where you learned how to read Test Data from Excel Files, parameterize Test Scripts using TestNG, execute multiple Data Sets, and validate Application Outputs efficiently.

You also understood how the Data Driven Framework improves Test Reusability, Maintainability, and Automation Efficiency.

Checkpoint

   Git Push

Next-Lab Preparation

git push origin branchName
  • Define keywords for actions
  • Map keywords to methods
  • Execute tests using keywords
  • Improve reusability

TravelTest Keyword Driven Framework (KDF)

By Content ITV

TravelTest Keyword Driven Framework (KDF)

  • 54