playwright-pom

Implement Page Object Model patterns to reduce duplicated locators in Playwright tests.

1|Updated Apr 23, 2026
One-click install
npx skills add https://github.com/swongsuddee/windflu-test --skill playwright-pom-swongsuddee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-pom
Source: https://github.com/swongsuddee/windflu-test/tree/main/.agents/toolkit/playwright-skill/pom
Command: npx skills add https://github.com/swongsuddee/windflu-test --skill playwright-pom-swongsuddee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Playwright tests become hard to maintain when locators and low-level UI interactions are scattered across specs, causing brittle failures and duplicated setup logic.

Core Features & Use Cases

  • Page Object Model guidance: Encapsulate user-intent actions in page objects while keeping tests responsible for assertions.
  • Decision framework: Choose between Page Objects, fixtures, and helper functions based on reuse frequency and interaction complexity.
  • Practical patterns: Use components, navigation-returning methods, getter patterns for dynamic locators, and static async factories for pages that need initialization.

Use Case Example: Multiple test files repeatedly perform login flows and navigate into a dashboard, so you standardize actions like login and navigation into LoginPage and keep assertions in the test to reduce duplication and flakiness.

Quick Start

Use the playwright-pom skill to refactor your Playwright tests so page objects expose intent-based actions and your specs own all expect() assertions.

Frequently Asked Questions about playwright-pom

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce duplicated locators in Playwright tests?

Implement the Page Object Model pattern to encapsulate user-intent actions inside dedicated page objects. This approach keeps specs responsible for assertions while centralizing interaction logic to prevent brittle failures from scattered low-level UI setup.

What is the best way to structure Playwright test architecture for maintainability?

Separate actions from assertions, scope component locators correctly, and use getter patterns for dynamic locators. Apply typed chaining or async readiness methods to handle navigation flows across shared UI components for better maintainability.

When should I use Playwright fixtures instead of page objects?

Choose Playwright fixtures or helper functions instead of page objects when reuse frequency is low or interaction complexity is minimal. A decision framework evaluates shared component requirements to determine the best approach for each testing scenario.

How do I handle dynamic locators in Playwright page objects?

Use getter patterns in Playwright page objects to generate dynamic locators on demand. For pages requiring initialization, apply static async factory methods to ensure async readiness before executing typed chaining or navigation flows.

Does the Page Object Model work with Playwright component locators?

The Page Object Model works with Playwright component locators by correctly scoping them within dedicated page objects. This encapsulates shared components properly while maintaining clear separation between intent-based actions and test-level assertions.

Why do my Playwright tests keep failing with brittle locators?

Playwright tests fail with brittle locators when low-level UI interactions are scattered across specs. Implementing the Page Object Model standardizes repeated flows like login and navigation into page objects, reducing duplication and overall test flakiness.