🎹Keyword Driven Framework
🔎 Understanding Keyword Driven Framework
A Keyword Driven Framework is a software testing framework that uses an external data source, such as an Excel file, to define keywords and actions that are used in the test script. The framework is designed to separate the test script from the test data and the actions that are performed during the test. This separation allows for greater code reusability, reduced script maintenance, and higher portability[1][2][4].
The Keyword Driven Framework has four main components:
Test data: The input data that is used to drive the test cases.
Test script: The code that is executed to perform the test cases.
Keyword repository: The external data source that defines the keywords and actions used in the test script.
Test execution engine: The software that executes the test script and manages the test data[2][4].
👨💻 Example Java Block for CNBC
Here's an example Java block for a Keyword Driven Framework that automates the end-to-end flow of the CNBC website:
This Java block automates the following actions:
Open the CNBC website.
Click on the "Sign In" link.
Enter the username and password.
Click on the "Login" button.
Search for a stock.
Click on the "Sign Out" link.
Close the browser.
The keywords and actions used in this example are:
Open browser:
driver.get("https://www.cnbc.com/");
Click:
driver.findElement(By.linkText("Sign In")).click();
Enter text:
driver.findElement(By.id("username-verification")).sendKeys("username");
Click button:
driver.findElement(By.id("login-button")).click();
Enter search text:
driver.findElement(By.id("header-search")).sendKeys("AAPL");
Click search button:
driver.findElement(By.id("header-search-button")).click();
Click link:
driver.findElement(By.linkText("Sign Out")).click();
Close browser:
driver.quit();
The keywords and actions could be defined in an external Excel file, and the Java block could be modified to read the keywords and actions from the file.
Excel Sheets
In a Keyword Driven Framework, an Excel sheet is used to store keywords that represent the actions to be performed in the test script. The Excel sheet serves as a central repository for the keywords and their associated test data. Here's how the Excel sheet is typically used in a Keyword Driven Framework:
Keyword Definition: The Excel sheet contains a column dedicated to defining the keywords. Each row represents a specific keyword that corresponds to a particular action or function in the test script. For example, keywords like "click", "type", "verify", etc., can be defined in the Excel sheet[2][4][6].
Test Data: Alongside the keywords, the Excel sheet also includes columns for test data. Test data represents the input values or parameters required for executing the corresponding keyword action. The test data can be specific values, variables, or references to external data sources. These values are used by the test script to perform the actions defined by the keywords[2][4][6].
Test Case Templates: The Excel sheet acts as a summary for the function library or function class. It becomes useful when creating test case templates. The user can refer to the Excel sheet to identify the available keywords and select the appropriate keyword for each action in the test case. The test case templates define the sequence of keywords and associated test data required to execute a specific test case[2].
Test Script Execution: The test script reads the keywords and test data from the Excel sheet to perform the corresponding actions. The test execution engine or the automation framework interprets the keywords and executes the associated functions or actions defined in the function library. The test script uses the test data from the Excel sheet as inputs for the actions performed during the test execution[1][4][6].
By storing the keywords and test data in an Excel sheet, the Keyword Driven Framework provides a flexible and easily maintainable approach to automation testing. It allows for easy modification and customization of test cases without the need to modify the underlying code. Testers can update the test data and keywords in the Excel sheet, enabling quick changes to the test script behavior[1][2][4][6].
It's important to note that the specific format and structure of the Excel sheet may vary depending on the implementation and requirements of the Keyword Driven Framework. The examples provided in the search results demonstrate different approaches to using an Excel sheet for storing keywords and test data.
Last updated