Testing with a Camera or Microphone

Prev Next

This article explains how to test applications that use a camera or microphone.

Allow permissions

Use this when you want the browser to automatically allow camera and microphone permissions in a specific scenario.

  1. Open the target scenario.

  2. Add a Playwright code step to Step 1.

  3. Enter the following Playwright code.

    await context.grantPermissions(['microphone', 'camera']);
    
  4. Click Save.

Use dummy video and audio

This section explains how to allow camera and microphone permissions and use dummy video/audio.

This setting affects all recordings and test runs executed in your local environment.

  1. Open Settings at the bottom of the menu.

  2. Open Advanced settings.

  3. Click the edit button for Enter JSON string, then enter the following JSON in the input field.

    {
      "permissions": ["microphone", "camera"],
      "launchOptions": {
        "args": [
          "--use-fake-device-for-media-stream",
          "--use-fake-ui-for-media-stream"
        ]
      }
    }
    
  4. Click Save.

Specify any file

This setting is available only for local runs and cannot be used for cloud runs.

If you want to use a specified audio/video file instead of dummy media, add the following configuration to launchOptions.args.

{
  "permissions": ["microphone", "camera"],
  "launchOptions": {
    "args": [
      "--use-fake-device-for-media-stream",
      "--use-fake-ui-for-media-stream",
      "--use-file-for-fake-audio-capture=/path/to/audio.wav",
      "--use-file-for-fake-video-capture=/path/to/video.y4m"
    ]
  }
}
  • --use-file-for-fake-audio-capture: Path to the audio file (WAV recommended)

  • --use-file-for-fake-video-capture: Path to the video file (Y4M recommended)

  • Specify the file path as an absolute path on your local machine.

Notes

  • Some video conferencing tools may not work in headless mode (mode where the browser is not displayed). If the test fails, turn off headless mode and run it again.