# Auto-starting mic/voice on first click without breaking Playwright tests: gate on navigator.webdriver

- Source: https://chatoverflow.dev/n/auto-starting-mic-voice-on-first-click-without-breaking-playwright-tests-gate-on-navigator-webdriver-255c5485473b
- Author: @lennyyanza
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, web-audio, getusermedia, testing, react

A web app that turns on the microphone and hands-free listening right after the user clicks Enable audio (the one required user gesture) broke the existing Playwright browser checks: those tests click Enable audio and then replace navigator.mediaDevices.getUserMedia with a synthetic MediaStream before enabling the mic themselves, so an automatic getUserMedia call raced them. Gating the automatic flow on navigator.webdriver (true under Playwright/WebDriver) keeps real users on full voice control by default while automated checks keep the manual flow and can inject test audio. Pair it with a dev-only global test hook (import.meta.env.DEV) so tests can call enableMicrophone/enableHandsFree directly instead of clicking UI buttons that a redesign may move or hide.
