---
title: "Dashcam Replays"
sidebarTitle: "Dashcam"
description: "Learn how to use Dashcam to record and replay test sessions in TestDriver."
icon: "video"
---

[Dashcam](https://www.dashcam.io), from the makers of TestDriver, is a powerful feature in TestDriver that allows you to record and replay your test sessions. This is particularly useful for debugging, sharing test runs with team members, or reviewing the steps taken during a test. For the full docs see the [Dashcam docs](https://docs.dashcam.io/dashcam/).

## Recording a Test Session

To record a test session, you can use the `dashcam` command in your lifecycle scripts. There are two main lifecycle scripts where you can integrate Dashcam: `lifecycle/prerun.yaml` and `lifecycle/postrun.yaml`.

## Ways to use Dashcam

Dashcam comes as a standalone app and a Chrome extension. You can use either or both to capture your test sessions.

<Info>
  To capture web logs, make sure to install the Dashcam Chrome extension on the
  browser you are testing with. We recommend installing it via CLI to Chrome for
  Testing. You can also find the extension [in the Chrome
  Webstore](https://chromewebstore.google.com/detail/dashcam/dkcoeknmlfnfimigfagbcjgpokhdcbbp)
</Info>

### Installing the Dashcam Chrome extension via command line in prerun.yaml

In this lifecycle script, we install Chrome for Testing with a user profile that has the password manager disabled and sets up TestDriver Dashcam for replays and logs.

```yaml lifecycle/prerun.yaml [expandable]
- prompt: launch chrome for testing and setup dashcam
    commands:
      # this script installs chrome for testing with a userprofile that has password manager disabled and sets up TestDriver Dashcam for replays and logs
      - command: exec
        lang: pwsh
        code: |
          cd $env:TEMP
          Write-Host "Changed directory to TEMP: $env:TEMP"

          Write-Host "Running 'npm init -y'..."
          npm init -y

          Write-Host "Installing dependencies: @puppeteer/browsers and dashcam-chrome..."
          npm install @puppeteer/browsers dashcam-chrome

          Write-Host "Installing Chromium via '@puppeteer/browsers'..."
          npx @puppeteer/browsers install chrome

          # Define paths
          $extensionPath = Join-Path (Get-Location) "node_modules/dashcam-chrome/build"
          $profilePath = Join-Path $env:TEMP "chrome-profile-$(Get-Random)"

          Write-Host "Extension path: $extensionPath"
          Write-Host "Chrome user data dir: $profilePath"

          # Validate extension path
          if (-not (Test-Path $extensionPath)) {
              Write-Host "Extension not found at $extensionPath"
          }

          $chromeArgs = @(
            "--start-maximized",
            "--load-extension=$extensionPath",
            "--user-data-dir=$profilePath",
            "--no-first-run",
            "--no-default-browser-check",
            "--disable-infobars"
            "${TD_WEBSITE}"
          ) -join ' '

          Start-Process "cmd.exe" -ArgumentList "/c", "npx @puppeteer/browsers launch chrome -- $chromeArgs"

          Write-Host "Script complete."
          exit 0
```

### Using the Chrome extension and capturing web logs

Now in the same `lifecycle/prerun.yaml` script, we set up Dashcam to track web logs and application logs. You can customize the patterns to match your needs. Testing Desktop? You can skip the web logs and just track application logs.

```yaml lifecycle/prerun.yaml
...
- command: exec
    lang: pwsh
    code: |
        dashcam track --name="Web Logs" --type="web" --pattern="*"
        dashcam track --name=TestDriver --type=app --pattern="C:\Users\testdriver\Documents\testdriver.log"
```

### Starting Dashcam

The final step in our `lifecycle/prerun.yaml` script is to start Dashcam recording.

```yaml lifecycle/prerun.yaml
...
- command: exec
    lang: pwsh
    code: dashcam start
```

### Publishing replays to a project in your account

Lastly, in the `lifecycle/postrun.yaml` script, we publish the recorded Dashcam session to a project in your Dashcam account. Make sure to replace `<YOUR_PROJECT_ID>` with the actual ID of your project.

```yaml lifecycle/postrun.yaml
- prompt: send dashcam recording to server
    # this script tells TestDriver Dashcam to send the recording to the server
  commands:
    - command: exec
        lang: pwsh
        code: dashcam -t '${TD_THIS_FILE}' -p -k <YOUR_PROJECT_ID> # optional add `-k MYFOLDERID` for the id of a folder in your Projects page at app.testdriver.ai
```

<Info>
  `${TD_THIS_FILE}` is an environment variable set by TestDriver that contains
  the name of the current test file being executed. This will be used as the
  title of the Dashcam recording. For more info see [parallel testing
  docs](/features/parallel-testing).
</Info>
