UI Test Automation - POM Framework

What is Page Object Model Design Pattern (POM) ?

‌Page Object Model is a Design Pattern which has become popular in Selenium Test Automation. It is widely used design pattern in Selenium for enhancing test maintenance and reducing code duplication. Page object model (POM) can be used in any kind of framework such as modular, data-driven, keyword driven, hybrid framework etc. A page object is an object-oriented class that serves as an interface to a page of your Application Under Test(AUT). The tests then use the methods of this page object class whenever they need to interact with the User Interface (UI) of that page. The benefit is that if the UI changes for the page, the tests themselves don’t need to change, only the code within the page object needs to change. Subsequently, all changes to support that new UI is located in one place.

​‌Advantages of Page Object Model

‌The advantages of page object model can be listed as:‌

  • Code re-usability – We could achieve code re-usability by writing the code once and use it in different tests.

  • Code maintainability – There is a clean separation between test code and page specific code such as locators and layout which becomes very easy to maintain code. Code changes only on Page Object Classes when a UI change occurs. It enhances test maintenance and reduces code duplication.

  • Object Repository – Each page will be defined as a java class. All the fields in the page will be defined in an interface as members. The class will then implement the interface.

  • Readability – Improves readability due to clean separation between test code and page specific code

‌This approach is called Page Object Model(POM). It helps make the code more readable, maintainable, and reusable.

This figure illustrates the page pattern model using Selenium:

Last updated