Hybrid Framework
Hybrid Driven Framework is an ideal framework for manual testers who have no programming knowledge. This concept takes advantage of the Keyword-driven framework and the Information-driven framework.
Ingredients
JAVA, Selenium, IDE (any)
Directions
# Sauté Keywords
publicclass Keywords {
publicvoidclick(RemoteWebDriverdriver, String ObjectName, String locatorType)
throwsIOException, InterruptedException{
Thread.sleep(1000);
try {
driver.findElement(this.getObject(ObjectName, locatorType)).click();
}catch (Exception e) {
//
}
}
publicvoidenter(RemoteWebDriverdriver, String ObjectName, String locatorType, String value) throwsInterruptedException {
Thread.sleep(1000);
try {
WebDriverWaitwebDriverWait = newWebDriverWait(driver, 20);
webDriverWait.until(ExpectedConditions.elementToBeClickable(this.getObject(ObjectName, locatorType)));
driver.findElement(this.getObject(ObjectName, locatorType)).click();
new Actions(driver).sendKeys(value).build().perform();
} catch (Exception e) {
//
}
}
publicvoidassertion(RemoteWebDriverdriver, String ObjectName, String locatorType, String Expected, String value) throwsInterruptedException, IOException {
booleanpresent = false;
try {
WebDriverWaitwebDriverWait = newWebDriverWait(driver, 20);
webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(this.getObject(ObjectName, locatorType)));
if (driver.findElement(this.getObject(ObjectName, locatorType)).getText().contains(value))
present = true;
}
catch (Exception e) {
//
}
if(Expected.contains("true"))
Assert.assertTrue(present);
elseAssert.assertFalse(present);
}
By getObject(String ObjectName, String locatorType) throws
IOException{
//Object Repository is opened
File file = newFile(Path.CONFIG_OR_FILE_PATH);
FileInputStreamfileInput = newFileInputStream(file);
Read Also:- Key Benefits of Test Driven Development (TDD)
//Properties file is read
Properties prop = newProperties();
prop.load(fileInput);
//find by xpath
if(locatorType.equalsIgnoreCase("XPATH")){
returnBy.xpath(prop.getProperty(ObjectName));
}
//find by class
elseif(locatorType.equalsIgnoreCase("ID")){
return By.id(prop.getProperty(ObjectName));
}
//find by name
elseif(locatorType.equalsIgnoreCase("NAME")){
return By.name(prop.getProperty(ObjectName));
}else {
}
return null;
}
}
#Assemble Steps
public class Steps {
Keywords keyword = newKeywords();
publicvoidperform(RemoteWebDriverdriver,Stringoperation, String objectName, String typeLocator,Stringexpected, String testdata) throwsInterruptedException, IOException {
switch (operation) {
case"Enter_URL":
driver.get(testdata);
break;
case"Enter":
keyword.enter(driver, objectName, typeLocator, testdata);
case"Click":
keyword.click(driver, objectName, typeLocator);
default:
break;
}
if(operation.contains("AssertElement")){
–– keyword.assertion(driver,objectName, typeLocator, expected, testdata);
}
}
}
Read Also:- Robot Automation Framework and Features
# Mix and Serve
publicvoidExecuteStepsFromExcel(RemoteWebDriverdriver, intcount) throwsInterruptedException, IOException {
File file = newFile(filePath + File.separator + fileName);
String value = null;
FileInputStreaminputStream;
Workbook workbook = null;
try {
inputStream = newFileInputStream(file);
workbook = WorkbookFactory.create(inputStream);
} catch (Exception e) {
}
Sheet worksheet = workbook.getSheet(readSuiteNameUsingKeyFromExcel().get(count));
Row firstRow = worksheet.getRow(0);
introw = worksheet.getLastRowNum();
intcolumn = worksheet.getRow(1).getLastCellNum();
String Testdata = null;
for (inti = 1; i<= row; i++) {
LinkedList<String>Testexecution = new LinkedList<>();
for (intj = 0; j<column; j++) {
Cell Criteria = worksheet.getRow(i).getCell(j);
String CriteriaText;
if (Criteria == null) {
CriteriaText = null;
} else {
CriteriaText = Criteria.getStringCellValue();
}
Testexecution.add(CriteriaText);
Cell cell = worksheet.getRow(i).getCell(j);
switch (cell.getCellType()) {
caseCell.CELL_TYPE_STRING:
value = cell.getRichStringCellValue().getString();
break;
caseCell.CELL_TYPE_NUMERIC:
value = Integer.toString(((int) cell.getNumericCellValue()));
break;
caseCell.CELL_TYPE_BLANK:
value = "";
break;
}
}
String Keyword = Testexecution.get(0);
String TypeLocator = Testexecution.get(1);
String ObjectName = Testexecution.get(2);
String Expected = Testexecution.get(3);
String Testdata = Testexecution.get(4);
if (i==1) {
if(!Testdata.isBlank())
step.perform(driver, Keyword, ObjectName, TypeLocator, Expected, Testdata);
} elseif (i> 1) {
step.perform(driver, Keyword, ObjectName, TypeLocator, Expected, Testdata);
}
System.out.println("Row" + i + " is read and action performed");
}
System.out.println("****TEST CASE " + worksheet.getSheetName() + " is executed*****");
}
Read Also:- Ultimate Guide On Behavior Driven Development Testing
Stir Excel
# RoastTestcase

# Garnish Keywords
Expert Tips
- Use Maven for dependencies
- Choose TestNG for reports
FAQs
- What is a hybrid framework in Selenium?
A hybrid framework in Selenium is a testing framework that combines elements from multiple types of testing frameworks. Hybrid frameworks typically use a combination of keyword-driven testing and data-driven testing to create a flexible and efficient testing strategy.
- What is a keyword-driven framework in Selenium?
A keyword-driven framework in Selenium is a testing framework that uses a set of predefined keywords or actions to execute tests. Keyword-driven frameworks are typically easy to maintain and can be used by testers with limited programming knowledge.
- What is a data-driven framework in Selenium?
A data-driven framework in Selenium is a testing framework that separates the test data from the test logic. In this type of framework, test data is stored in a separate file or database, and is accessed by the test script as needed.
- How does a hybrid framework in Selenium work?
A hybrid framework in Selenium combines the benefits of both keyword-driven testing and data-driven testing. These blocks of code are then called by the test script and executed with different sets of data as needed.
- What are the benefits of using a hybrid framework in Selenium?
There are several benefits of using a hybrid framework in Selenium, including:
- Flexibility
- Reusability
- Maintainability
- Ease of use
Related Articles

