The Four OOP Pillars Mapped to the Framework

The following memory map shows where each OOP concept is used in the automation framework.

OOP Concept Where It Is Used
Encapsulation Page Object Model (POM)
Inheritance Base Test Class
Polymorphism WebDriver Interface
Abstraction Interfaces / Utilities

Encapsulation → Page Object Model (POM)

Encapsulation means wrapping data and methods together while hiding internal implementation details.

In the automation framework, Encapsulation is implemented using the Page Object Model (POM).

Advertisement

Implementation

  • WebElements → Private
  • Actions → Public Methods

The WebElements remain hidden inside the page class, while only the required actions are exposed to the test scripts.

For example:

  • Login page elements remain private.
  • Only the login() method is accessible to the test class.

This allows test scripts to interact with page functionality without directly accessing page elements.

Interview Line

"I used encapsulation in my framework through the Page Object Model by keeping WebElements private and exposing actions through public methods."


Inheritance → Base Test Class

Inheritance allows a child class to reuse properties and methods from a parent class.

In the framework, inheritance is used to improve code reusability.

Base Class Responsibilities

The Base Class contains common setup and teardown functionality such as:

  • Driver Initialization
  • Browser Launch
  • Browser Closure
  • Test Teardown

Every test class extends the Base Class instead of duplicating setup code.

Interview Line

"I used inheritance by creating a Base Class for browser setup and extending it in all test classes to achieve code reusability."


Polymorphism → WebDriver Interface

Polymorphism means one method or reference can take multiple forms.

In the automation framework, it is mainly implemented using the WebDriver interface.

Example

 
WebDriver driver;
 

The same WebDriver reference can point to different browser implementations such as:

  • ChromeDriver
  • FirefoxDriver
  • EdgeDriver

Depending on the selected browser, the same reference behaves differently.

Additional Note

This is Runtime Polymorphism through the WebDriver interface.

Other forms include:

  • Method Overloading
  • Method Overriding

Examples:

  • Overriding TestNG Listener methods
  • Overloading utility methods with different parameters

Interview Line

"I used polymorphism mainly through the WebDriver interface, where the same reference supports multiple browser drivers."


Abstraction → Interfaces & Utilities

Abstraction means showing what to do while hiding how it is done.

In the framework, abstraction is implemented using:

  • Interfaces
  • Abstract Classes

These define framework rules, while concrete classes and utility classes provide the implementation.

Purpose

  • Hide implementation details
  • Enforce framework standards
  • Improve maintainability

Interview Line

"I used abstraction by defining interfaces and abstract classes to hide implementation details and enforce framework rules."


One-Line Interview Summary

"In my framework, I used Encapsulation through the Page Object Model, Inheritance using a Base Test Class for setup and teardown, Polymorphism via the WebDriver interface to support multiple browsers, and Abstraction using interfaces and utility classes to hide implementation details."


FAQs

How Do You Use OOP Concepts in Your Automation Framework?

The framework uses:

  • Encapsulation through Page Object Model
  • Inheritance through Base Test Class
  • Polymorphism through the WebDriver interface
  • Abstraction through Interfaces and Abstract Classes

Where Is Encapsulation Used?

Encapsulation is implemented in the Page Object Model.

  • WebElements are private.
  • User actions are exposed through public methods.

Example:

Only the login() method is exposed while page elements remain hidden.


Where Is Inheritance Used?

Inheritance is used in the Base Test Class.

The Base Class contains:

All test classes extend this Base Class for code reuse.


How Is Polymorphism Used?

Polymorphism is implemented through the WebDriver interface.

The same reference supports multiple browser drivers such as:

  • ChromeDriver
  • FirefoxDriver
  • EdgeDriver

How Is Abstraction Used?

Abstraction is implemented using:

  • Interfaces
  • Abstract Classes

These define framework rules while hiding implementation details.