top of page
Writer's pictureReshma Stephen

Java OOPS concepts used in Automation Framework



1. ABSTRACTION

Abstraction is the methodology of hiding the implementation of internal details and showing the functionality to the users.


Let’s see an example of data abstraction in Selenium Automation Framework.



Step Definitions in Login Page


Here the loginpage is the object of LoginPage class and the methods are directly called. Abstraction achieved as code and locator details are hidden






2. INTERFACE

An interface in Java is a collection of abstract methods. All methods declared in an interface are implicitly public and abstract.


WebDriver is an Interface

We all know in Selenium WebDriver driver = new ChromeDriver();


WebDriver itself is an Interface. So based on the above statement WebDriver driver = new ChromeDriver(); we are initializing Chrome browser using Selenium WebDriver. It means we are creating a reference variable (driver) of the interface (WebDriver) and creating an Object. Here WebDriver is an Interface as mentioned earlier and ChromeDriver is a class.








3. INHERITANCE

The mechanism in Java by which one class(Subclass) acquires the properties (instance variables) and functionalities of another(Superclass) class is known as Inheritance.


We create a Base Class in the Automation Framework to initialize WebDriver interface, WebDriver waits, Property files, etc., in the Base Class.

We extend the Base Class in other classes such Tests and Utility Class.



4. POLYMORPHISM

Polymorphism allows us to perform a task in multiple ways.


  • METHOD OVERLOADING

A class having multiple methods with same name but different parameters is called Method Overloading


We use Implicit wait in Selenium. Implicit wait is an example of overloading. In Implicit wait we use different time stamps such as SECONDS, MINUTES, HOURS etc.




Assert class in TestNG is also an example of overloading.



  • METHOD OVERRIDING

Method overriding allows a subclass to provide a specific implementation for a method that is already defined in its superclass is method overriding.

Examples are get() and navigate() methods of different drivers in Selenium.


5. ENCAPSULATION

Encapsulation is a mechanism of binding ode and data (variables) together in a single unit.

All the classes in a framework are an example of Encapsulation.

In POM classes, we declare the data members using @FindBy and initialization of data members will be done using Constructor to utilize those in methods.



84 views0 comments

Recent Posts

See All

Battle of the Backends: Java vs Node.js

Comparing Java and Node.js involves contrasting two distinct platforms commonly used in backend development. Here’s a breakdown of their...

Comments


bottom of page