Open sourcePlaywright OpenTelemetry

Configure the fixture

Switch your tests to the instrumented fixture to propagate trace context and capture screenshots.

The fixture propagates trace context to enable nested spans, and captures the screenshots shown with the trace. Import its test in place of Playwright's:

import { expect } from "@playwright/test";
import { test } from "playwright-opentelemetry/fixture";

test("has title", async ({ page }) => {
	await page.goto("https://playwright.dev/");

	await expect(page).toHaveTitle(/Playwright/);
});

Screenshots

The fixture captures screenshots of every page in a test through Playwright's page.screencast API, sharing the browser's existing screencast rather than starting a second one. Alongside screenshots, it records where pointer and element actions (such as clicks, fills, and drags) landed so the trace viewer can highlight them; typed input values are not recorded. Both are stored with the trace and follow the trace retention settings. They don't depend on Playwright's own trace screenshots, so you can set screenshots: false in Playwright's trace option.

Tests can still use page.screencast themselves. To turn screenshots (and action highlights) off, set use.playwrightOpentelemetry.screenshots to false.

Last updated