Skip to content
Allure report logoAllure Report
Main Navigation ModulesDocumentationStarter Project

English

Español

English

Español

Appearance

Sidebar Navigation

Allure 3

Install & Upgrade

Install Allure

Upgrade Allure

Configure

Create Reports

How to generate a report

How to view a report

Improving readability of your test reports

Improving navigation in your test report

Reading Allure charts

Migrate from Allure 2

Allure 2

Install & Upgrade

Install for Windows

Install for macOS

Install for Linux

Install for Node.js

Upgrade Allure

Create Reports

How to generate a report

How to view a report

Improving readability of your test reports

Improving navigation in your test report

Features

Agent Mode

Test steps

Attachments

Test statuses

Assertion diffs

Sorting and filtering

Environments

Multistage Builds

Categories

Visual analytics

Test stability analysis

History and retries

Quality Gate

Global Errors and Attachments

Timeline

Export to CSV

Export metrics

Guides

JUnit 5 parametrization

JUnit 5 & Selenide: screenshots and attachments

JUnit 5 & Selenium: screenshots and attachments

Setting up JUnit 5 with GitHub Actions

Pytest parameterization

Pytest & Selenium: screenshots and attachments

Pytest & Playwright: screenshots and attachments

Pytest & Playwright: videos

Playwright parameterization

Publishing Reports to GitHub Pages

Allure Report 3: XCResults Reader

How it works

Overview

Glossary

Test result file

Container file

Categories file

Environment file

Executor file

History files

Test Identifiers

Integrations

Azure DevOps

Bamboo

GitHub Action

Gradle

Jenkins

JetBrains IDEs

Maven

TeamCity

Visual Studio Code

Frameworks

AVA

Getting started

Configuration

Reference

Axios

Getting started

Configuration

Reference

Behat

Getting started

Configuration

Reference

Behave

Getting started

Configuration

Reference

Bun

Getting started

Configuration

Reference

Chai

Getting started

Reference

Codeception

Getting started

Configuration

Reference

CodeceptJS

Getting started

Configuration

Reference

Cucumber.js

Getting started

Configuration

Reference

Cucumber-JVM

Getting started

Configuration

Reference

Cucumber.rb

Getting started

Configuration

Reference

Cypress

Getting started

Configuration

Reference

Fetch

Getting started

Configuration

Reference

Go

Getting started

Configuration

Reference

Jasmine

Getting started

Configuration

Reference

JBehave

Getting started

Configuration

Reference

Jest

Getting started

Configuration

Reference

JUnit 4

Getting started

Configuration

Reference

JUnit 5

Getting started

Configuration

Reference

Mocha

Getting started

Configuration

Reference

Newman

Getting started

Configuration

Reference

Node.js Test Runner

Getting started

Configuration

Reference

NUnit

Getting started

Configuration

Reference

PHPUnit

Getting started

Configuration

Reference

Playwright

Getting started

Configuration

Reference

Playwright Java

Getting started

Configuration

Reference

pytest

Getting started

Configuration

Reference

Pytest-BDD

Getting started

Configuration

Reference

Reqnroll

Getting started

Configuration

Reference

REST Assured

Getting started

Configuration

Robot Framework

Getting started

Configuration

Reference

Rust Cargo Test

Getting started

Configuration

Reference

RSpec

Getting started

Configuration

Reference

SpecFlow

Getting started

Configuration

Reference

Spock

Getting started

Configuration

Reference

TestCafe

Getting started

Configuration

Reference

TestNG

Getting started

Configuration

Reference

Vitest

Getting started

Configuration

Reference

WebdriverIO

Getting started

Configuration

Reference

xUnit.net

Getting started

Configuration

Reference

On this page

Allure Playwright Java reference ​

These are the classes and methods you can use to integrate your Playwright Java tests with Allure.

AllurePlaywright ​

io.qameta.allure.playwright.AllurePlaywright

A utility class with static methods for registering Playwright objects, capturing browser artifacts, and managing the per-test Playwright state. All methods are thread-safe and safe to call when no Allure test is active.

register ​

  • AllurePlaywright.register(Page page)
  • AllurePlaywright.register(BrowserContext context)

Register a Playwright Page or BrowserContext for automatic failure diagnostics. Registered objects are used as sources for screenshots, page source, and page log attachments when a test fails or is broken.

Registering a Page also registers its parent BrowserContext.

When AspectJ weaving is active, pages and contexts are registered automatically in two ways: when created via browser.newPage(), browser.newContext(), or context.newPage(); and when any intercepted Playwright action is performed on a page while a test is active. Explicit registration is only needed for objects created and used exclusively outside an active test (for example, in a @BeforeAll setup).

java
import io.qameta.allure.playwright.AllurePlaywright;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.Page;

Page page = browser.newContext().newPage();
AllurePlaywright.register(page);

BrowserContext context = browser.newContext();
AllurePlaywright.register(context);

attachScreenshot ​

  • AllurePlaywright.attachScreenshot(String name, Page page)

Capture a screenshot of the given page and attach it to the current Allure test or step. This call does not produce an additional Allure step.

Pass null or an empty string as name to use the default attachment name Screenshot.

java
AllurePlaywright.attachScreenshot("Before submit", page);
AllurePlaywright.attachScreenshot(null, page);  // attached as "Screenshot"

attachPageSource ​

  • AllurePlaywright.attachPageSource(String name, Page page)

Capture the current HTML of the given page and attach it as a text/html attachment.

Pass null or an empty string as name to use the default attachment name Page source.

java
AllurePlaywright.attachPageSource("Page source", page);

attachConsoleMessages ​

  • AllurePlaywright.attachConsoleMessages(String name, Page page)

Attach the console messages collected by the given page since it was created. Each message is formatted as [type] text (location). Empty output is not attached.

Pass null or an empty string as name to use the default attachment name Console messages.

java
AllurePlaywright.attachConsoleMessages("Browser console", page);

attachPageErrors ​

  • AllurePlaywright.attachPageErrors(String name, Page page)

Attach the uncaught JavaScript errors collected by the given page since it was created. Each error is written on its own line as plain text. Empty output is not attached.

Pass null or an empty string as name to use the default attachment name Page errors.

java
AllurePlaywright.attachPageErrors("Page errors", page);

attachTrace ​

  • AllurePlaywright.attachTrace(String name, Path traceZip)

Attach an existing Playwright trace archive (zip file) to the current Allure test or step.

Pass null or an empty string as name to use the default attachment name Playwright trace.

java
AllurePlaywright.attachTrace("Login trace", Path.of("trace.zip"));

attachVideo ​

  • AllurePlaywright.attachVideo(String name, Path videoFile)

Attach an existing video file to the current Allure test or step. WebM files are attached with the video/webm media type; other extensions are attached as application/octet-stream.

Pass null or an empty string as name to use the default attachment name Playwright video.

java
AllurePlaywright.attachVideo("Test recording", Path.of("video.webm"));

startTracing ​

  • AllurePlaywright.startTracing(BrowserContext context): TraceSession
  • AllurePlaywright.startTracing(String name, BrowserContext context): TraceSession

Start Playwright tracing on the given BrowserContext with screenshots and DOM snapshots enabled, and return a TraceSession that can stop and attach the trace.

The context is registered for failure diagnostics automatically.

Pass a name to control the attachment name. The default name is Playwright trace.

Use try-with-resources to guarantee that tracing is stopped and the archive is attached even if the test throws:

java
try (TraceSession trace = AllurePlaywright.startTracing("Checkout trace", context)) {
    page.navigate("https://example.com");
    page.click("#checkout");
}

If the context is closed before TraceSession.close() is called, the trace is still attached automatically. If the test ends while the session is still open, the trace is attached before the test result is written.

beforeTest ​

  • AllurePlaywright.beforeTest()

Clear the Playwright registry before a test starts. Call this at the start of each test when no Allure framework integration is managing the lifecycle automatically.

Any open trace sessions present at this point are stopped without attaching.

afterTest ​

  • AllurePlaywright.afterTest()

Attach pending console messages, page errors, and open trace sessions for registered pages and contexts, then clear the Playwright registry. Call this at the end of each test when no Allure framework integration is managing the lifecycle automatically.

Videos are attached when page.close(), context.close(), or browser.close() is called, not by this method.

afterTestFailure ​

  • AllurePlaywright.afterTestFailure()
  • AllurePlaywright.afterTestFailure(Throwable throwable)

Attach failure diagnostics — screenshots, page source, and open trace sessions — for all registered pages. This is called once per test; duplicate calls within the same test are ignored.

Call this from your failure handler or @AfterEach equivalent when no Allure framework integration is managing the lifecycle automatically. The Throwable overload accepts the causing exception for debug logging.

java
// In an @AfterEach or equivalent
try {
    testBody.run();
} catch (Throwable t) {
    AllurePlaywright.afterTestFailure(t);
    throw t;
} finally {
    AllurePlaywright.afterTest();
}

TraceSession ​

io.qameta.allure.playwright.TraceSession

Represents an active Playwright trace session started by AllurePlaywright.startTracing(). Implements AutoCloseable.

attach ​

  • TraceSession.attach()

Stop the trace and attach the generated archive to the current Allure test or step. Equivalent to close().

close ​

  • TraceSession.close()

Stop the trace and attach the generated archive to the current Allure test or step. Use try-with-resources to call this automatically:

java
try (TraceSession trace = AllurePlaywright.startTracing(context)) {
    // browser actions
}
Pager
Previous pageConfiguration
Next pageGetting started
Powered by

Subscribe to our newsletter

Get product news you actually need, no spam.

Subscribe
Allure TestOps
  • Overview
  • Why choose us
  • Cloud
  • Self-hosted
  • Success Stories
Company
  • Documentation
  • Blog
  • About us
  • Contact
  • Events
© 2026 Qameta Software Inc. All rights reserved.
A Markdown version of this page is available at /docs/playwright-java-reference.md