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

Getting started with Allure Playwright Java ​

Allure Playwright Java latest version

Generate beautiful HTML reports using Allure Report and your Playwright Java tests.

Setting up ​

Allure Playwright Java works alongside your test framework — set up JUnit 5 or TestNG first, then add the steps below.

To integrate Allure Playwright into your project, you need to:

  1. Add Allure Playwright dependencies.
  2. Set up the AspectJ weaving agent.
  3. Specify a location for Allure results storage.

Add Allure dependencies ​

xml
<!-- Define the version of Allure you want to use via the allure.version property -->
<properties>
    <allure.version>VERSION</allure.version>
    <aspectj.version>1.9.25.1</aspectj.version>
</properties>

<!-- Add allure-bom to dependency management to ensure correct versions of all the dependencies are used -->
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-bom</artifactId>
            <version>${allure.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Add necessary Allure dependencies to dependencies section -->
<dependencies>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-playwright</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
kts
val allureVersion = "VERSION"
val aspectjVersion = "1.9.25.1"

val aspectjAgent: Configuration by configurations.creating

dependencies {
    testImplementation(platform("io.qameta.allure:allure-bom:$allureVersion"))
    testImplementation("io.qameta.allure:allure-playwright")
    testRuntimeOnly("org.aspectj:aspectjrt:$aspectjVersion")
    aspectjAgent("org.aspectj:aspectjweaver:$aspectjVersion")
}
groovy
def allureVersion = "VERSION"
def aspectjVersion = "1.9.25.1"

configurations {
    aspectjAgent
}

dependencies {
    testImplementation platform("io.qameta.allure:allure-bom:$allureVersion")
    testImplementation "io.qameta.allure:allure-playwright"
    testRuntimeOnly "org.aspectj:aspectjrt:$aspectjVersion"
    aspectjAgent "org.aspectj:aspectjweaver:$aspectjVersion"
}

Set up the AspectJ agent ​

Allure Playwright uses AspectJ to intercept Playwright API calls at runtime and record them as Allure steps. The AspectJ weaver must be attached to the JVM when tests run.

xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.2.3</version>
    <configuration>
        <argLine>
            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
        </argLine>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
    </dependencies>
</plugin>
kts
tasks.test {
    doFirst {
        jvmArgs("-javaagent:${configurations["aspectjAgent"].singleFile}")
    }
}
groovy
test {
    doFirst {
        jvmArgs "-javaagent:${configurations.aspectjAgent.singleFile}"
    }
}

Specify Allure results location ​

Allure saves test results in the project's root directory by default. It is recommended to store results in the build output directory instead.

Create an allure.properties file in src/test/resources:

properties
allure.results.directory=target/allure-results
properties
allure.results.directory=build/allure-results
properties
allure.results.directory=build/allure-results

Generate a report ​

After running your tests, convert the results into an HTML report using one of these commands:

  • allure generate processes the test results and saves an HTML report into the allure-report directory. To view the report, use the allure open command.

  • allure serve creates the same report as allure generate, then automatically opens the main page of the report in a web browser.

Browser actions as steps ​

With the AspectJ agent active, Allure Playwright automatically intercepts calls to the Playwright Java API and records them as steps in the test report. No additional code is required.

The following Playwright types are intercepted:

  • Page, Frame, Locator, ElementHandle — browser interaction methods
  • Playwright assertion classes — assertThat(...) assertions

Step names are generated from the method name and its arguments. For example:

java
page.click("button");                 // → "Click button"
page.navigate("https://example.com"); // → "Navigate to https://example.com"
page.hover(".menu-item");             // → "Hover .menu-item"
page.fill("#search", "query");        // → "Fill #search with <redacted>"
page.type("#comment", "text");        // → "Type <redacted> into #comment"
page.screenshot();                    // → "Take screenshot" step, with a "Screenshot" attachment inside it

Values passed to fill(), type(), and press() are replaced with <redacted> in step names by default to avoid exposing passwords and other sensitive data. See configuration to change this behavior.

Playwright action steps are nested under any enclosing Allure steps you define:

java
Allure.step("Checkout flow", () -> {
    page.click("button");   // appears as a sub-step of "Checkout flow"
});

By default, only recognized browser interaction methods (click, fill, navigate, hover, check, type, dragTo, waitForSelector, and more) and Playwright assertions are recorded as steps. To record every public Playwright API method call, set allure.playwright.steps.mode=all in allure.properties.

Capturing browser artifacts ​

Allure Playwright captures browser artifacts automatically and also provides helpers for manual capture.

On test failure ​

When a test fails or is broken, Allure Playwright automatically captures a screenshot and the current page source for each registered page, and attaches them to the test result.

This requires pages or contexts to be registered, either explicitly or automatically (see Registering pages and contexts).

On close ​

When a Page, BrowserContext, or Browser is closed while a test is active, Allure Playwright automatically collects:

  • Console messages — browser console output accumulated since the page was created (controlled by allure.playwright.close.page-logs).
  • Page errors — uncaught JavaScript exceptions (controlled by allure.playwright.close.page-logs).
  • Video — if the context was created with video recording enabled (controlled by allure.playwright.close.video).
  • Trace — if tracing was started with AllurePlaywright.startTracing() (controlled by allure.playwright.close.trace). See Trace capture for the full set of triggers; closing an individual Page does not trigger trace attachment.

Console messages and page errors are also captured when the test ends for any registered pages whose context was not explicitly closed during the test.

See configuration for details on each setting.

Manual capture ​

You can capture and attach any of these artifacts at any point during a test using the static helpers on AllurePlaywright:

java
import io.qameta.allure.playwright.AllurePlaywright;

// Attach a screenshot of the current page state
AllurePlaywright.attachScreenshot("Before submit", page);

// Attach the current page HTML
AllurePlaywright.attachPageSource("Page source", page);

// Attach console messages collected by the page
AllurePlaywright.attachConsoleMessages("Browser console", page);

// Attach uncaught JavaScript errors
AllurePlaywright.attachPageErrors("Page errors", page);

// Attach an existing trace archive
AllurePlaywright.attachTrace("Playwright trace", Path.of("trace.zip"));

// Attach an existing video file
AllurePlaywright.attachVideo("Test recording", Path.of("video.webm"));

All helpers are safe to call when no Allure test is active — they do nothing in that case.

Registering pages and contexts ​

Allure Playwright tracks registered pages and contexts and uses them to capture screenshots, page source, console messages, and page errors when a test fails.

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 (such as click or fill) is performed on a page while a test is active. Auto-registration only applies while a test is active; objects created and used exclusively before the test starts, such as in a @BeforeAll setup, must be registered explicitly.

For pages or contexts created outside of Playwright's standard factory methods, or outside an active test, register them explicitly:

java
AllurePlaywright.register(page);
AllurePlaywright.register(context);

Registering a Page also registers its parent BrowserContext.

Trace capture ​

Playwright traces record browser activity as a rich archive that can be opened in the Playwright Trace Viewer. Allure Playwright can start a trace and attach the resulting archive automatically.

Use AllurePlaywright.startTracing() to begin tracing a browser context. The returned TraceSession stops tracing and attaches the archive when closed:

java
import io.qameta.allure.playwright.AllurePlaywright;
import io.qameta.allure.playwright.TraceSession;

BrowserContext context = browser.newContext();

try (TraceSession trace = AllurePlaywright.startTracing(context)) {
    // run browser actions
}
// trace archive is now attached to the test result

Tracing is also stopped and attached automatically when:

  • The BrowserContext or Browser is closed while a test is active (controlled by allure.playwright.close.trace).
  • The test fails while a trace is still open (always, regardless of allure.playwright.close.trace).
  • The test ends while a trace is still open (controlled by allure.playwright.close.trace).

To assign a custom name to the trace attachment, use the overload that accepts a name:

java
TraceSession trace = AllurePlaywright.startTracing("Login flow trace", context);

Framework lifecycle integration ​

When allure-playwright is on the classpath alongside any Allure framework integration, lifecycle integration is configured automatically — no additional setup is needed.

For test frameworks without an Allure integration, call the following methods in your test setup and teardown. beforeTest() must run before the test body, and afterTest() must run after it — typically in a @BeforeEach/@AfterEach pair. Detecting failure requires intercepting the test body exception before it propagates:

java
import io.qameta.allure.playwright.AllurePlaywright;

// Before the test body runs (@BeforeEach or equivalent)
AllurePlaywright.beforeTest();

// Wrap the test body execution to detect failure:
try {
    // test body
} catch (Throwable t) {
    AllurePlaywright.afterTestFailure(t);
    throw t;
} finally {
    AllurePlaywright.afterTest();
}

Environment information ​

For the main page of the report, you can collect various information about the environment in which the tests were executed.

To provide environment information, put a file named environment.properties into the allure-results directory after running the tests. See the example in Environment file.

properties
os.name=Linux
java.version=17.0.10
browser=chromium
playwright.version=1.60.0
Pager
Previous pageReference
Next pageConfiguration
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.md