Top Page Object Model(POM) Interview Questions (2021) | CodeUsingJava
















Most frequently Asked Page Object Model(POM) Interview Questions


  1. What is a Page Object Model?
  2. What are the Advantages of Page Object Model?
  3. How to implement POM?
  4. Is Page object model a framework?
  5. What is the Page Factory Class?
  6. What is Page Factory?
  7. Differences between Page Object Model and Page Factory?
  8. What is Test Class?
  9. How can we write sample code for Page Action Class?
  10. How can we create testng.xml file?
  11. What are the OOPS Concepts applied in POM?

What is a Page Object Model?

Page Object Model is a design pattern in Selenium, that is also used for enhancing test maintenance and reducing code duplication. Page Object Model is used in a framework like Data-Driven, Modular, Hybrid Framework, etc.POM is a class that is also used for serving as an interface to a page of our AUT(Application Under Test).

What are the Advantages of Page Object Model?

Page Object Model
  • Code Resuability - POM can achieve code reusability by writing code and using in different tests.
  • Code Maintainability - POM acts as a Clean Separation between Tests Code and Page Specifics Code like Layout, Locators, which helps in maintaining code.
  • Object Repository - POM helps in defined like Java Class.The pages can be defined in an interface like members.
  • Readability - POM can help in improving readability by clean separation through Test Code and Page Specific Code.

How to implement POM?

We can implement POM by using:
BrowserStackHomePage
BrowserStackSignUpPage

Is Page object model a framework?

POM acts as a design pattern that is popular in Selenium Test Automation. It can also be used in any kind of framework like Data-Driven, Modular, Hybrid Framework, etc.
Page Object Model

What is the Page Factory Class?

Page Factory Class acts as an extension to the POM Design Pattern and is also used for initializing elements of POM or Instantiating the Page Object.Annotations can also be created by describing properties that cannot be descriptive.
Page Object Model

What is Page Factory?

Page Factory is an inbuilt Page Object Model for Selenium web driver, it is also optimized. Page Factory is used as a framework like a data-driven, keyword-driven, etc. It also gives focus on the code is structured for getting the best benefit.

Differences between Page Object Model and Page Factory?

Page Object represents Web Page and used for holding functionality and members.
Page Factory used for initializing web elements that are needed to interact with the page object when we used for creating an instance.

What is Test Class?

Test Class helps in writing an actual Selenium Test Script. We can also call Mentioned Actions and Page Action which can be performed in Web Pages. We can also write our Test Class for Code Readability, in @Test Annotations.

How can we write sample code for Page Action Class?

We can use the following command:
publicclassPageActions_Login
{
WebDriver driver;
PageObjects_Loginpo; // Creating an Instance to Page Factory
class
publicPageActions_Login(WebDriver driver)
{
this.driver = driver; // Setting Web Driver for current Page
Action
}
}


How can we create testng.xml file?

We can create testng.xml file by using the following command:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Everjobs Suite">
 
<test name="Page Object Model Project">
<classes>
<class name="tests.TestBase" />
<class name="tests.FbLoginTest" />
</classes>
</test>

</suite> <!-- Suite -->


What are the OOPS Concepts applied in POM?

OOPS concepts applied in POM are as follows:
Abstraction
Interface
Inheritance
Polymorphism
Encapsulation