Keyword Driven Framework for Selenium
On This Page What is Keyword Driven Framework?April 03, 2026 · 11 min read · Tool Comparison
A Keyword Driven Framework for Selenium allows testers to separate test case logic from the code, making it easy to automate and sustain tests. Keyword Driven Framework allows testers to compose test using a set of predefined keywords, enable them to express test cases in a natural language format. This model enhances reusability, scalability, and readability, making it ideal for large-scale testing projects. Components of Keyword Driven Framework: The article explores the conception, benefits, factor, and implementation of a Keyword Driven Framework in Selenium, along with its conflict from Data Driven Framework. The keyword-driven framework is based on keywords that form the basis of the functionality, direct in parameters, and throw the relevant output. When the code has to continue a lot of functionality, it might need repetitive composition for some section. Thus, keywords are written to pinch the complexity of the code. Read More: A Keyword Driven Framework in Selenium is an automation framework where test cases are created employ a set of predefined keywords, representing action like & # 8220; pawl, & # 8221; & # 8220; enter text, & # 8221; or & # 8220; verify. & # 8221; These keywords are map to corresponding Selenium commands, allowing tester to design tests in a more readable and perceivable format. This approach separates the test logic from the code, making test conception and maintenance more efficient. Here ’ s a process flow to understand how it works. Keyword-Driven Testing, or Keyword-Driven Testing Framework or simply Keyword Testing is a test mechanization framework that abstracts the technical details of test implementation and allow testers to make and cope test using a more user-friendly and business-oriented language. Tests are correspond using a sequence of keywords, where each keyword equate to a specific activity or operation to be performed on the covering under test. These keywords are delineate in a library or repository, and examiner use them to create test cases by combining keywords in a meaningful sequence. Read More: Keyword driven prove addresses common challenges in test automation by providing a structured approach that separates test design from automation implementation. The following are the benefit: To further raise your Keyword-Driven Testing procedure, consider using BrowserStack Automate. It allows seamless cross-browser testing on real device and browser, ensuring that your keyword-driven tests act cleanly across various environments. Automate your Selenium handwriting with BrowserStack to achieve fast test executing, greater reliability, and comprehensive test reporting. The next outlines the advantages and disadvantages of using a Keyword Driven Testing Framework, providing perceptiveness into its forcefulness and potential restriction. SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. The benefits are evident enough to evidence the mettle of Keyword Driven Framework in Selenium. Testers can overcome many challenges while habituate other fabric approaches utilise Keyword Driven Framework in Selenium. The components of a Keyword Driven Framework include essential elements that work together to enable efficient and structured test mechanisation. Read More: Here is a simple plan of a keyword-driven framework using a scenario that automates the end-to-end flowing of a web application. Frameworks in help tell the codification and the information to help maintain test cases. Frameworks supporter make the code reusable, readable, and reduce the toll of maintenance. This section will explore a Keyword Driven Testing Framework use. Let ’ s create a simple design of a keyword-driven framework with the helper of a scenario. The scenario will automate the end-to-end flow of a web application. Scenarios to be automatise: Prerequisites: Step 1: To design a Keyword Driven Framework, first identify all the actions to be performed for automated examination of an application. In the above scenario, seven step feature to be completed. Step 2: Once all actions are identified, the next stride is to create a keyword map table in the Excel sheet. Keyword map table is a table in an Excel sheet that defines all the keywords available for examination automation projects. The table below present the keyword map table for the above scenario Step 3: Once all keywords have been identified, the next step is to place the Excel sheet in the task package. Create a packet named ‘ excelData ’ by right-clicking on the Project. For this, go to New & gt; Package. Place the newly created Excel file in the bundle directory locally on the computer. The package structure of the keyword-driven framework can be seen in the screenshot below. This structure is highly urge as it is easygoing to understand, use, and maintain. Read More: Step 4: Create a new package identify “utility”. Now, create a new class file named “Constants” in which the tester will define constant likeURL, filePath, and excelData. Source codification look as below: Step 5:Now, write code for each action keyword. Create a new package named “keywordDriven”. Create a new class file named “Action_Keyword”. In this class, create methods for each Action Keyword identified in Excel. Step 6:Write codification to say data from an Excel sheet in this step. For this, use an Apache POI library, which let tester to say, create, and edit Microsoft Office documents using Java. Create a new package named “excelUtility” and then create a new class file named “ReadExcelSheet”. Look at the following source code to read all keywords from the step table. Step 7: Next footstep is to write code for callingreadExcelData () method of ReadExcelSheetclass and methods ofActionKeywordsclass. Create a new package name “executionEngine” and write the following rootage code by create a category nominate “ExecutionTest”. Observe the output by fulfil the code: A more advanced keyword-driven fabric would involve data-driven capabilities, better error treatment, and more modular test scenarios and keyword organization. Overall, we can reason that Keyword-Driven Testing aims to improve the efficiency and effectivity of software screen by providing a integrated, reclaimable, and maintainable approach to screen automation. A Keyword Driven Framework for Selenium offers a structured and effective approach to test automation by separating tryout logic from codification. It raise readability, reusability, and scalability, making it suitable for both technical and non-technical teams. While it comes with its own set of challenge, such as maintaining a orotund set of keywords, its benefits in improving quislingism and simplifying test creation make it a knock-down tool for automating web application testing. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.Keyword Driven Framework for Selenium
Overview
What is Keyword Driven Framework?
What is a Keyword Driven Framework in Selenium?
What is Keyword Driven Testing?
Why perform Keyword Driven Testing?
Tools Used for Keyword Driven Testing
Advantages And Disadvantages of Keyword Driven Testing Framework
Advantages Disadvantages Code Reusability Keyword Management Platform sovereign Test Scripts Extensive Planning Enhanced Productivity Expertise demand to pen test scripts Application abstraction Time taken to write test handwriting is high than common Components of a Keyword Driven Framework
Keyword Driven Framework Using Selenium WebDriver
& lt;? xml version= '' 1.0 '' encoding= '' UTF-8 ''? & gt; & lt; labor xmlns= '' http: //maven.apache.org/POM/4.0.0 '' xmlns: xsi= '' http: //www.w3.org/2001/XMLSchema-instance '' xsi: schemaLocation= '' http: //maven.apache.org/POM/4.0.0 http: //maven.apache.org/xsd/maven-4.0.0.xsd '' & gt; & lt; modelVersion & gt; 4.0.0 & lt; /modelVersion & gt; & lt; groupId & gt; com.keyword_driven_framework & lt; /groupId & gt; & lt; artifactId & gt; keyword_driven_framework & lt; /artifactId & gt; & lt; version & gt; 1.0-SNAPSHOT & lt; /version & gt; & lt; property & gt; & lt; maven.compiler.source & gt; 1.8 & lt; /maven.compiler.source & gt; & lt; maven.compiler.target & gt; 1.8 & lt; /maven.compiler.target & gt; & lt; /properties & gt; & lt; dependencies & gt; & lt;! -- Other dependencies, if any -- & gt; & lt;! -- Selenium WebDriver -- & gt; & lt; colony & gt; & lt; groupId & gt; org.seleniumhq.selenium & lt; /groupId & gt; & lt; artifactId & gt; selenium-java & lt; /artifactId & gt; & lt; version & gt; 4.0.0 & lt; /version & gt; & lt;! -- Replace with the late variant available -- & gt; & lt; /dependency & gt; & lt; dependency & gt; & lt; groupId & gt; io.github.bonigarcia & lt; /groupId & gt; & lt; artifactId & gt; webdrivermanager & lt; /artifactId & gt; & lt; version & gt; 5.3.1 & lt; /version & gt; & lt;! -- Use the latest version usable -- & gt; & lt; /dependency & gt; & lt; dependency & gt; & lt; groupId & gt; org.apache.poi & lt; /groupId & gt; & lt; artifactId & gt; poi-ooxml & lt; /artifactId & gt; & lt; version & gt; 3.11 & lt; /version & gt; & lt; /dependency & gt; & lt; /dependencies & gt; & lt; /project & gt;
package com.keyword_driven_framework.utility; public class Constants {public static final String URL = `` https: //bstackdemo.com/ ''; //Mention the route to your excel file public static final String filePath = `` D: \\DemoFile.xlsx ''; public static final String excelData = `` DemoFile.xlsx ''; public static final String username = `` Your_Username ''; public static concluding String watchword = `` Your_password '';}package com.keyword_driven_framework.keywordDriven; import java.time.Duration; import org.openqa.selenium.By; importation 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 {public static WebDriver driver; public void openBrowser () {System.setProperty (`` webdriver.gecko.driver '', '' path_to_driver ''); FirefoxOptions options = new FirefoxOptions (); WebDriver driver = new FirefoxDriver (options); driver.manage () .window () .maximize ();} public void navigate () {driver.manage () .timeouts () .implicitlyWait (Duration.ofSeconds (10)); driver.get (Constants.URL);} public void clickSignIn_h () {driver.findElement (By.xpath (`` //a [@ id='signin '] '')) .click ();} public void enterEmail () {driver.findElement (By.xpath (`` (//div [@ class= ' css-1wa3eu0-placeholder ']) [1] '')) .sendKeys (Constants.username);} public nihility enterPassword () {driver.findElement (By.xpath (`` (//div [@ class= ' css-1wa3eu0-placeholder ']) [2] '')) .sendKeys (Constants.password);} public null clickSignIn () {driver.findElement (By.xpath (`` //button [@ id='login-btn '] '')) .click ();} public null verifyUserName () {String username =new String (`` your_username ''); username.equals (driver.findElement (By.xpath (`` //span [@ class='username '] '')));} public void logout () {driver.findElement (By.xpath (`` //a [@ id='logout '] '')) .click ();} public void verifySignBtn () {String signIn =new String (`` Sign In ''); signIn.equals (driver.findElement (By.xpath (`` //a [@ id='signin '] '')));} public void closeBrowser () {driver.quit ();}}package com.keyword_driven_framework.excelUtility; import java.io.File; import java.io.FileInputStream; meaning java.io.IOException; import java.util.ArrayList; importation java.util.Iterator; significance org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; importee org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; importation com.keyword_driven_framework.utility.Constants; public class ReadExcelSheet {public ArrayList readExcelData (int colNo) throws IOException {String filePath = Constants.filePath; File file = new File (filePath); // Create an object of FileInputStream class and pass file as argument to its builder. FileInputStream fis = new FileInputStream (file); XSSFWorkbook wb = new XSSFWorkbook (fis); XSSFSheet sheet = wb.getSheet (`` Sheet1 ''); Iterator row = sheet.rowIterator (); row.next (); ArrayList & lt; String & gt; a = new ArrayList (); // Checking the future element availableness using the reference varying row. while (row.hasNext ()) {Row r = (Row) row.next (); // Moving cursor to the cell by acquire a cell number. Cell c = r.getCell (colNo); String data = c.getStringCellValue (); a.add (data); a.add (((Row) row.next ()) .getCell (colNo) .getStringCellValue ());} System.out.println (`` List: `` +a); // Return the datum to the Arraylist method. regress a;} public void DemoFile (int i) {// TODO Auto-generated method nub}}package com.keyword_driven_framework.executionEngine; signification java.io.IOException; import java.lang.reflect.InvocationTargetException; import com.keyword_driven_framework.excelUtility.ReadExcelSheet; import com.keyword_driven_framework.keywordDriven.Action_keyword; public class ExecutionTest {public inactive void main (String [] args) throws IOException, Exception, IllegalArgumentException, InvocationTargetException {ReadExcelSheet rs = new ReadExcelSheet (); rs.DemoFile (4); Action_keyword k = new Action_keyword (); k.openBrowser (); k.navigate (); k.clickSignIn_h (); k.enterEmail (); k.enterPassword (); k.clickSignIn (); k.verifyUserName (); k.logout (); k.verifySignBtn (); k.closeBrowser (); System.out.println (`` Test executed successfully '');}}Difference Between Data Driven And Keyword Driven Framework
Keyword Driven Framework Data Driven Framework Easy to maintain due to more generalisation layers between trial scripts, test data, keywords, etc. Comparatively harder to conserve since the generalisation is only between tryout data and test scripts Planning has to be extensive and precise for keyword driven fabric Planning is easy since it is only needed for tryout information and test scripts It is possible to write test scripts even before the production has finished development stage One has to look for development to finish before writing test cases Conclusion
Related Guides
Automate This With SUSA
Test Your App Autonomously