Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Selenium Framework 2: Why Do We Need A Framework In Selenium?

Posted on 02/08/2025 By admin

Hello Folks,

In last post, we have seen some real time examples of a framework. Now we will relate all those with selenium frameworks.

Let me define framework first.

What is Framework?

Framework is a collection of concepts you know in an organised manner with some proper rules, validation, proper exception and error handling which can be easily reuse, manage and scale.

You will be feeling like how it could be a definition of a framework. Stay with me to get it.

Selenium automates browser. Browser is a key part of it. You have very good knowledge of opening a browser. You know to open any desired browser. You need to automate many test cases. You are writing same lines of code for opening a browser in every test case. It is increasing number of lines of code. But you don’t bother because you think it is just copying 10 lines of code and pasting it every test scripts. Suppose you are opening a chrome browser.

Now your manager says you to test in a Firefox browser. What you will do? Will you go and change in every test scripts? Suppose you manage to change in every scripts, is it reasonable? If managers asks you to run in other browsers or again in same browser, you are gone. You can not just keep changing it.

What you should do here? You should create a method for launching a browser. You should customized this method in such a way that it should open any desired browser at any operating system. You create this method in a separate class say “Reusable methods”. Now you can call it any where you want.

Your colleagues are also working on same or other project. They are also required to launch a browser. Do they need to develop same method again or they can use method created by you already? Of course, they should use method created by you. Method is reusable, extendable and flexible. This method is a building block of a framework. You just incorporated the concept of opening a browser. You didn’t write new or something rocket science to launch a browser to make it part of framework. So, Framework is a collection of concepts you know.

You want to type in to a text box. You know that sendKeys() method is used to do so. Before typing in to a text box you should check if it is displayed and enabled and also to validate if typed successfully, you should fetch the value and compare actual with expected one.  You should create a method which will check if element is displayed and enabled and then type. After typing it should validate the typed value as well. And also you can do better exception handling if something goes wrong. If text box is not displayed, you can show proper error message to user. All these steps should be part of a method and you can use it any where you need to type. You can say you are implementing some rules and standard or protocols.

Similar types of method you can create for click, select etc actions. Since it is all similar types of actions, we can put into a file say “CustomisedSeleniumControls”. This is another building block of framework. You just used so many concepts of java and selenium and build it.

Like above example, you can create methods for reading writing from external data sources, validation, reporting etc and can place it in such a way that you and other projects can also use it. It saves efforts, time and of course money of company.

Now you can say, that above definition of framework is making some sense.

Characteristics of a framework:

  1. Framework should be developed in such a way that any body can plug and use it. They should be able to start scripting with minimal or no setup.
  2. It must not be project dependent.
  3. It should be reusable and easy to manage and maintain.
  4. Flows should be clear.
  5. It should be simple so that an average automation tester could understand and use it.
  6. It should not contain scripting codes.
  7. It should be easily extendable i.e. enhancing.
  8. It should be platform independent.

Hopefully, now you can understand why do you need a framework in selenium.

More on Frameworks in upcoming posts.

If you have any doubt, feel free to comment below. If you like my posts, please like, comment, share and subscribe. #ThanksForReading

#HappySelenium

Uncategorized

Post navigation

Previous Post: Selenium Interview Question 10 – Difference Between findElement() and findElements() methods
Next Post: Frequently Asked Java Program 03: Java Program to check if any string is palindrome Using inbuilt Reverse method of Java

Related Posts

April 18, 2019 – Make Selenium Easy Uncategorized
Hierarchy of Selenium Classes and Interfaces – Make Selenium Easy Uncategorized
image – Make Selenium Easy Uncategorized
TestNG Tutorials 42: Parameters In TestNG or Parameterization of Methods in a TestNG Class | Make Selenium Easy Uncategorized
Postman Tutorial Part 19 – Save Response in Collection in Postman Uncategorized
TestNG Tutorials 36: Can a Test Method Return a Value in TestNG? – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark