Skip to content

feat: add formFiller to declaratively fill forms in page objects - #49

Open
foxable wants to merge 1 commit into
mainfrom
feat/fill-form
Open

foxable wants to merge 1 commit into
mainfrom
feat/fill-form

Conversation

@foxable

@foxable foxable commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Adds formFiller, a helper to fill forms in page objects from a data object.

  • Each key maps to a form input: anything with a fill method (e.g. a Locator or a nested page object) or a filler function such as (checked) => checkbox("Accept").setChecked(checked)
  • undefined values are skipped
  • fields are filled in the order of the fields object
  • formFiller can be nested because it returns a filler function
import { formFiller, roleLocators } from "@cronn/playwright-utils";
import type { Page } from "@playwright/test";

interface Registration {
  name: string;
  email?: string;
}

function createRegistrationForm(page: Page) {
  const { button, textbox } = roleLocators(page);

  return {
    submitButton: button("Register"),
    fill: formFiller<Registration>({
      name: textbox("Name"),
      email: textbox("Email"),
    }),
  };
}

@foxable foxable self-assigned this Sep 29, 2026
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3315509

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cronn/playwright-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@foxable
foxable force-pushed the feat/fill-form branch 2 times, most recently from 41b6bcd to 1ff991b Compare September 29, 2026 15:47
@foxable foxable changed the title feat: add fillForm to declaratively fill forms in page objects feat: add formFiller to declaratively fill forms in page objects Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant