playwright-pom

Implements Page Object Model patterns for Playwright tests with fixtures and component composition.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/t-jet/pal_found_cli --skill playwright-pom-t-jet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-pom
Source: https://github.com/t-jet/pal_found_cli/tree/main/.ept/skills/playwright/pom
Command: npx skills add https://github.com/t-jet/pal_found_cli --skill playwright-pom-t-jet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @playwright/test.

What problem does it solve? Playwright test suites become unmaintainable when locators and interactions are duplicated across spec files. This Skill provides structured guidance on organizing test code with Page Object Model classes, component objects, custom fixtures, and helper functions so tests stay readable as the suite grows. ## Core Features & Use Cases - Page Object Patterns: Eight concrete patterns including basic POM classes, component objects scoped to a Locator root, navigation chains returning destination page objects, factory functions, getter-based dynamic locators, and static factory methods for async initialization. - Decision Framework: A flowchart and comparison table for choosing between page objects, custom fixtures, and helper functions based on interaction count, reuse across files, and lifecycle needs. - Anti-Pattern Catalog: Identifies god objects, assertions inside page objects, deep inheritance chains, stateful page objects, and oversized fixtures with concrete fixes. - Use Case: When refactoring a growing Playwright suite where the same login flow is copy-pasted across 10 spec files, use this Skill to extract a LoginPage class, wrap it in a test.extend fixture, and compose shared UI like navbars into component objects. ## Quick Start Ask the agent to refactor your Playwright login tests into a page object with fixture injection following the POM patterns in this Skill.

Frequently Asked Questions about playwright-pom

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

FAQPage Schema
How do I create a page object in Playwright?

Create a class that takes a Page in its constructor, define locators as readonly properties, and expose action methods like login() that perform user-visible behaviors. Keep assertions in the test file, not inside the page object.

Page object vs fixture vs helper function in Playwright?

Use page objects for UI interactions on pages with 5+ actions reused across files, custom fixtures for resources needing setup and teardown like auth state or test users, and helper functions for stateless utilities like generating test data. Most projects combine all three.

How do I use page objects as Playwright fixtures?

Extend the base test with test.extend and define a fixture that instantiates your page object and passes it to use(). Tests then receive the page object via destructuring, and you import test and expect from your fixtures file instead of @playwright/test.

Should assertions go inside Playwright page objects?

No, assertions belong in tests so the page object stays a pure action boundary. The exception is synchronization calls like waitForURL or waitFor that confirm navigation completed, which are fine inside page object methods.

Why does my Playwright page object locator time out?

The page object was likely constructed before navigation completed, binding locators to the wrong page state. Call goto() before constructing the POM, or use getter methods that create locators fresh on each access.

When should I avoid the Page Object Model in Playwright?

Skip POM when a page has only 1-2 interactions used in a single test file; inline locators or a small helper function are simpler. POM pays off only when interactions are reused across multiple test files.