Hybrid Framework in Selenium
On This Page What is Hybrid Framework in Selenium?May 25, 2026 · 7 min read · Tool Comparison
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. What Is a Hybrid Framework? Structure & amp; Components Benefits of Hybrid Approach This clause will discuss how to enforce the 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. The diagram below depicts the architectural design of the Hybrid framework: 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: 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: 2. Click on ‘ SignIn ’ link 3. Enter valid Email 4. Enter Valid Password 5. Click on SignInButton 2. Click on ‘ SignIn ’ linkup 3. Enter invalid Email 4. Click on continue 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: 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. 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. Run Selenium Tests on Real Device Cloud for Free 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. Example: Test Case conception in Hybrid Framework using POM Step 1: Create a class BrowserFactory Step 2: Create a New Class LoginTestCRM Step 3: Create a New Class LoginPage Step 4: Create a course (BaseClass) 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. # 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.Hybrid Framework in Selenium
Overview
What is Hybrid Framework in Selenium?
Execution Flow of Hybrid Framework in Selenium
Executing Hybrid Framework in Selenium
1. Function Library
Test Case No Description Test Steps Expected Result 1 Verify Browserstack logotype 1. Enter URL – https: //www.browserstack.com BrowserStack logo should be displayed in home page 2 Verify valid signIn 1. Enter URL – https: //www.browserstack.com Login should be successful 3 Invalid login 1. Enter URL – https: //www.browserstack.com This error message should contain ‘ can not find an account ’ 2. Excel Sheet to store Keywords
3. Test Case Design Template
4. Object Repository for Elements
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;}}5. Driver Script
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;}}}}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 ();}}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 ”);}}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 ();}}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);}}Related Guides
Automate This With SUSA
Test Your App Autonomously