Playwright browserContext.credentials registers virtual passkeys
Introduced 2026-06-15 · score 0.99
HOW TO USE IT
When testing a passkey login without a physical key, seed a virtual credential in the browser context, install the authenticator before navigation, then open the login page.
const context = await browser.newContext();
await context.credentials.create('example.com', {
id: '<credentialId>',
userHandle: '<userHandle>',
privateKey: '<privateKey>',
publicKey: '<publicKey>',
});
await context.credentials.install();
const page = await context.newPage();
await page.goto('https://example.com/login');const context = await browser.newContext();
await context.credentials.install();
const page = await context.newPage();
await page.goto('https://example.com/register');
await page.getByRole('button', { name: 'Create a passkey' }).click();
const [credential] = await context.credentials.get({ rpId: 'example.com' });const context = await browser.newContext();
await context.credentials.create('<rpId>', <credential>);
await context.credentials.install();
const page = await context.newPage();
await page.goto('https://example.com/login');WHY THIS HELPS
Test a passkey login flow in a browser context without a physical security key.
REQUIREMENTS AND LIMITATIONS
- Version: v1.61.0
- rpId (required): Relying party ID, typically the site's effective domain.
- options.id: Base64url credential ID; auto-generated if omitted.
- options.userHandle: Base64url user handle; auto-generated if omitted.
- options.privateKey: Base64url PKCS#8 (DER) private key; auto-generated if omitted.
- options.publicKey: Base64url SPKI (DER) public key; auto-generated if omitted.
- credentials.install() (required): Takes no parameters; installs interception for page WebAuthn calls. Call before the page first uses WebAuthn.
- Prerequisite: Use Playwright v1.61 or later; the credentials API was added in v1.61.
- Prerequisite: Call credentials.install() before navigating to a page that uses WebAuthn; otherwise seeded credentials are not exposed to the page.
- No real hardware key is required.
- Works in all browsers.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.61.0
- https://playwright.dev/docs/api/class-credentials
Check the installed version and the source before using it. Entry JSON