Skip to main content
The Android emulator routes audio played on the runner host through to the emulator’s microphone input. Use device.passAudioAsMicrophoneInput(...) to play an audio file during a flow — your app will receive it as microphone input.
Store your audio file in team storage and reference it via process.env.TEAM_STORAGE_DIR. See Upload files for instructions.

Examples

Inject audio into the microphone
await device.passAudioAsMicrophoneInput({
  data: `${process.env.TEAM_STORAGE_DIR}/audio.mp3`,
  durationSeconds: 10,
});
Pull a recording off the emulator
await device.adb(`pull '/sdcard/Recordings/My recording 1.m4a' ${process.env.TEAM_STORAGE_DIR}/recorded.m4a`);

When to use

  • Your app records audio or processes microphone input and you need to test that flow with known audio data.
  • Your app has voice commands or speech recognition features.
  • Your app validates or analyzes microphone input.
  • Your test needs to run the same audio scenario repeatedly with consistent inputs.

Options

passAudioAsMicrophoneInput accepts delaySeconds (wait before playback starts) and durationSeconds (cap playback length; omit to play the whole file). See the Android Device Reference for the full signature.

Full sample test

import { device, flow } from "@qawolf/flows/android";

const audioPath = `${process.env.TEAM_STORAGE_DIR}/audio.mp3`;

export default flow(
  "Test audio recording",
  { target: "Android - Pixel", launch: true },
  async ({ driver, test }) => {
    await test("record injected audio and verify it was saved", async () => {
      // Arrange
      await driver.$(`//*[@text='Record Audio']`).click();
      await driver.pause(3_000);

      // Act
      await device.passAudioAsMicrophoneInput({
        data: audioPath,
        durationSeconds: 10,
      });

      await driver.$(`//*[@text='Record']`).click();
      await driver.pause(10_000);
      await driver.$(`//*[@text='Done']`).click();

      // Assert
      await driver.$(`//*[@text='Open Audio']`).waitForDisplayed({ timeout: 5_000 });
    });
  },
);
Last modified on June 4, 2026