Mastering POM
Mastering POM
Kalboussi Karim
What is the Page
Object Model (POM) ??
The Page Object Model (POM) is a
design pattern that promotes creating
object-oriented classes to represent web
pages in test automation. It helps
separate test scripts from
the UI elements and
interactions, making
tests more readable and
maintainable.
Kalboussi Karim
POM Design
Home Products Contact
Page Page Page
Kalboussi Karim
Advantages of POM
Advantage 1: Reusability
By centralizing the page structure and
actions, POM allows you to reuse code
for different test cases. If a UI element
changes, you only need to update it in
the page object, reducing maintenance
effort.
Kalboussi Karim
Advantages of POM
Advantage 2: Maintainability
POM enhances test maintainability. With
the separation of page-specific details
from test scripts, tests are more stable.
UI changes can be easily managed
within the page objects, avoiding code
repetition.
Kalboussi Karim
Advantages of POM
Advantage 3: Readability
Tests become more readable and easier
to understand with POM. The page
objects provide a clear mapping
between test actions and UI elements,
making it simpler for teams to scale and
manage large test suites.
Kalboussi Karim
Principles of POM
1. Page Object: Each page/component
of a web application is represented as a
seperate class.
2. Separation of Concerns: Test logic
and UI interactions are distinctly
separated.
3. Maintenance: Updates are needed
only in the affected page object if the UI
changes.
Kalboussi Karim
Example
Home Products
Page Page
BasePage
(common to all page
objects)
Page Page
Object Object
BaseTest
(common to all tests)
Kalboussi Karim
Example
BasePage :
Kalboussi Karim
Example
BaseTest :
Kalboussi Karim
Example
ProductsPage object :
Test script :
Kalboussi Karim
Let’s sum it up !
The Page Object Model (POM) in Selenium
organizes test automation by separating
test logic from UI elements, improving
readability and reusability.
Karim Kalboussi