Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.qawolf.com/llms.txt

Use this file to discover all available pages before exploring further.

Use Playwright’s fake media device flags to inject a pre-recorded audio file as the browser’s microphone input. This lets you test voice-activated features, speech recognition, and audio processing in web apps under controlled, repeatable conditions.
WAV format is recommended. Store your audio file in team storage and reference it via process.env.TEAM_STORAGE_DIR. See Upload files for instructions.
Playwright initializes the fake audio device once per browser instance. You cannot swap the audio file mid-flow. If you need to test with different audio inputs, launch a new browser instance for each.

Examples

Inject audio into the browser microphone
const { context } = await launch({
  permissions: ["microphone"],
  args: [
    "--use-fake-device-for-media-stream",
    "--use-fake-ui-for-media-stream",
    `--use-file-for-fake-audio-capture=${process.env.TEAM_STORAGE_DIR}/voice-input.wav`,
  ],
});

const page = await context.newPage();
await page.goto("https://your-app.com");

// trigger the feature that reads from the microphone

When to use

  • Your app has speech recognition and you need to test that specific voice commands are interpreted correctly.
  • Your app has voice-activated controls and you need to verify they produce the expected behavior.
  • Your app processes or transforms microphone input and you need to assert on the output.
  • Your app has voice-controlled accessibility features and you need to confirm they work as expected.

Full sample test

import { flow, launch } from "@qawolf/flows/web";

export default flow(
  "Test voice input",
  "Web - Chrome",
  async ({ test }) => {
    const { context } = await launch({
      permissions: ["microphone"],
      args: [
        "--use-fake-device-for-media-stream",
        "--use-fake-ui-for-media-stream",
        `--use-file-for-fake-audio-capture=${process.env.TEAM_STORAGE_DIR}/voice-input.wav`,
      ],
    });

    const page = await context.newPage();

    await test("inject audio and verify voice command response", async () => {
      // Arrange
      await page.goto("https://your-app.com/voice");
      await page.locator(`[data-testid='mic-button']`).waitFor({ state: "visible" });

      // Act
      await page.locator(`[data-testid='mic-button']`).click();
      await page.waitForTimeout(5_000);

      // Assert
      await expect(page.locator(`[data-testid='transcript']`)).toContainText("hello");
    });
  },
);
Last modified on May 20, 2026