The Simplest Way to Make Playwright and Webauthn Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use playwright and webauthn together to test strong browser logins without real hardware keys. The test tool creates a virtual key in the browser to finish the login check. This workflow lets teams test passkey logins on every code push. Developers do not need to touch a physical thumb drive during test runs. The browser handles the cryptographic check inside the isolated test session. Your pipeline stays fast while your login rules stay strict. How login checks and data flow between pl

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use playwright and webauthn together to test strong browser logins without real hardware keys. The test tool creates a virtual key in the browser to finish the login check.

This workflow lets teams test passkey logins on every code push. Developers do not need to touch a physical thumb drive during test runs. The browser handles the cryptographic check inside the isolated test session. Your pipeline stays fast while your login rules stay strict.

How login checks and data flow between playwright and webauthn

The test runner starts a clean browser session for each test case. It talks to the browser automation protocol to turn on a virtual key tool. This virtual tool acts just like a hardware security key or phone passkey.

When the web app asks for a passkey, the browser intercepts the request. The virtual tool creates a public and private key pair in memory. It sends the public key back to the app server during sign up.

During a login test, the app server sends a random challenge to the browser. The virtual tool signs this challenge with its stored private key. The app server checks the signature against the public key and grants entry. All keys disappear as soon as the test session ends.

Common failure modes and how to scope test roles

Many teams skip passkey tests because hardware prompts block automated browser scripts. Instead, they create weak bypass accounts or share long-lived tokens across test runs. These shared test accounts often have broad permissions and weak audit logs.

If a shared token leaks from a build server, attackers gain broad entry. Shared accounts also fail when two test jobs run at the same time. One test can log out or change the state of another test.

Right to Erasure Implementation + FIDO2 / WebAuthn: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

A better pattern scopes each test run to a fresh, low-privilege user role. The test script creates a new user and attaches a virtual key right away. Network rules should also limit where test runners can send traffic.

Test runners should only reach staging apps and isolated test databases. If test scripts query real user tables, masking rules should rewrite matched fields in results. Masking can rewrite emails, phone numbers, card numbers, and national IDs during test checks.

Managing browser state and key lifecycles in test pipelines

Running virtual keys for every single test can slow down large test suites. Teams can save the signed-in browser state after the first passkey check. Later tests in the same run can load this saved session state.

Still, saved session files must never leave the current build job. Never store active session files in shared code repos or public build artifacts. Delete all saved browser states and test users when the pipeline finishes.

You should also test failure cases with your virtual key setup. Have the virtual tool send a bad signature or cancel the login prompt. This confirms that your app blocks bad keys and shows a clear message.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can automated browser tests use a real hardware security key?

No, real hardware keys need a physical touch from a human to sign challenges. Automated tests must use a virtual key inside the browser protocol instead.

Do virtual passkeys work across all browser engines in test runs?

Support depends on the underlying browser automation protocol used during the test run. Chromium browsers have full support through the standard developer protocol for virtual keys.

How should teams handle passkey recovery flows in automated tests?

Your test script can remove the virtual key from the browser session mid-test. Then the script can walk through your backup login or key reset screens.

The query runs. The emails stay hidden.