1 Encapsulation (say this)
“I applied Encapsulation by keeping all WebElements/locators private in my Page Object
classes and exposing only meaningful public action methods like enterUsername(),
enterPassword(), and clickLogin(), so that tests interact with behavior rather than
implementation.”
2 Inheritance (say this)
“I used Inheritance by creating a common BaseTest class that contains shared setup and
teardown methods like browser initialization, window maximize, and quit. All my test
classes extend this BaseTest to avoid code duplication and promote reuse.”
3 Abstraction (say this)
“I implemented Abstraction by using interfaces or abstract classes for browser and driver
setup. The test classes only call high-level methods like launchBrowser() without worrying
about the internal implementation of Chrome, Firefox, or Edge.”
4 Polymorphism — Method Overloading (say this)
“I used Compile-time Polymorphism (Overloading) in my utility methods, for example
creating multiple waitForElement() methods — one with default timeout and another
accepting a custom timeout, so tests can use whichever is required.”
5 Polymorphism — Method Overriding (say this)
“I used Runtime Polymorphism (Overriding) where common methods were defined in a
BasePage or BaseTest class and overridden in child classes when page-specific behavior was
needed.”
6 Association (Has-A relationship) (say this)
“I used Association where my Test classes ‘have-a’ relationship with Page Objects — for
example, LoginTest has a LoginPage object and uses it to perform login actions.”
7 Composition (Strong Has-A relationship) (say this)
“I used Composition in my Page Objects where each Page class depends on WebDriver. For
example, LoginPage cannot exist without a WebDriver instance, which is passed via the
constructor.”