What Is Hybrid Framework In Selenium?

This Informative Tutorial Explains What is a Hybrid Framework, Uses and Components of Selenium Hybrid Driven Framework and How to Implement it:

What is a Hybrid Framework?

Hybrid Driven Framework is a combination of both the Data-Driven and Keyword-Driven framework.

Here, the keywords, as well as the test data, are externalized. Keywords are maintained in a separate Java class file and test data can be maintained either in a properties file/excel file/can use the data provider of a TestNG framework.

=> Check Here To See A-Z Of Selenium Training Tutorials Here.

Hybrid Framework In Selenium

Introduction To Hybrid Framework

Here is the Video Tutorial:

Hybrid Driven framework is mostly used by manual testers who don’t have much knowledge of programming languages. Such people can just have a look at the Keywords, Test data, Object repository and start creating the test case right away, without having to code anything in the framework.

Selenium frameworks


Components Of Hybrid Driven Framework

Components of the Hybrid Framework are similar to the components of the Keyword Driven Framework wherein every Test Data, as well as the Keywords, are externalized making the script appear in a more generalized form

  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

Hybrid Framework

#1) Function Library

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

For Example: Let us take an instance to automate the below test cases.

Test Case NoDescriptionTest StepsExpected Result
1Verify Amazon logo present 1. Enter URL - https://www.amazon.comAmazon logo should be displayed in home page
2Verify valid signIn 1. Enter URL - https://www.amazon.com
2. Click on 'SignIn' link
3. Enter valid Email
4. Click on continue
5. Enter Valid Password
6. Click on SignInButton
User Icon should be present in Homepage
3Invalid login1. Enter URL - https://www.amazon.com
2. Click on 'SignIn' link
3. Enter invalid Email
4. Click on continue
This error message should contain 'cannot find an account'

First, the test cases and its test steps are analyzed and its actions are noted down.

Say, in TC 01: Verify Amazon logo present- the user actions will be: Enter URL
In TC 02: Verify Valid SignIn- the user actions are Enter URL, Click, TypeIn
In TC03: Verify Invalid Login- the user actions are Enter URL, Click, TypeIn

Now, the library file will be created with Keywords defined for each action as below:


package Keywords.Defined;

import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class Keywords {
String path = System.getProperty("user.dir");
WebDriver driver; // driver object is declared
//method for entering URL – Keyword is ‘enter_URL’	
public void enter_URL(WebDriver driver,String TestData) throws IOException
//method for typing action – Keyword is ‘type’	
public void typeIn(WebDriver driver, String locatorValue, String locatorType, String testdata) 
//method for click action – Keyword is ‘click’	
public void click(WebDriver driver, String locatorValue, String locatorType) 

#2) Excel Sheet To Store Keywords

Keywords that are created in the library file are stored in an excel sheet with its description for anyone who uses this framework to understand.

#3) Design Test Case Template

A Test Case template is created for the framework. There is no specific template to follow. As per the Hybrid Framework, both Test data and Keywords should be externalized. So, a template is created accordingly. For example:

For Test case 2 – Verify valid SignIn

Test StepsLocator TypeLocator ValueTestDataAssertionTypeExpectedValue

Likewise, test steps are filled in for each test case in a separate sheet.

#4) Object Repository For Elements

A separate Repository is maintained for all elements on the webpage. Each WebElement is referred with a name followed by its value in an Object Repository (in this case, it is a properties file). Test Case template will hold the Object Name and its value is taken from the Repository as below:

Object Name

Here, LoginLink is the name of the object and its value is read from OR.properties as ‘//div[contains(@id,’ SignIn’)]

Accordingly, code to read the value from ObjectRepository will be included in the script Keywords.java

For Example Library file: consider ‘click’ action in Keywords.java

public class Keywords {
public void click(WebDriver driver, String ObjectName, String locatorType) 
throws IOException{
		driver.findElement(this.getObject(ObjectName, locatorType)).click();
	By getObject(String ObjectName, String locatorType) throws 
//Object Repository is opened		
File file = new File(path+"\\Externals\\Object Repository.properties");
FileInputStream fileInput = new FileInputStream(file);
//Properties file is read	 
Properties prop = new Properties();
//find by xpath
	  return By.xpath(prop.getProperty(ObjectName)); 
// ObjectName is read and its value is returned
//find by class
else if(locatorType.equalsIgnoreCase("ID")){
	   return By.Id(prop.getProperty(ObjectName));
// ObjectName is read and its value is returned

//find by name
else if(locatorType.equalsIgnoreCase("NAME")){
	   return By.name(prop.getProperty(ObjectName));
// ObjectName is read and its value is returned

return null;

Object Repository For Test Data In Test Cases

Let me show you a simple example of how all test data involved in the script are externalized, having the framework more generalized.

  • Externalizing Test Data from Test case Template:

Externalising Test Data from Test case Template

Similarly, test data is also read from the properties file.

  • Object Repository for test data in general script

Other general data like Browser name, executable driver location, test case filename, etc can also be externalized in a separate repository.

Object Repository for test data in general script

In the above example, the browser parameter is externalized in a properties file – Basic.properties.

  • Passing Test Data from TestNG Suite:

TestData can be also be passed from a suite file of TestNG to the method.

We use a tag called <parameter> in the TestNG.xml file just above the class where it is used.

Syntax: <parameter name = “any_name” value=”value_to_be_passed”/>

Once the testing suite is specified with the parameter name and its value, annotations are used in the script to specify which method uses the value. This is specified using the @Parameters annotation.

Syntax: @Parameters({“value_to_be_passed”})

Passing Test Data from TestNG Suite1

Multiple parameters can also be passed to a method as:

Syntax :

<parameter name = “Browser” value=”Chrome”/>
	<parameter name = “SheetName” value=”TestCase.xls”/>
<parameter name = “DriverLocation” value=”chromedriver.exe”/>
			<class name= “com.automation.Amazon”/>
 @Parameters({“Chrome”}, {“ TestCase.xls”}, {“ chromedriver.exe”})
public void init(String Browser, String SheetName, String DriverLocation){

Note that this doesn’t refer to multiple values of the same parameter, it only takes multiple values of different parameters.

#5) Driver Script

This contains the main logic to read all the test cases from the test case template excel sheet and performs the corresponding action by reading from the library file. The script is designed based on the test case template created.


Thus, a Hybrid Framework can be created and used to automate any application. This, in turn, will reduce the man-hours spent in scripting the automation code, since a framework once created can be used to automate multiple applications.

Similarly, frameworks can be created according to the project needs and used for automation purposes.

We hope you enjoyed the series of informative tutorials on Selenium!

=> Check ALL Selenium Tutorials Here.