Passkeys E2E Playwright Testing via WebAuthn Virtual Authenticator
Passkeys E2E Playwright Testing via WebAuthn Virtual Authenticator
Learn to set up E2E testing for passkeys across browsers with Playwright, Nightwatch, Selenium, and Puppeteer using the WebAuthn virtual authenticator.
Author: Anders
Created: March 30, 2024
Updated: October 5, 2026
Table of Contents
Buy vs. Build Guide
Practical guidance, rollout patterns and KPIs for passkey programs.
Key Facts
- CDP-based frameworks like Playwright and Puppeteer share identical WebAuthn virtual authenticator API calls, making Playwright test examples directly reusable in Puppeteer line-by-line.
- The automaticPresenceSimulation option controls whether passkey input triggers automatically or requires explicit initiation. Manual mode (false) improves readability and prevents unintended Conditional UI completions.
- WebDriver-based frameworks like Selenium and Nightwatch cannot attach event listeners to passkey operations, unlike CDP implementations which emit credentialAdded and credentialAsserted events on success.
- Setting isUserVerified to false simulates a canceled passkey input, but no built-in event signals completion, requiring hard timeouts as a workaround in test code.
- The WebAuthn virtual authenticator cannot replicate hardware-specific security features or simulate nuanced differences between platform and cross-platform authenticator types.
1. Introduction: Passkeys E2E Testing
Passkeys are becoming more widely accepted as an authentication method, relying on Web Authentication (WebAuthn) as its underlying standard. This guide aims to fill the gap in documentation and resources regarding the use and testing of passkeys.
2. Background: Browser Automation and E2E Testing Frameworks
2.1. What is Browser Automation?
Browser automation is the process of automating repetitive user actions in a browser, primarily for testing web applications.
2.2. What is WebDriver?
WebDriver is a remote-controlled interface serving as a middleman between the client and the browser, providing support for all major browsers.
2.3. What is Chrome DevTools Protocol (CDP)?
CDP eliminates the need for a middleman and uses socket connections for faster communication between the client and the browser.
3. What Makes E2E Testing of Passkeys with Playwright a Problem?
Testing passkey implementations presents various challenges, particularly around user interactions involved in biometric authentication, which complicate the writing of tests.
4. WebAuthn Virtual Authenticator Makes E2E Passkey Testing Possible
Using the WebAuthn virtual authenticator simplifies testing by emulating the behavior of physical authenticators.
5. How to Set Up WebAuthn Virtual Authenticator in Playwright
Example of implementing WebAuthn virtual authenticator in Playwright:
test('signup with passkey', async ({ page }) => {
const client = await page.context().newCDPSession(page);
await client.send('WebAuthn.enable');
const result = await client.send('WebAuthn.addVirtualAuthenticator', {
options: {
protocol: 'ctap2',
transport: 'internal',
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
automaticPresenceSimulation: false,
},
});
});
6. WebAuthn Virtual Authenticator Use Cases
6.1. How to Simulate Passkey Input Attempt in Playwright
Simulating successful and canceled passkey inputs can be managed through the WebAuthn virtual authenticator settings.
7. Alternatives to the WebAuthn Virtual Authenticator
Explore testing with mock services and real authenticators to enhance testing processes.
8. Recommendations for Developers
Developers are encouraged to understand the underlying concepts of passkeys and choose the appropriate testing frameworks based on project needs.
9. Summary
This guide covers using CDP WebAuthn virtual authenticator with Playwright, highlighting advanced concepts and the functionality across various automation protocols.