Hybrid Framework in Selenium

On This Page What is Hybrid Framework in Selenium?May 25, 2026 · 7 min read · Tool Comparison

Hybrid Framework in Selenium

The Selenium Framework is basically code structure that makes codification maintenance easy and efficient. Without fabric, users may place the code at some location which is not reusable or decipherable. Using frameworks Pb to increased codification reusability, higher portability, reduced cost of script maintenance, better code readability, etc. The Hybrid framework in Selenium offers these reward by serve as a combination of both Keyword-Driven Framework and Data-Driven fabric.

Overview

What Is a Hybrid Framework?

  • It is a blend of keyword-driven, data-driven, and script-driven concepts.
  • It enables examiner to prefer the best approach for each test case.

Structure & amp; Components

  • Function Library
  • Excel Sheet to store Keywords
  • Design Test Case Template
  • Object Repository for Elements/Locators
  • Test Scripts or Driver Script

Benefits of Hybrid Approach

  • Flexibility: can conform to both simple and complex test scenarios.
  • Reusability: share components across tests.
  • Maintainability: changes in tests/data/components have less complexity.

This clause will discuss how to enforce the Hybrid framework in Selenium.

What is Hybrid Framework in Selenium?

Hybrid Driven Framework in Selenium is a mix of both the and.

In this case, the keywords as well as the trial information, are exteriorize. Keywords are store in a separate Java class file and test datum can be maintained in a Properties file or an Excel file.

Execution Flow of Hybrid Framework in Selenium

The diagram below depicts the architectural design of the Hybrid framework:

  1. Execution starts with reading the configuration file. This file will reveal the location and name of the remark file, as well as the fix of the output file. This is the test rooms
  2. The input file is an Excel sheet. It contains the first sheet as the Test Suite. The Test Suite sheet has four column:
    1. Name of the tryout case
    2. Run Flag (whether to execute respective test cases or not)
    3. Comments
    4. Run Status
  3. Name of the test case in the Test Suite sheet is the same as the name of the Test Case sheet
  4. Each test suit has 6 columns:
    1. Keyword
    2. Argument
    3. Comment
    4. Run Status
    5. Return value
  5. Each row in a test event sheet represents a test pace
  6. Comments are updated in the comment column if any trial step miscarry or is skipped with the proper intellect
  7. If a keyword returns some value, then that is update in the Return value column
  8. Each step is executed in the serial column. If one or more steps fail in a tryout case, the corresponding test case is also marked FAIL in the examination entourage
  9. Once all the test cases of a trial suite are executed, and the comparable status is update in both sheet, a result file with a new name (timestamp appended) is saved in the Result leaflet
  10. Logs and screenshots are saved in the Output folder

Executing Hybrid Framework in Selenium

Components of the Hybrid Framework in Selenium are like to those of the Keyword Driven Framework wherein all Test Data and Keywords are externalise, thus creating scripts in a more generalized form.

If you compare test case execution, the Hybrid framework in Selenium is almost the same as its Keyword-Driven counterpart with exclusively a mates of changes ask.

Components of Hybrid Framework in Selenium are as follows:

  1. Function Library
  2. Excel Sheet to store Keywords
  3. Design Test Case Template
  4. Object Repository for Elements/Locators
  5. Test Scripts or Driver Script

1. Function Library

User-defined method are created for each user action. In other words, keywords are created in the library file.

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

As an example let ’ s automate the test suit below:

Test Case NoDescriptionTest StepsExpected Result
1Verify Browserstack logotype1. Enter URL – https: //www.browserstack.comBrowserStack logo should be displayed in home page
2Verify valid signIn1. Enter URL – https: //www.browserstack.com

2. Click on ‘ SignIn ’ link

3. Enter valid Email

4. Enter Valid Password

5. Click on SignInButton

Login should be successful
3Invalid login1. Enter URL – https: //www.browserstack.com

2. Click on ‘ SignIn ’ linkup

3. Enter invalid Email

4. Click on continue

This error message should contain ‘ can not find an account ’

2. Excel Sheet to store Keywords

Keywords that we created in the library file are stored in an Excel sheet with description. This help user to understand the framework and its components.

Read More:

3. Test Case Design Template

For the model to function, one must create a Test Case template. Both Test Data and Keywords should be externalized in Hybrid Framework, and the templet needs to be created consequently.

4. Object Repository for Elements

For all the web elements, users must maintain a separate Repository. Each WebElement is referred to with a name postdate by its value. The Test Case guide will hold the Object Name and the Repository value.

First, let ’ s create a library file for Keywords.

package Keywords; importee java.io.File; import java.io.FileInputStream; signification java.io.IOException; importation java.util.Properties; import org.openqa.selenium.By; meaning org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; significance org.openqa.selenium.support.ui.WebDriverWait; public class Keywords {public void click (WebDriver driver, String ObjectName, String typeLocator) throws IOException {driver.findElement (this.getObject (ObjectName, typeLocator)) .click ();} By getObject (String ObjectName, String typeLocator) throws IOException {//Object Repository is opened File file = new File (path+ '' \\Externals\\Object Repository.properties ''); FileInputStream fileInput = new FileInputStream (file); //Properties file is read Properties shore = new Properties (); if (typeLocator.equalsIgnoreCase (`` XPATH '')) {return By.xpath (prop.getProperty (ObjectName)); // ObjectName is say and its value is returned} else if (typeLocator.equalsIgnoreCase (`` ID '')) {return By.id (prop.getProperty (ObjectName)); // ObjectName is read and its value is returned} else if (typeLocator.equalsIgnoreCase (`` NAME '')) {return By.name (prop.getProperty (ObjectName)); // ObjectName is say and its value is returned} return null;}}

Run Selenium Tests on Real Device Cloud for Free

5. Driver Script

Let ’ s now write the driver script. This control the main logic from the Test Case template Excel sheet. It will say all the Test Cases and perform corresponding actions by reading from the library file. The script is design based on the Test Case template created.

package HybridFramework; import java.lang.reflect.Method; public class DriverScript {public still Actions actionKeywords; public static String sActions; //This is reflection class object and declare as 'public static ' and it can //be habituate outside the main [] method public inactive Method method []; public static nihility independent (String [] args) throws Exception {//Declaring the path of the Excel file with the gens of the Excel file String sPath = `` Path to the exceldata.xlsx ''; ReadExcelData.setExcelFile (sPath, `` Sheet1 ''); for (int iRow=1; iRow & lt; =9; iRow++) {sActions = ReadExcelData.getCellData (iRow, 1); execute_Actions ();}} private static emptiness execute_Actions () throws Exception {actionKeywords = new Actions (); //It will load all the method of the class 'Actions ' in it. method = actionKeywords.getClass () .getMethods (); //It will run for the number of actions in the Action Keyword class for (int i = 0; i & lt; method.length; i++) {if (method [i] .getName () .equals (sActions)) {method [i] .invoke (actionKeywords); break;}}}}

Example: Test Case conception in Hybrid Framework using POM

Step 1: Create a class BrowserFactory

packet com.automation.utility; import org.openqa.selenium.WebDriver; public stratum BrowserFactory {public static WebDriver startApplication (WebDriver driver, String browserName, String appURL) {if (browserName.equals (“ chrome ”)) {System.setProperty (“ webDriver.chrome.driver ”, ” .Path of chrome driver ”); driver = new ChromeDriver (); driver.manage () .timeouts () .pageLoadTimeout (20, TimeUnit.SECONDS);} else if (browserName.equals (“ Firefox ”)) {System.setProperty (“ webDriver.gecko.driver ”, ” Path of driver ”); driver = new FirefoxDriver ();} else if (browserName.equals (“ IE ”)) {System.setProperty (“ webDriver.ie.driver ”, ” Path of driver ”); driver = new InternetExplorerDriver ();} else {System.out.println (“ Does not support this browser ”);} driver.manage () .timeouts () .pageLoadTimeout (20, TimeUnit.SECONDS); driver.manage () .window () .maximize (); driver.get (appURL); driver.manage () .timeouts () .implicitlyWait (30, TimeUnit.SECONDS); return driver;} public static void quitBrowser (WebDriver driver) {driver.quit ();}}

Step 2: Create a New Class LoginTestCRM

package com.automation.testcases; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.PageFactory; import org.testng.annotations.Test; signification com.automation.pages.LoginPage; import com.automation.utility.BrowserFactory; public class LoginTestCRM extends BaseClass {@ Test Public vacuum loginApp () {LoginPage loginpage = PageFactory.initElements (driver, LoginPage.class); loginPage.loginToCRM (“ Selenium ”, “ Password ”);}}

Step 3: Create a New Class LoginPage

software com.automation.pages; meaning org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; public form LoginPage {WebDriver driver; public LoginPage (WebDriver ldriver) {this.driver=ldriver;} @ FindBy (name= ” user [login] ”) WebElement uname; @ FindBy (name= ” user [password] ”) WebElement pass @ FindBy (name= ” commit ”) WebElement loginButton; Public void loginToCRM (String usernameApplication, String passwordApplication) {uname.sendKeys (xxx); pass.sendKeys (xxxxx); loginButton.click ();}}

Step 4: Create a course (BaseClass)

package com.automation.pages; importation org.openqa.selenium.WebDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import com.automation.utility.BrowserFactory; public class BaseClass {public WebDriver driver; @ BeforeClass public void setup () {driver= BrowserFactory.startApplication (driver, “ Chrome ”, “ https: //www.browserstack.com/users/sign_in ”);} @ AfterClass public nihility teardown () {BrowserFactory.quitBrowser (driver);}}

Right-click on theLoginTestCRMclass and run the covering.

Read More:

Try extend the code, and use the Hybrid framework inSeleniumfor more sophisticated test creation and execution. Bear in judgement that are better run on real browsers and devices, since only can not render the required for 100 % accurate test answer.

Run manual and automated tests on real browsers and devices. Start running test on 2000+ real browsers and device on BrowserStack ’ s. Run parallel tests on a to get fast results without compromise on accuracy. Detect bugs before users do by testing package in real cosmos circumstances with BrowserStack.

Run Selenium Tests on Cloud for Free

Tags
10,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

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