← Back to microsoft/playwright
microsoft / playwright · Issue No. 40819
When using expect.soft(), the Playwright HTML report should capture and attach a screenshot at the exact moment each soft assertion fails, instead of only capturing the final screen at the end of the test.
Expected Behavior
expect.soft() should have its own screenshot attached in the HTML report.Test Code
import { test, expect } from "@playwright/test";
test("Verify Login Heading and login flow", { tag: ["@orangeHRM"] }, async ({ page }) => {
await page.goto("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login");
// Verify Login Heading ← This fails
await expect.soft(page.locator("h5.orangehrm-login-title")).toHaveText("Sign in", { timeout: 10000 });
await page.getByPlaceholder("Username").fill("Admin");
await page.getByPlaceholder("Password").fill("admin123");
await page.getByRole("button", { name: "Login" }).click();
// Verify Dashboard Heading ← This passes
await expect.soft(page.getByText("Dashboard")).toBeVisible();
});
Current Behavior:
Even though only the first soft assertion failed (on the login screen), and the test successfully logged in and reached the dashboard, the Playwright HTML report shows the Dashboard screenshot.
As visible in the attached report screenshot:
Desired Behavior:
Playwright should capture a screenshot at the moment each expect.soft() fails.
In this case, the report should show:
This allows developers to instantly see the visual state corresponding to each soft assertion failure without needing to rerun the test or dig deep into traces.
Soft assertions expect.soft() are one of the most powerful features in Playwright Test. They allow tests to continue running after failures so that multiple issues can be identified in a single test execution. This is extremely useful for validating forms, dashboards, checkout flows, and other complex UI scenarios.
However, the built-in HTML reporter currently only captures a screenshot of the final page state at the end of the test. When a soft assertion fails early and the test continues (performing more actions, navigation, or state changes), the screenshot shown in the report no longer reflects the UI at the time of the failure.
This creates a frustrating debugging experience where the visual evidence is often misleading or irrelevant to the actual failing assertion.
This feature will make Playwright better by:
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.