Testing With Selenium WebDriver (73 Blogs) Become a Certified Professional
AWS Global Infrastructure

Software Testing

Topics Covered
  • Testing With Selenium WebDriver (63 Blogs)

Test Automation Frameworks: How to Build a Framework in Selenium?

Last updated on Aug 08,2023 7.1K Views

Every business runs on software and all the software needs to be tested before it is released to users. Automation software testing is vital to release efficient, effective and reliable software at a rapid pace. For that, you need automation frameworks. Automation frameworks allow testers with less experience to manage sophisticated testing on shorter development cycles. In this Test Automation Frameworks article, let’s explore more about the concept of testing frameworks. You can get a better understanding of test automation from the Automation Engineer Certification.

Let’s take a look at the topics covered in this Test Automation Frameworks article:

You can go through this Automation Testing video lecture where our Software Testing Training expert is discussing every nitty gritty of the technology.

Test Automation Using Python | Selenium Webdriver Tutorial With Python

This video will teach you the basics of Selenium with Python.

What is a Test Automation Framework?

A test automation framework is a comprehensive set of guidelines and rules created to make test automation efficient and effective. A framework is comprised of a combination of test tools and practices that are designed to help QA specialist test more efficiently.

Test Automation Frameworks are an essential part of any successful automated testing process. A framework allows testers with less experience to manage sophisticated testing on shorter development cycles. Frameworks incorporate components such as:

  • Coding standards
  • Test data handling
  • Object repository treatments
  • Log configurations
  • Rules for writing test cases
  • Test results and reporting practices

Benefits of a Test Automation Framework

Consider a simple scenario. Let’s say you are working in a testing team comprising of 5 members. Now, if each one of you uses your own technique to write the automation script, it will lead to a divergent style of coding. Moreover, the entire team may not be able to leverage common pieces of code and scripts. This is where test automation frameworks come into the picture. 

So, with an automation framework you can:

  • Establish a universal standard for testers
  • Fasten the test progress
  • Maintain the test code easily
  • Eliminate the human error
  • Test the application effectively
  • Achieve continuous testing and delivery
  • Save time, effort and money

Use of an automation framework in any project leads to the following advantages:

Benefits of framework - Test Automation Framework - Edureka

So, technically test automation frameworks, when designed and implemented correctly, deliver frequent and stable automated test code. There are different types of frameworks. Now lets’ look at what each framework is built to accomplish, along with their pros and cons.

Find out our Automation Testing Training in Top Cities/Countries

IndiaUSAOther Cities/Countries
BangaloreNew YorkUK

Different types of Test Automation Frameworks

There are several types of test automation frameworks that you can use for different types of testing scenarios. It’s important to choose the framework that is right for you. The 6 primary test automation frameworks we’ll be exploring are: 

Linear Automation Framework

It is a basic level test automation framework which is in the form of ‘Record and Playback’ in a linear fashion. In this type of framework, creation and execution of test script are done individually for each test case individually. The tester records each step such as navigation, user input, or checkpoints, and then plays the script to automatically conduct the test from the beginning in sequential order. This type of framework is mostly used to test small sized applications.


  • Expertise in test automation is not necessary
  • Test workflow is easier to understand for any party involved in testing
  • One of the fastest way to generate test scripts


  • The scripts developed using this framework aren’t reusable
  • Maintainance is a hassle because any changes to the application will require a lot of rework

Data-Driven Framework

While automating or testing any application, at times you might to test the same functionality multiple times with the different set of input data. In such cases, we can’t embed test data in the test script itself. Data Driven Testing Framework helps the user segregate the test script logic and the test data from each other. The test data is kept in the external storages resources such as MS Excel Sheets, MS Access Tables, SQL Database, XML files etc.


  • Test cases can be executed with multiple sets of data
  • Changes to the scripts do not affect test data
  • You will save a lot of time by executing tests faster


  • Setting up a data-driven framework takes a significant amount of time
  • You’ll need high technical expertise, proficiency in various programming languages to write these scripts

Keyword-Driven Framework

This framework is an extension of the data-driven testing framework in some ways. It not only segregates the test data from the scripts, but it also keeps a certain set of code belonging to the test script into an external data file. Here we use a table format to define keywords or action words for each method that we would execute. Once the table has been set up, all you have to do is write the code that will trigger the necessary action based on the keywords.


  • Minimal scripting knowledge is required
  • Provides hight code reusability
  • Test scripts can be written independent of the software under test


  • The initial investment of setting up framework is high
  • High-level technical expertise is needed

Modular Testing Framework

This framework is based on one of the popularly known OOPs concept – Abstraction. The testers divide the entire application into a number of logical and isolated modules. After that, a test script is created for each part and they are combined to build larger tests in a hierarchical fashion.


  • Any changes made in individual sections of the module won’t affect the overarching module
  • Creating and maintenance of test cases is easier because test scripts for different modules can be reused


  • You can’t use this method for multiple data sets, because data is still hard-coded into the test script
  • Efficiency in programming languages is required to set up the framework

Library Architecture Testing Framework

This framework is slightly based on the modular framework, except has some extra benefits. Instead of dividing the application into test scripts, we divide the application into common functions that can be used by the other parts of the application as well. These functions are then kept in a library which can be referred to by the test scripts whenever needed.


  • Test case maintenance and scalability is much easier and cost-effective
  • Common functions can be called upon multiple test scripts so this framework has a high degree of re-usability


  • Test scripts need more time to develop
  • High-level technical expertise is needed
  • Any changes to the data will require changes to the scripts because the data is hard-coded into the test script

Hybrid Testing Framework

As the name suggests, the Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks. The best thing about this framework is it can be customized to your specific needs and requirements. You can pick and choose the capabilities of each framework that you want that suits your requirements.

So, these are some most widely used test automation frameworks. How a company chooses among them is ultimately determined by its requirement and testing team’s expertise to the right automation tools. Now let’s see how to build a simple data-driven framework using selenium.


Building a Data-Driven Framework using Selenium

selenium - Test Automation Framework - Edureka Demand for web development and software testing is huge. As a result, a lot of tools are being released into the market and competition is much stronger than ever. But so far, no one has outshone Selenium in terms of popularity and use. The biggest sweet spot of Selenium is the fact that it is completely free to download and use. Testers can craft their tests in many programming languages, including Java, C#, Python, etc.

Now before we get started with the demo let’s check out the steps that you follow to generate a framework using Selenium:

Step 1: The first step is to select a programming language. In the Selenium world, you have a wide range of programming languages to choose from such as Java, C#, Ruby, Python, etc. In my opinion, Java is a good choice because it is widely adopted and cross-platform.

Step 2: Next you choose a unit test framework. It helps to mark a method as part of the test using annotations, generate logs, execute test cases from IDE, executes tests in parallel. For example, you could use TestNG as it offers a lot of benefits.

Step 3: Next design the framework architecture according to your needs. Make sure you come with a come up with a sustainable, maintainable, and scalable architecture. Now based on the architecture start building your test modules.

Step 4: Next step is to choose a recording mechanism. With a proper recording mechanism reading and analyzing test results will be easier.

Step 5: Lastly, if needed you can integrate your framework with other tools. For example, TestRail is a test case management (TCM) system that can be used when your project has a large number of tests and related work items such as bugs. Similarly, Jira integration.

Let’s get started with the demo. So, in this demo, I have two files:

  • One has code for testing the login functionality of a flight booking application
  • Another is to read data directly from excel file

You can get a better understanding with the Software testing course certification.

Take a look at the below code to understand the test case. The code is written for testing the login functionality of a flight booking application.

package DataDriven;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class DDTExcel
 ChromeDriver driver;
 public void DemoProject(String username, String password) throws InterruptedException
 System.setProperty("webdriver.chrome.driver", "C:UsersVardhanDownloadschromedriver.exe");
 driver = new ChromeDriver();
 driver.get("<a href="http://newtours.demoaut.com/" data-mce-href="http://newtours.demoaut.com/">http://newtours.demoaut.com/</a>");
 Assert.assertTrue(driver.getTitle().matches("Find a Flight: Mercury Tours:"), "Invalid credentials");
 System.out.println("Login successful");

void ProgramTermination()

public Object[][] TestDataFeed()
 ReadExcelFile config = new ReadExcelFile("C:UsersVardhanworkspaceSeleniumLoginCredentials.xlsx");
 int rows = config.getRowCount(0);
 Object[][] credentials = new Object[rows][2];

 for(int i=0;i<rows;i++)
 credentials[i][0] = config.getData(0, i, 0);
 credentials[i][1] = config.getData(0, i, 1); 
 return credentials;


In the above code, there is a method called  “TestDataFeed()”. In this method, I have created an object instance of another class named “ReadExcelFile”. I have fed the path of my excel file containing the data. Then I defined a ‘for’ loop to retrieve the text from the excel workbook.  For the demo, I have created an excel file called “LoginCredentials” in which the usernames and passwords have been stored in different columns.

Moving on to our next file, “ReadExcelFile”.

<pre>package DataDriven;

import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReadExcelFile
 XSSFWorkbook wb;
 XSSFSheet sheet;

 public ReadExcelFile(String excelPath)
 File src = new File(excelPath);
 FileInputStream fis = new FileInputStream(src);
 wb = new XSSFWorkbook(fis);
 catch(Exception e)
 public String getData(int sheetnumber, int row, int column)
 sheet = wb.getSheetAt(sheetnumber);
 String data = sheet.getRow(row).getCell(column).getStringCellValue();
 return data;
 public int getRowCount(int sheetIndex)
 int row = wb.getSheetAt(sheetIndex).getLastRowNum();
 row = row + 1;
 return row;

Like I mentioned earlier, the file had code to read data from excel file. There are two main functions of importance here. “getRowCount” which calculates the number of rows of data present in my excel sheet. For more information, you can refer to the Automation Testing Training in Austin.

“String getData” which extracts the data from the excel sheet for every iteration of testing code. To understand this framework better, you can refer to the below video, where I have explained this in a structured manner.

Test Automation Framework Using Selenium | Software Testing Training

This video will help you learn what testing frameworks are and how to build one using Selenium.

With this, we have reached the end of the blog. Hope the things that you have learned here today will help you as you head out on your automation journey. If you want to dive deeper in Automation Testing, We at Edureka also offer a masters program in Automation engineer course.

If you found this “Test Automation Frameworks” article relevant, check out the live-online Selenium Certification Training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. 

Got a question for us? Please mention it in the comments section of this ‘Test Automation Frameworks’ article and we will get back to you. Alternatively, check out the Automation Testing Training in Bangalore!



Upcoming Batches For Selenium Certification Training Course
Course NameDateDetails
Selenium Certification Training Course

Class Starts on 24th June,2024

24th June

MON-FRI (Weekday Batch)
View Details
Selenium Certification Training Course

Class Starts on 29th June,2024

29th June

SAT&SUN (Weekend Batch)
View Details
Selenium Certification Training Course

Class Starts on 15th July,2024

15th July

MON-FRI (Weekday Batch)
View Details
1 Comment
  • Thank you so much for sharing detailed explanation in test automation framework. This article is really very helpful for me. Learnt something new today.

Join the discussion

Browse Categories

webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

Test Automation Frameworks: How to Build a Framework in Selenium?