agentleFS
idavidov13idavidov13/agentic-playwright/.agents/skills/page-objects/SKILL.md

page-objects

Skill268 starsChanged 9 days agoMITView on GitHub

Use when creating a page object or component under pages/**, adding locators or action methods to one, or registering it as a fixture. Not for choosing a selector or the exploration workflow (see `selectors`) or for fixture internals (see `fixtures`).

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every new page object is registered in fixtures/pom/page-object-fixture.ts.

    line 30
  2. Very specific:

    Run ls pages/ to resolve {area}.

    line 34
  3. Very specific:

    Write the class from references/class-pattern.md: locators in priority order (selectors), feedback locators, action methods with explicit …

    line 37
  4. Very specific:

    Run npm run lint; write or update the spec per test-standards and run it.

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Page Objects

Critical

  • Explore the live page with playwright-cli before writing any locator (selectors). If the app is unreachable, stop and say so; never ship placeholder locators.
  • Locators are get accessors returning Locator. The constructor is constructor(private readonly page: Page). Imports come from @playwright/test, never from fixtures/pom/test-options.ts.
  • JSDoc is Forbidden on locator getters and on any method returning a Locator. JSDoc with @param and @returns is required on every action and verification method.

    // CORRECT
    get submitButton(): Locator {
        return this.page.getByRole('button', { name: 'Submit' });
    }
    // WRONG
    /** The submit button. */
    get submitButton(): Locator {
        return this.page.getByRole('button', { name: 'Submit' });
    }
  • A page object for a form or CRUD screen has three groups: interactive locators, feedback locators (success, error, field validation), action methods. Feedback locators are not optional; selectors lists what to capture.
  • Strings inside getByText(...) come from enums/{area}/* (Messages.LOGIN_ERROR), never literals.
  • Action methods do not assert; a verification method named xxxAndVerify() may call expect. Waits are page.waitForResponse(...) or web-first assertions, never page.waitForTimeout(...).
  • A fragment shared by several pages (header, modal, sidebar) is a component in pages/components/, held as readonly nav: NavigationComponent and created in the constructor.
  • Every new page object is registered in fixtures/pom/page-object-fixture.ts; tests receive it from the fixture (fixtures).

Procedure

  1. Run ls pages/ to resolve {area}. File: pages/{area}/<name>.page.ts, or pages/components/<name>.component.ts for a fragment.
  2. Explore the page with playwright-cli per selectors; record each element's role, accessible name, label or test id, and the exact text of every feedback message.
  3. A message or route that has no enum member yet is added per enums before the class is written.
  4. Write the class from references/class-pattern.md: locators in priority order (selectors), feedback locators, action methods with explicit return types and JSDoc.
  5. A fragment used by more than one page becomes a component per references/components.md.
  6. Register: import the class, add it to FrameworkFixtures, add the fixture body, each shaped like the appPage entries in fixtures/pom/page-object-fixture.ts. No mergeTests change.
  7. Run npm run lint; write or update the spec per test-standards and run it.

References

  • references/class-pattern.md: the full class with the three groups, one action method and one verification method.
  • references/components.md: a component, its composition into a page, when to split a large page object.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.