Agent skill

Page Objects

by idavidov13 in idavidov13/agentic-playwright

Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and…

MITAuto-check passedTesting & QA

Install Page Objects

skills CLI
$ npx skills add idavidov13/agentic-playwright --skill page-objects -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install idavidov13/agentic-playwright page-objects --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/idavidov13/agentic-playwright.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/page-objects .claude/skills/page-objects && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
page-objects
GitHub stars
223
Token cost
~3.6k tokens
SKILL.md length
1,158 words
Files
3 (incl. references)
Skills in repo
13
Repo updated
First seen
Licence
MIT

At a glance

Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and…

  • Works in 6 steps: Verify prerequisites → Explore the live application (mandatory) → Plan the page object's test coverage → …
  • Creating a new page object
  • SKILL.md covers Critical, File Locations, Page Object Pattern and Rules, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Page Objects is an agent skill from idavidov13/agentic-playwright. Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and the mandatory exploration-first workflow. Use when creating a new page object, adding or updating locators on an existing page object, adding a new reusable component, or registering a page in the fixture layer. For the locator priority order and feedback/validation-message rules see the selectors skill; for the…

Its SKILL.md is about 3.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/examples.md` and `references/troubleshooting.md`).

It sits in Testing & QA, covering Browser testing and React components. It works with Playwright. The repository describes itself as: Production-grade Playwright + TypeScript Scaffold for Agentic Testing. Harness for all major AI coding agents baked in. The licence is MIT.

When your agent uses it

  • Creating a new page object
  • Updating locators on an existing page object
  • Adding a new reusable component
  • Registering a page in the fixture layer

Example prompts

  • “/page-objects”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Verify prerequisites
  2. Explore the live application (mandatory)
  3. Plan the page object's test coverage
  4. Build the class
  5. Register the page object
  6. Consume from tests via the fixture

What it can do on your machine

Read from SKILL.md and the folder at commit f6cbf35. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Page Objects loads about 3.6k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 175 tokens; SKILL.md has 1,158 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~175
When it runs · the whole SKILL.md, loaded when a task matches
~3.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from idavidov13/agentic-playwright at commit f6cbf35, republished under its MIT licence (© idavidov13). 1,158 words, ~3,553 tokens.

Download SKILL.mdSave it as .claude/skills/page-objects/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
page-objects
description
Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and the mandatory exploration-first workflow. Use when creating a new page object, adding or updating locators on an existing page object, adding a new reusable component, or registering a page in the fixture layer. For the locator priority order and feedback/validation-message rules see the selectors skill; for the terminal-only live-app exploration tool see the playwright-cli skill; for the DI wiring see the fixtures skill; for UI message strings and endpoint enums see the enums skill.
author
Ivan Davidov

Page Object Model

Critical

  • Locators are get accessors returning Locator. This is a style/readability convention — Playwright's Locator is lazy either way (it only queries the DOM when an action runs), so get vs readonly field behave identically at runtime. Use get for consistency with the rest of the scaffold.
  • Constructor uses private readonly page: Page. No other visibility modifiers, no alternative DI patterns.
  • Page objects import expect, Locator, Page from @playwright/test — never from fixtures/pom/test-options.ts (that's for spec files and fixtures).
  • JSDoc rules:
    • Forbidden on locator getters and on any method that returns a Locator. Names are self-documenting.
    • Required (with @param and @returns) on every action method and every verification method.
    • Allowed on component fields (e.g. readonly nav: NavigationComponent) — these are not locators.
  • Three locator sections when the page has forms or CRUD: interactive-element locators, feedback/validation-message locators, action methods. Feedback locators are not optional — see the selectors skill.
  • Feedback/message strings come from enums/{area}/* (e.g. Messages.LOGIN_ERROR). Never hardcoded strings inside getByText(...).
  • NEVER page.waitForTimeout(...) inside a page object. Use web-first assertions (await expect(locator).toBeVisible()) or page.waitForResponse(...).
  • Exploration with playwright-cli is mandatory before writing any locators (see the selectors skill's Exploration-First Workflow). No guessing from wireframes, docs, or screenshots. If the app is unavailable, stop and say so — never ship placeholder locators.
  • Register every new page object as a fixture in fixtures/pom/page-object-fixture.ts. Tests consume page objects through the fixture, never via new PageObject(page).

File Locations

{area} is a placeholder. Before creating or referencing any path below, run ls pages/ to discover the real subdirectory names in this repo (e.g., front-office, back-office) and use those instead.

TypeDirectoryNamingScaffold example
Page objectspages/{area}/[name].page.tspages/app/app.page.ts (AppPage)
Componentspages/components/[name].component.tspages/components/navigation.component.ts (NavigationComponent)

Page Object Pattern

typescript
import { expect, Locator, Page } from '@playwright/test';
import { Messages } from '../../enums/app/app';

export class ExamplePage {
    constructor(private readonly page: Page) {}

    // ==================== Locators ====================

    get emailInput(): Locator {
        return this.page.getByLabel('Email');
    }

    get submitButton(): Locator {
        return this.page.getByRole('button', { name: 'Submit' });
    }

    // ==================== Feedback Locators ====================

    get successMessage(): Locator {
        return this.page.getByText(Messages.LOGIN_SUCCESS);
    }

    get errorMessage(): Locator {
        return this.page.getByText(Messages.LOGIN_ERROR);
    }

    get requiredFieldError(): Locator {
        return this.page.getByText(Messages.REQUIRED_FIELD);
    }

    // ==================== Actions ====================

    /**
     * Submits the form and waits for the API response.
     * @param {string} email - The user's email address.
     * @returns {Promise<void>}
     */
    async submitForm(email: string): Promise<void> {
        await this.emailInput.fill(email);
        await this.submitButton.click();
        await this.page.waitForResponse((r) => r.url().includes('/api/submit'));
    }
}

Every page object that handles forms or CRUD operations must have three locator sections: interactive element locators, feedback/validation message locators, and action methods. Feedback locators are not optional — see the selectors skill for the full list of feedback types to capture.

Rules

Locators as getters

Use get accessor returning Locator. Both get and readonly field work identically at runtime (Playwright's Locator is lazy), but get is the scaffold convention — terser, locators stay grouped in the class body, constructor stays focused on dependencies.

typescript
// PREFERRED -- the scaffold's convention
get submitButton(): Locator {
    return this.page.getByRole('button', { name: 'Submit' });
}
Constructor pattern
typescript
constructor(private readonly page: Page) {}
No JSDoc on locators

JSDoc is forbidden on locator getters and on any method that returns a Locator. The name documents what it is:

typescript
// CORRECT -- no comment needed
get submitButton(): Locator {
    return this.page.getByRole('button', { name: 'Submit' });
}

// WRONG -- locators don't need JSDoc
/** The submit button. */
get submitButton(): Locator {
    return this.page.getByRole('button', { name: 'Submit' });
}

JSDoc is required on action methods and verification methods (see below).

Action methods and verification methods
  • Action methods represent complete user actions (login(), submitForm(), addToCart()).
  • Verification methods combine an action with a success assertion (loginAndVerify()). They may use expect(...) internally.
  • Plain action methods should not assert — the test asserts. Use a verification method when the success check is re-used across tests.
  • Always wait for API responses or state changes inside the method (page.waitForResponse, web-first assertions). Never page.waitForTimeout(...).
  • Always specify an explicit return type (Promise<void> is the common case).
  • JSDoc with @param and @returns is required; an @example block is encouraged for non-trivial methods.
Imports in page objects

Page objects import from @playwright/test (not from test-options.ts):

typescript
import { expect, Locator, Page } from '@playwright/test';

Component composition

Reusable UI fragments (headers, modals, sidebars) are defined as components and composed into page objects:

typescript
// pages/components/navigation.component.ts
import { Locator, Page } from '@playwright/test';

export class NavigationComponent {
    constructor(private readonly page: Page) {}

    get homeLink(): Locator {
        return this.page.getByRole('link', { name: 'Home' });
    }

    async clickHome(): Promise<void> {
        await this.homeLink.click();
    }

    async logout(): Promise<void> {
        await this.page.getByTestId('user-menu-button').click();
        await this.page.getByRole('button', { name: 'Logout' }).click();
    }
}

Compose components into page objects:

typescript
// pages/app/dashboard.page.ts
import { Page } from '@playwright/test';
import { NavigationComponent } from '../components/navigation.component';

export class DashboardPage {
    /** Navigation component for header/nav interactions */
    readonly nav: NavigationComponent;

    constructor(private readonly page: Page) {
        this.nav = new NavigationComponent(page);
    }
}

// Usage in tests
await dashboardPage.nav.clickHome();
await dashboardPage.nav.logout();

The nav: NavigationComponent field is a component, not a locator, so the JSDoc-forbidden rule does not apply — a short descriptive JSDoc is allowed.

Instructions

Phase 1: Verify prerequisites

Before writing any code:

  • Run ls pages/ to resolve {area} (e.g. app, front-office, back-office). Do not guess.
  • Identify which enums the page needs (Messages, ApiEndpoints, Roles, etc.). If a required enum member does not yet exist, extend it via the enums skill first — verify UI text with playwright-cli before encoding it.
  • Confirm the scaffold has a matching schema (for pages that trigger API calls you need to wait for / assert on) via ls fixtures/api/schemas/; if missing, create it via the api-testing skill.
Show full SKILL.md (524 more words)Show less
Phase 2: Explore the live application (mandatory)

Never create a page object from assumptions, wireframes, or documentation alone.

  1. Open and authenticate — use only playwright-cli in the terminal (not IDE browser MCP, not Cursor browser tools, not any substitute). Orchestrator rule: No Substitute UI Exploration. If the page doesn't load or auth fails, stop and notify the human.
  2. Explore like a user — navigate through the feature, trigger CRUD operations, observe forms, buttons, feedback messages, validation errors, and dynamic content.
  3. Record every observed element's role, accessible name, label, and (if applicable) test ID.

Read the full workflow in the selectors skill (.claude/skills/selectors/SKILL.md → "Exploration-First Workflow") and playwright-cli skill for the specific commands.

Forbidden: Skipping exploration. If the application is unavailable, say so and wait — do not create placeholder locators with guessed names.

Phase 3: Plan the page object's test coverage

Draft, in writing, which paths the page object needs to support:

  • Happy paths — the main user flow succeeds.
  • Validation paths — field-level rejections (empty, bad format, boundary).
  • Error paths — server rejections, surfaced via error feedback messages.
  • Edge cases — timeouts, intermittent network, concurrent edits, long strings.

The plan drives which feedback locators end up on the page object. A page with 5 happy-path buttons and 0 feedback locators is incomplete.

Phase 4: Build the class

Follow the Page Object Pattern above. Specifically:

  • Import expect, Locator, Page from @playwright/test.
  • Constructor: private readonly page: Page — plus component instantiation if composing.
  • Three locator sections (Interactive / Feedback / Actions), each separated by a visual header comment. Feedback locators reference enums/{area}/* values, never hardcoded strings.
  • Every action method: explicit return type, @param / @returns JSDoc, waits for API responses or state changes (web-first assertions or waitForResponse), no waitForTimeout.
  • Verification method naming: xxxAndVerify() — may use expect(...) internally.
  • Reusable fragments → component under pages/components/ and composed via a readonly field: ComponentClass in the page object (see Component composition above).
Phase 5: Register the page object

After creating the class, register it as a fixture in fixtures/pom/page-object-fixture.ts:

  1. Import the class.
  2. Add the property to FrameworkFixtures.
  3. Add the fixture body.
typescript
import { test as base } from '@playwright/test';
import { AppPage } from '../../pages/app/app.page';
import { DashboardPage } from '../../pages/app/dashboard.page';

export type FrameworkFixtures = {
    appPage: AppPage;
    dashboardPage: DashboardPage; // Add type
    resetStorageState: () => Promise<void>;
};

export const test = base.extend<FrameworkFixtures>({
    appPage: async ({ page }, use) => {
        await use(new AppPage(page));
    },
    dashboardPage: async ({ page }, use) => {
        await use(new DashboardPage(page)); // Add fixture
    },
    resetStorageState: async ({ context }, use) => {
        await use(async () => {
            await context.clearCookies();
            await context.clearPermissions();
        });
    },
});

No mergeTests() change needed — pageObjectFixture is already merged into fixtures/pom/test-options.ts. For the deeper DI rules (new fixture categories, lifecycle, Built-in Fixtures table) see the fixtures skill.

Phase 6: Consume from tests via the fixture
typescript
import { expect, test } from '../../../fixtures/pom/test-options';

test('should show error on bad login', async ({ appPage }) => {
    await appPage.openHomePage();
    await appPage.login('bad@example.com', 'wrong');
    await expect(appPage.errorMessage).toBeVisible();
});

Never new AppPage(page) inside a test. If the fixture feels too heavy, fix the fixture, don't bypass it.

See Also

  • selectors skill — exploration-first workflow (4 steps), selector priority order, feedback/validation message rules, forbidden patterns.
  • playwright-cli skill — the terminal-only live-app exploration tool (no IDE browser MCP substitutes).
  • fixtures skill — full DI rules, FrameworkFixtures / HelperFixtures, mergeTests, Built-in Fixtures table.
  • enums skill — where Messages.*, ApiEndpoints.*, Roles, StorageStatePaths live; how to add new values with live-text verification.
  • common-tasks skill — prompt templates for "Add a New Page Object (With / Without Exploration)" and "Add Locators to Existing Page".
  • api-testing skill — helper fixtures and factories used from page-object tests.
  • debugging skill — when a test using this page object fails, classify the failure (TimeoutError on action, locator returned multiple, etc.) and use the right tool to investigate before changing the page object.
  • references/examples.md — three end-to-end walkthroughs (new page, locator addition, component extraction).
  • references/troubleshooting.md — common page-object pitfalls and their fixes.

© idavidov13, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in .claude/skills/page-objects of idavidov13/agentic-playwright.

  • SKILL.md
  • references/examples.md
  • references/troubleshooting.md

Open the folder on GitHubat commit f6cbf35

Compare with similar skills

Page Objects next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Page Objects compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Page Objects this skillidavidov13/agentic-playwright223—~3.6kAutomated safety check: PassMIT
Tanstack Startasmyshlyaev177/test-proxy-recorder112—~2.9kAutomated safety check: NotesMIT
E2E Tests Studiomastra-ai/mastra29k—~4.3kAutomated safety check: PassCustom licence
React Testingaffaan-m/ECC275k1 repos~3.3kAutomated safety check: PassMIT
Web Application Testinganthropics/skills180k51 repos~966Automated safety check: PassApache-2.0
Playwright CLIsanity-io/sanity6.4k18 repos~1.9kAutomated safety check: PassMIT

Similar skills

  • Tanstack Start

    asmyshlyaev177/test-proxy-recorder

    Record and replay TanStack Start SSR with test-proxy-recorder.

    112 GitHub stars~2.9k tokensUpdated 4 days ago
    Testing & QAAuto-check: notes
  • E2E Tests Studio

    mastra-ai/mastra

    REQUIRED when modifying any file in packages/playground-ui or packages/playground.

    29k GitHub stars~4.3k tokensUpdated today
    Testing & QAAuto-check passed
  • React Testing

    affaan-m/ECC

    React component testing with React Testing Library, Vitest/Jest, MSW for network mocking, accessibility assertions with axe, and the decision boundary between component tests and Playwright/Cypress…

    275k GitHub starsUsed in 1 repo~3.3k tokens
    Testing & QAAuto-check passed
  • Web Application Testing

    anthropics/skills

    Official

    Tests local web applications with Python Playwright scripts, checking frontend behavior, capturing screenshots and reading browser console logs.

    180k GitHub starsUsed in 51 repos~966 tokens
    Testing & QAAuto-check passed
  • Playwright CLI

    sanity-io/sanity

    Official

    Automates browser interactions for web testing, form filling, screenshots, and data extraction.

    6.4k GitHub starsUsed in 18 repos~1.9k tokens
    Testing & QAAuto-check passed
  • Official

    Drives a real browser from the command line with playwright-cli to open pages, interact, mock requests, save state and work with Playwright tests.

    5.4k GitHub starsUsed in 24 repos~2.8k tokens
    Testing & QAAuto-check passed

More from idavidov13/agentic-playwright

All 13 skills in this repo
  • AI Native Workflow

    idavidov13/agentic-playwright

    Sole entry-point router for AI-assisted work on this Playwright scaffold — owns the 8-phase main workflow (classify → route → explore → plan+confidence → human gate → apply → verify → report), the…

    223 GitHub stars~3.5k tokensUpdated 7 days ago
    Auto-check passed
  • Common Tasks

    idavidov13/agentic-playwright

    Copy-paste AI prompt templates for common Playwright scaffold development tasks — adding page objects, functional/E2E/API tests, Zod schemas, factories, fixtures, and components.

    223 GitHub stars~2.5k tokensUpdated 7 days ago
    Auto-check passed
  • Data Strategy

    idavidov13/agentic-playwright

    Test data strategy for the Playwright scaffold — Faker + Zod factories for dynamic happy-path data, static TS files (.ts with as const exports — never .json) for domain-specific curated invalid…

    223 GitHub stars~3.4k tokensUpdated 7 days ago
    Auto-check passed
  • Selectors

    idavidov13/agentic-playwright

    Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector…

    223 GitHub stars~2.7k tokensUpdated 7 days ago
    Auto-check passed
  • Test Standards

    idavidov13/agentic-playwright

    Spec file conventions for the Playwright scaffold — imports from test-options.ts, test file structure (describe / beforeEach / test / test.step), single-tag rule, functional vs E2E vs API vs setup…

    223 GitHub stars~3.9k tokensUpdated 7 days ago
    Auto-check passed
  • Type Safety

    idavidov13/agentic-playwright

    TypeScript type safety conventions for the Playwright scaffold — the "no any" rule, Zod 4 schema patterns (z.strictObject, top-level validators like z.uuid / z.email / z.url / z.int / z.enum)…

    223 GitHub stars~3.5k tokensUpdated 7 days ago
    Auto-check passed

Works with

Categories

Questions about Page Objects

What does Page Objects do?

Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and…. Page Objects is an agent skill from idavidov13/agentic-playwright. Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and the mandatory exploration-first workflow.

When should I use Page Objects?

Page Objects fits situations like: creating a new page object; updating locators on an existing page object; adding a new reusable component; registering a page in the fixture layer.

How do I install Page Objects in Claude Code?

Run `npx skills add idavidov13/agentic-playwright --skill page-objects -a claude-code`. Or copy the skill folder (.claude/skills/page-objects in idavidov13/agentic-playwright) into .claude/skills/page-objects in your project. Claude Code loads it when a task matches its description.

How do I install Page Objects in Codex?

Run `npx skills add idavidov13/agentic-playwright --skill page-objects -a codex`. Or copy the skill folder (.claude/skills/page-objects in idavidov13/agentic-playwright) into .agents/skills/page-objects in your project. Codex loads it when a task matches its description.

Can I use Page Objects in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add idavidov13/agentic-playwright --skill page-objects -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/page-objects, .gemini/skills/page-objects, .github/skills/page-objects and .opencode/skills/page-objects in your project.

What does Page Objects need to run?

SKILL.md names no scripts, command-line tools or credentials: Page Objects is instructions for the agent only.

Does Page Objects access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Page Objects safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Page Objects use?

Page Objects is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Page Objects use?

About 3.6k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.4k tokens, read only when the agent opens those files.

What are the alternatives to Page Objects?

Skills that share tags, products or a category with Page Objects: Tanstack Start (asmyshlyaev177/test-proxy-recorder, 112 stars), E2E Tests Studio (mastra-ai/mastra, 29k stars), React Testing (affaan-m/ECC, 275k stars) and Web Application Testing (anthropics/skills, 180k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Page Objects?

idavidov13 (a GitHub user) maintains it in idavidov13/agentic-playwright, which has 223 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on October 1, 2026.

Source: idavidov13/agentic-playwright on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.