Use device.startSpeakerRecording() to capture audio output from the iOS device speaker while your app is playing audio. The recording is saved as a WAV file that can be downloaded and analyzed.
See the iOS Device Reference for the full API.
Examples
Record and download speaker audio
const session = await device.startSpeakerRecording(driver);
// trigger audio playback in your app
const file = await device.stopSpeakerRecording(driver, session.id);
const buffer = await device.downloadSpeakerRecording(driver, file.filename);
const { writeFile } = await import("node:fs/promises");
await writeFile("/tmp/output.wav", buffer);
When to use
- Your app plays audio and you need to verify the correct sound or track played.
- Your app uses text-to-speech and you need to validate the spoken output.
- Your app plays audio prompts and you need to confirm they play correctly after an update.
- Your test needs to capture audio output for comparison against a known reference.
Analyzing the recording
To compare the recording against a reference file, see Audio analysis (iOS).
stopSpeakerRecording() automatically calculates a Chromaprint fingerprint and includes it as file.fingerprint. You can use this directly for audio analysis without calling calculateAudioFingerprint() separately.
Full sample test
import { device, flow } from "@qawolf/flows/ios";
export default flow(
"Record speaker audio",
{ target: "iOS - iPhone 15 (iOS 26)", launch: true },
async ({ driver, test }) => {
await test("record audio and verify file was captured", async () => {
// Arrange
await driver.$(`//XCUIElementTypeButton[@name='Play']`).waitForDisplayed({ timeout: 10_000 });
// Act
const session = await device.startSpeakerRecording(driver);
await driver.$(`//XCUIElementTypeButton[@name='Play']`).click();
await driver.pause(10_000);
const file = await device.stopSpeakerRecording(driver, session.id);
const buffer = await device.downloadSpeakerRecording(driver, file.filename);
// Assert
expect(buffer.length).toBeGreaterThan(0);
const { writeFile } = await import("node:fs/promises");
await writeFile("/tmp/output.wav", buffer);
});
},
);