What is Page Object Model (POM) in Selenium?

What is Page Object Model (POM) in Selenium?

The Page Object Model (POM) is not just a theoretical concept, but a practical and widely used design pattern in Selenium. It enhances the maintainability and readability of automated test scripts, making them more manageable and less daunting. By creating an object repository for web elements and representing each web page within the application as a separate class, POM ensures that test scripts remain clean, modular, and easy to manage, giving you the power to control your automation framework.

This post aims to provide an in-depth understanding of POM, its concept, structure, and benefits, offering valuable insights for software testers looking to improve their automation frameworks.

Concept of POM

POM encapsulates the interactions and behaviors of a web page within a class, separating test logic from page-specific logic. Each class in the POM represents a web page and contains:

  • Web Elements: Defined as variables using locators such as By.id, By.name, By.xpath, etc.
  • Methods: Actions can be performed on these web elements, such as clicking a button or entering text.

By isolating the UI elements and their behaviors in page classes, POM ensures that any changes to the UI require updates only in the corresponding page class, leaving the test scripts unaffected.


Structure of POM

POM consists of two main components:

  • Page Class: Contains the web elements and methods for interacting with these elements.
  • Test Class: Utilizes the methods from the page classes to perform actions and verification.

Benefits of POM

Improved Readability and Maintainability

  • Cleaner Test Scripts: By focusing on test logic rather than UI interactions, test scripts become more readable and accessible.
  • Isolation of UI Changes: Changes in the UI are isolated to the page classes, reducing the impact on test scripts and making maintenance easier.

Reusability and Scalability

  • Code Reuse: Page classes can be reused across multiple test scripts, promoting code reuse and reducing duplication.
  • Scalable Framework: As the application grows, new page classes can be added without affecting existing tests, making the framework scalable and adaptable.


The Page Object Model (POM) is not just a design pattern, but a powerful tool that can transform your test automation framework. By encapsulating the details of UI interactions within page classes, POM makes it easier to manage, extend, and maintain automated tests. Implementing POM in Selenium not only enhances the readability and maintainability of test scripts but also promotes code reuse and scalability, ensuring a robust and efficient testing process. So, rest assured, POM is the key to a more efficient and effective testing process.


This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment