top of page

Relation between Page Object Model (Pom) and Page Factory

Page Object Model (Pom) and Page Factory

Many a times I have heard people say that they used POM rather than Page Factory or asking questions if POM is better or Page factory. A little bit of credit for this goes to the search engine too. As soon as you type “POM vs ” in the search bar the first comparison it suggests is POM vs Page Factory. This leads you to believe that these both are comparable.

Let me first clarify that, POM and page factory go very well together, just like pasta and cheese. So, whenever you are hesitant about using both, just remember how adding cheese enhances the flavor of pasta and all then your doubts will be gone.

That being said, let’s go into the details of POM and page factory.

POM: It is a model, a design pattern. It is designed in such a way that you have one class for your web elements and their related functionality called Page class and one other class for your test cases.

For each page of your web application, you create one Page class.

Let us learn by taking an example of a website you are testing with following pages:

1. Home Page

2. Login Page

3. Forgot Password Page

4. Dashboard Page

Here, you will need to create 4 separate Page classes for each page

In these classes you will define all the web elements of the corresponding page and the methods that will be used on each element.

Next, we create a class for test cases which will use the web elements and methods from the page class.

Page Factory: It is a class provided by Selenium WebDriver to help us implement the Page Object Model in more efficient way reducing the time and effort.

1. When using Page Factory class, web elements are located and declared using @FindBy annotation

@FindBy(id=”username”) WebElement uname;

2. Page Factory class uses a static method initElements() to initialize the elements which helps in instantiating the Page class early.

initElements(Webdriver localDriver, java.lang.Class LoginPage)


1. Its good to use POM as it reduces the maintenance effort and increases the reusability of code

2. Page Factory class helps in implementing POM

3. POM can be implemented without using Page Factory Class

48 views0 comments

Recent Posts

See All


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page