0% found this document useful (0 votes)
18 views12 pages

Mastering POM

Uploaded by

sivasanni03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views12 pages

Mastering POM

Uploaded by

sivasanni03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Mastering

Page Object Model


in Selenium

Swipe for more

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.

Swipe for more

Kalboussi Karim
POM Design
Home Products Contact
Page Page Page

Page Object Page Object Page Object

Test Script 1 Test Script 2 Test Script 3

Swipe for more

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.

Swipe for more

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.

Swipe for more

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.

Swipe for more

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.

Swipe for more

Kalboussi Karim
Example
Home Products
Page Page

BasePage
(common to all page
objects)

Page Page
Object Object

BaseTest
(common to all tests)

Test Test Test


Script 1 Script 2 Script 3

We will test the products page to ensure it is


displayed, confirming successful redirection to the
products page after login. TestNG was utilized in
both the BaseTest class and the test script.

Swipe for more

Kalboussi Karim
Example
BasePage :

Swipe for more

Kalboussi Karim
Example
BaseTest :

Swipe for more

Kalboussi Karim
Example
ProductsPage object :

Test script :

Swipe for more

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.

In the next posts, we’ll explore more about


Selenium, locators, best practices, reusable
utilities, and tips for writing efficient,
maintainable test scripts.

Karim Kalboussi

You might also like