Introduction
In this blog, we will discuss most asked POM interview questions and their answers. Selenium has tools for automating test cases such as Page Object Model and Page Factory. POM, also known as Page Object Model, is a Selenium design pattern that creates an object repository for all web elements. Test case maintenance is made easier by reducing code duplication.
Every web page in an application is a class file in the Page Object Model. Classes in this model are only composed of elements that correspond to web pages. Testing can be done on a website using these elements.

Let us discuss the most asked POM interview questions.
Most Asked Page Object Model(POM) Interview Questions and Answers
1. What is a page object model?
The Page Object Model design pattern has become popular in test automation for reducing code duplication and enhancing test maintenance. A page object represents a page of your AUT in an object-oriented way. This is one of the basic POM Interview Questions.
2. What is a page object model in Selenium?
A Page Object Model is a Selenium design pattern in which the various elements of a web page are represented as variables within classes.
3. Is Page object model a framework?
Design Patterns such as Page Object Model are becoming popular in automating Selenium tests. Any kind of framework can use Page Object Model (POM), including modular, data-driven, keyword-driven, and hybrid frameworks.
4. What is the Page Factory Class?
Using the Page Factory Class, we extend the Page Object design pattern. Page Objects or their elements can be initialized using this method. It is also possible to create annotations for elements, since the describing properties may not always be sufficiently descriptive to tell one object from another. This is also one of the basic POM Interview Questions.
5. What is the difference between Page Object Model (POM) and Page Factory?
'Page Objects' are classes that represent web pages and contain all of their functionality and members.
Page Factory lets you initialize the elements which you want to interact with within a page object as soon as you create an instance of it. This is one of the most asked POM Interview Questions.
6. What is Test Class?
We will write a real Selenium test script in Test Class. In this case, we refer to Page Actions as the actions performed on Web Pages. Our own test classes can be written for each page for better code readability. @Test annotations can be used to write test cases.
7. What is Page Action Class?
The Page Action Class allows us to write web pages actions according to the page and functionality. For each page in the application, we have a corresponding Page class under the Page Action component.
8. Can you write sample code for Page Factory Class?
@FindBy(xpath=”.//*[@id=’Email’]”)
publicWebElementgmailUserIDWebEdit;
9. Can you write sample code for Page Action Class?
publicclassPageActions_Login
{
WebDriver driver;
PageObjects_Loginpo; // Create Instance to Page Factory
class
publicPageActions_Login(WebDriver driver)
{
this.driver = driver; // set webDriver for current Page
Action
}
}
10. What type of test cases have you automated?
Automation tools are generally used to automate regression and functional tests because they are more stable and less prone to change.
11. What are the advantages of using page object pattern?
This question is the most important of all POM Interview Questions.
- Easy to maintain.
- Easy readability of scripts – It is easy to walk through the code since the test scripts, functions, and locators are in separate classes.
- Eliminate redundancy – There is no duplication of functions or locators.
- Re-usability of code – Tests can reuse locators or functions.
- Reliability.
- The coverage of tests is higher since they are written programmatically.
- It is possible to determine the performance of each test.
- If the locator changes, the changes must be made in the Page Factory class.
12. How to implement POM?
We can implement POM by using:
BrowserStackHomePage
BrowserStackSignUpPage
13. 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="POM Interview Questions Suite">
<test name="POM Interview Questions Project">
<classes>
<class name="tests.TestBase" />
<class name="tests.FbLoginTest" />
</classes>
</test>
</suite> <!-- Suite -->
14. What are the OOPS Concepts applied in POM?
OOPS concepts applied in POM are as follows:
Abstraction
Interface
Inheritance
Polymorphism
Encapsulation
Also see, Four Pillars of OOPS
15. What is the relationship between page classes and web elements in POM?
An object-oriented class that serves as an interface for your application's page is known as a Page object. Web elements are contained in Page objects, along with methods for interacting with them. Automating test cases involves creating objects of these Page Classes and calling methods on these objects as we interact with web elements.
16. Name a few files that serve as a data source for various Selenium frameworks.
They can be an XML, Excel, CSV, or even a Text file.
17. What are the Design Pattern used in the Project?
POM (Page Object Model) is one of the most commonly used design patterns. In addition to resolving stale element exceptions, enhanced POM can also provide caching. Both POM and Page Factory are based on Abstraction Strategy Design pattern.
18. When working with Selenium Automation, what challenges do you face?
Maintaining code is usually the biggest challenge an automation engineer faces.
This may affect your code, especially if you frequently change HTML elements of the page and add new components.
In order to resolve these issues, we have certain design patterns such as POM (Page Object Model) and Page Factory.
Synchronization is another challenge when using Selenium.
19. What is Automation Testing?
Software or applications are tested using an automation testing tool to find defects. By using automation tools, test scripts are executed automatically and results are generated.
20. Have you worked on any framework? Describe the framework designed for your project?
It is a trend to use hybrid frameworks, data driven frameworks, or even custom frameworks which use design patterns such as POMs or enhanced POMs (Page Factory).
21. Which design patterns do you use?
POM (Page Object Model) is the most commonly used pattern. A class file is created for every page of the application under test in this type of design pattern.
Page Factory, also known as Enhanced POM, helps with resolving stale element exceptions and also provides cache management.
22. What is an XPath?
To find the elements, XPath is used. An XML document could be navigated through elements and attributes to locate web elements, such as text boxes, buttons, check boxes, images, etc., in a web page using XPath.
23. How does "/" differ from "//"?
Single Slash “/” – This creates an XPath with an absolute path, i.e., the path starts at the document node/start node.
Double Slash “//” – This is used for creating XPaths with relative paths, i.e. the XPath will be created to start selection from anywhere within the document.
24. Is there anything you can do when you can't even identify the web element with XPath?
We cannot identify the web elements during execution because they may change dynamically. As a result, we use XPath functions and axes to overcome this problem.
25. What are XPath Axes?
Multiple nodes in the XML document can be found using XPath axes from the context (current) node.
With XPath axes, dynamic elements can be found that otherwise would not be found with regular locators.