


What is Page Object Model (POM) and why you should use it in Automation tests ?
Jul 7, 2024
1 min read
Page Object Model (POM) is a design pattern widely used to enhance test maintenance, readability, and reusability.
It helps in creating a structured and maintainable tests automation framework by separating the test code from the page-specific code.
In POM, each web page in the AUT (application under test) is represented as a separate class which contains:
Page Elements:Â Web elements like buttons, input fields, dropdowns, etc.
Page Methods:Â Functions that perform actions on these elements, such as clicking a button, entering text, or verifying the state of an element.
Â
POM benefits-
By creating page classes, you can reuse these classes across multiple test cases, this reduces code duplication (DRY).
Â
Organizing page elements and their interactions within page classes makes the test code more readable. Each test case becomes a series of actions and checks, making it easier to understand and follow, even for those not familiar with the application's details.
Â
By centralizing element locators and interactions within page classes, any changes to the web elements (such as IDs, names, or XPath), need to be updated in only one place. This significantly reduces the risk of breaking multiple test cases. What leave the test cases code cleaner and easier to modify with a wide scale of scenarios.
Here you can see my tests before using POM-

And here you can see my tests after using POM-

In this pic you can see the Locators and Methods-

By using POM, you can achieve more organized and efficient automation tests framework, making it easier to scale and maintain over time.
