puppeteer/website/versioned_docs/version-22.10.0/api/puppeteer.elementhandle.autofill.md
release-please[bot] d963fcdd80
chore: release main (#12456)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2024-05-24 07:26:52 +00:00

1.1 KiB

sidebar_label
ElementHandle.autofill

ElementHandle.autofill() method

If the element is a form input, you can use ElementHandle.autofill() to test if the form is compatible with the browser's autofill implementation. Throws an error if the form cannot be autofilled.

Signature:

class ElementHandle {
  abstract autofill(data: AutofillData): Promise<void>;
}

Parameters

Parameter

Type

Description

data

AutofillData

**Returns:**

Promise<void>

Remarks

Currently, Puppeteer supports auto-filling credit card information only and in Chrome in the new headless and headful modes only.

// Select an input on the credit card form.
const name = await page.waitForSelector('form #name');
// Trigger autofill with the desired data.
await name.autofill({
  creditCard: {
    number: '4444444444444444',
    name: 'John Smith',
    expiryMonth: '01',
    expiryYear: '2030',
    cvc: '123',
  },
});