Hybrid Driven Framework

In this tutorial, we will design Hybrid driven framework using Selenium WebDriver. The Hybrid framework is one which has a flavour of Data Driven as well Keyword Driven. As discussed in earlier tutorials, Data Driven is one which is derived from external data (i.e. test data is kept in some external file like excel sheet or CSV file or Database, etc.), whereas Keyword Driven is one which has keyword driving the execution, say for example “openbrowser” is a keyword which will open a browser of your choice and perform required action.

PS: This tutorial is going to be a long post. Keep your Eclipse ready and design the framework along with it.

Let us first understand the flow of execution of the framework which we will be designing.

Architechture design of Hybrid Driven Framework:

Hybrid driven framework using Selenium WebDriver

Flow of Execution:

  1. Execution of the framework starts from reading the configuration file (config.properties). This file will give us the location of the Input file, name of the input file (AutomationInput.xlsx), and the location of the output File (Result file).
  2. Input file (AutomationInput.xlsx) file is an excel sheet; it contains the first sheet as Testsuite. Test suite sheet has four columns, 1. Name of the test case; 2. Run Flag (whether to execute respective test case or not); 3. Comments and 4. Run Status.
  3. Name of the test case in test suite sheet is same as the test case sheet name. There is one sheet corresponding to each test case.
  4. Each test case consists of 6 columns namely 1. Keyword; 2. Locator; 3. Argument; 4. Comment; 5. Run Status and 6. Return value.
  5. Each row in a test case sheet represents a test step.
  6. The first column will be a Keyword; a corresponding method is executed for each keyword. It may require a Locator or an Argument. If a keyword does not need a Locator or Argument, then those columns are kept empty.
  7. After execution of a test step, the result of the test step is updated with PASS/FAIL in Run Status field.
  8. Comments are updated in comment column if any test step fails or skipped with proper reason.
  9. If a keyword returns some value that is updated in Return value Column.
  10. Each step is executed in the the sequential column. If one or more step fails in a test case, its corresponding test case is also marked as FAIL in the test suite.
  11. Once all the test cases of a test suite are executed, and the corresponding status is updated in both sheets, a result file with a new name (timestamp appended) is saved in result folder.
  12. Logs and screenshots are also saved in the output folder.

Directory Structure of the Framework:

The framework we are designing will have below directory structure:

  • CommonLibs Directory
    • CommonDriver class file
      • This Class file consists of commonly used methods like OpenBrowser, CloseBrowser, SetPageLoadTimeot, SetElementDetectionTimeout, all possible actions like clickElement, setText, getText etc.
    • Utils Class
      • This class file consists of utility methods used in the framework like getProperties (reading data from a properties file) etc.
    • Excel Driver
      • This class file consists of methods which are required to read from an Excel Sheet, like CreateAWorkbook, OpenAnExcelSheet, getCellData, setCellData, etc.
    • Keyword Utility
      • This Keyword Utility
    • driver
      • Driver Class
  • Project Specific Directory
    • Page1 (POM design pattern)
    • Page2

This directory consists of class files – one class file for each page

  • Test cases
    • This directory consists of class files which have methods to test various scenarios.

Refer below screenshot for the same:

Directory Structure of Hybrid Framework

TestSuite Sheet:


Testcase 1:


CommonDriver Class File:

Utils Class File:

Excel Driver Class File:

Keyword Utility:

Driver Class File:

PS: For any questions queries or comment feel free to write us at saurabh@qatechhub.com or support@qatechhub.com. Happy Learning ?

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: