Syntest

Syntest, a publication dedicated to exploring the dynamic world of Software Testing, Quality…

Follow publication

Member-only story

Reasons To Keep Assertions Out Of Page Object Models

The Power of Clean Code: Why Assertions Belong Outside POMs

In the Page Object Model (POM) pattern, the goal is to keep user interactions (clicking buttons, filling forms, etc.) separate from test assertions or validations. Page objects should only interact with web page elements, while the test files handle all the assertions. This ensures better separation of concerns, maintainability, and reusability of the code.

If you are behind the Medium paywall and can’t read this article, click here this publication is open to everyone.

Why This Approach is Important

  1. POM handles interactions, while the test files handle assertions and test logic.
  2. Keeping assertions in the test files allows easier updates when logic changes.
  3. A single Page Object can be reused across different tests without embedding test-specific logic.
  4. Test logic and assertions are centralized, making it easier to understand what the test is validating.

Example Without Assertions in Playwright POM

  • Page Object Model (POM) — No Assertions
// loginPage.ts - POM for the Login Page using Playwright
import { Page } from

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Syntest
Syntest

Published in Syntest

Syntest, a publication dedicated to exploring the dynamic world of Software Testing, Quality Assurance (QA), Test Automation, and the integration of Generative AI in these fields. Our goal is to provide readers with cutting-edge insights, practical techniques, and innovations

Shivam Bharadwaj
Shivam Bharadwaj

Written by Shivam Bharadwaj

Senior SDET | Passionate For Software Quality | Automation | Love sharing insights | https://www.linkedin.com/in/meetshivambharadwaj

Responses (1)

Write a response