Complete Guide To Object Oriented Concepts in Selenium Automation Framework


Complete Guide To Object Oriented Concepts in Selenium Automation Framework

In almost all of the Automation interview you may have face this question where you have actually used OOPS Concept in your Automation framework.
So In this blog, we will discuss how and where we have actually applied below OOPs concepts in our Automation Framework.

  •         INTERFACE
  •         ABSTRACTION
  •         INHERITANCE
  •        ENCAPSULATION
  •         METHOD OVERLOADING
  •         METHOD OVERRIDING

INTERFACE

An interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement. An interface also contain methods and variables just like the class but the methods declared in interface are by default abstract.

To understand this the very basic statement we write in Selenium
WebDriver driver = new Chromedriver();

In this Case WebDriver itself is an Interface. So based on this 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.



ABSTRACTION

As we are aware, Abstraction is a process of hiding the implementation details from the user and showing only relevant details to them. It also helps to reduce programming complexity and effort.

In our Automation Framework whenever we Use Page object Model, we write all the locator in page class and use this locator in our test it means we are hiding our implementation from the user this is the simple example of using abstraction in framework.


INHERITANCE

The process by which one class acquires the properties (instance variables) and functionalities of another class is called inheritance.

When We create a Base Class in our automation Framework to initialize WebDriver interface, waits,loggers,reports etc. and when we extend this Base Class in other classes such as Tests and Utility Class. In this case extending one class into other class is example of implementing Inheritance.


ENCAPSULATION

Encapsulation is a mechanism of wrapping data (variables) and code together as a single unit.
All the classes which we write in our automation framework are an example of Encapsulation. 

For e.g In Page object model classes, in which we declare the WebElement locator using @FindBy and initialization of this data members will be done using Constructor to utilize those in test methods.



METHOD OVERLOADING

If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.

In Implicit wait when we use different time stamps such as SECONDS, MINUTES, HOURS etc is one of the possible example of method overloading.


METHOD OVERRIDING

If subclass or child class has the same method as declared in the parent class, it is known as method overriding in Java. 

Whenever we use a method which was already implemented/written in another class by changing its parameters this is the example of method overriding.

Keep Learning, Keep Sharing




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
October 6, 2018 at 9:32 AM

Thankyou ankur..very helpful..

Reply
avatar
October 6, 2018 at 9:46 AM

Nice very helpful for interview

Reply
avatar
October 6, 2018 at 5:58 PM

nice and helpful.
Can you also share some tips for cracking selenium interview ?

Reply
avatar
October 8, 2018 at 10:44 PM

Wow amazing .. !!! Thanks for sharing

Reply
avatar
October 12, 2018 at 4:48 PM

Thank you ankur..very helpful :)

Reply
avatar
October 12, 2018 at 4:50 PM

Can you make one Post for Frequently asked Java programs in Interviews

Reply
avatar
May 29, 2019 at 7:02 AM

Can you please check the overriding section, I think if we change the parameter, it will be overloading not overriding but great article anyways.

Reply
avatar
November 8, 2019 at 4:44 PM

You missed the example for overriding. You only explain the definition.

But article is good. Thanks for writing this for us.

Reply
avatar
April 17, 2020 at 8:00 PM

Hi Ankur,
Can you please share any good framework for Appium mobile automation. Facing challenge to run TestNG tests on multiple emulators/ physical device where multiple apps need to launch for testing. How to manage this using framework. Also observe that Appium community is not so active to upgrade these types of challenges.
1. Problem in detecting if adb devices is up and running (USB debugging should be enabled).

Reply
avatar
April 5, 2021 at 2:20 PM

I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference.Excellent blog admin. This is what I have looked. Check out the following links for Software testing companies USA
Test automation software
Best automated testing software
Mobile app testing services
Load testing services

Reply
avatar
April 5, 2021 at 2:22 PM

I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference.Excellent blog admin. This is what I have looked. Check out the following links for Software testing companies USA
Test automation software
Best automated testing software
Mobile app testing services
Load testing services

Reply
avatar
April 6, 2021 at 5:33 PM

Nice blog has been shared by you. before I read this blog I didn't have any knowledge about this but now I got some knowledge so keep on sharing such kind of an interesting blogs. We wish you the best of luck in all your blogging endeavors. Excellent blog admin. This is what I have looked. Check out the following links for QA services:-

India Best QA Testing Services Provider Company | Best Automation Testing Company in USA

Reply
avatar
May 7, 2021 at 5:45 PM

The article is no doubt very helpful. Thank you so much for that but as per my knowledge in method overriding the signature of method should not change, it should have same number and type of arguments in base as well as child class.

Reply
avatar
October 11, 2021 at 7:23 PM

I used to be recommended this website by my cousin. I am no longer sure whether this put up is written by way of him as no one else realize such precise approximately my trouble. You are wonderful! Thank you! free javascript courses

Reply
avatar
Anonymous
April 19, 2022 at 10:44 AM

Complete Guide To Object Oriented Concepts In Selenium Automation Framework - Qa Automation >>>>> Download Now

>>>>> Download Full

Complete Guide To Object Oriented Concepts In Selenium Automation Framework - Qa Automation >>>>> Download LINK

>>>>> Download Now

Complete Guide To Object Oriented Concepts In Selenium Automation Framework - Qa Automation >>>>> Download Full

>>>>> Download LINK B8

Reply
avatar