---
title: Selenium BiDi
description: Learn how to integrate Allure with Selenium WebDriver 4 to capture browser logs and network events via the BiDi protocol as diagnostics in your test report.
---

# Getting started with Allure Selenium BiDi

[![Allure Selenium BiDi latest version](https://img.shields.io/maven-central/v/io.qameta.allure/allure-selenium-bidi?style=flat "allure-selenium-bidi")](https://mvnrepository.com/artifact/io.qameta.allure/allure-selenium-bidi)

Capture browser log events and network events from [Selenium WebDriver 4](https://www.selenium.dev/) tests using the BiDi protocol, and attach them as diagnostics to your [Allure Report](https://allurereport.org/) test results. The integration targets Selenium WebDriver 4 with BiDi support and is validated against Selenium Java 4.44.

Allure Selenium BiDi is compatible with any Allure Java framework integration, including [Allure JUnit 5](/docs/junit5/) and [Allure TestNG](/docs/testng/). Requires Java 17 or newer.

To enable the integration in your project:

1. Make sure you have an Allure integration set up for the test framework you use.

   See the instructions in the integration's documentation in [Frameworks](/docs/frameworks/).

2. Add `allure-selenium-bidi` to your project dependencies.

   **Maven:**
   ```xml
   <!-- Define the version of Allure you want to use via the allure.version property -->
   <properties>
       <allure.version>VERSION</allure.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>

   <dependencies>
       <dependency>
           <groupId>io.qameta.allure</groupId>
           <artifactId>allure-selenium-bidi</artifactId>
           <scope>test</scope>
       </dependency>
   </dependencies>
   ```

   **Gradle (Kotlin):**
   ```kts
   val allureVersion = "VERSION"

   dependencies {
       testImplementation(platform("io.qameta.allure:allure-bom:$allureVersion"))
       testImplementation("io.qameta.allure:allure-selenium-bidi")
   }
   ```

   **Gradle (Groovy):**
   ```groovy
   def allureVersion = "VERSION"

   dependencies {
       testImplementation platform("io.qameta.allure:allure-bom:$allureVersion")
       testImplementation "io.qameta.allure:allure-selenium-bidi"
   }
   ```

3. Enable BiDi on your WebDriver options.

   ```java
   ChromeOptions options = new ChromeOptions().enableBiDi();
   ```

   BiDi must be enabled at the driver level — without it, the integration silently produces no attachments. Check your browser's Selenium documentation for BiDi support.

4. Decorate your WebDriver instance with `AllureWebDriverBiDi`.

   ```java
   import io.qameta.allure.seleniumbidi.AllureWebDriverBiDi;

   AllureWebDriverBiDi bidi = new AllureWebDriverBiDi();
   WebDriver driver = bidi.decorate(new ChromeDriver(options));
   ```

   Use the decorated driver for all test interactions. When `driver.quit()` is called, the collected browser log and network events are flushed as JSON attachments to the active test result.

   Info:
   Events are only captured and attached while there is an active Allure test context. Browser activity that happens outside of a test — for example, in setup code that runs before any test starts — is not captured. Similarly, if `driver.quit()` is called after the test has ended (for example, in teardown code that runs after the test result is finalized), the collected events are not attached.

5. Run your tests and generate a test report the same way as you would normally.

## Report output

Each test result receives up to two JSON attachments:

- **WebDriver BiDi logs** — browser log events including console output (`console.log`, `console.warn`, `console.error`, etc.), uncaught JavaScript exceptions, and other generic browser log entries.
- **WebDriver BiDi network** — network events: `beforeRequestSent`, `responseStarted`, `responseCompleted`, and `fetchError`.

An attachment is omitted when no events of that type were received during the test and none were dropped.

Sensitive header values are [redacted by default](/docs/selenium-bidi-configuration/#redacting-headers). See [configuration](/docs/selenium-bidi-configuration/) to control which event types are captured, set per-test entry limits, or customize header redaction. See [reference](/docs/selenium-bidi-reference/) for the full attachment schema.

## Closing the listener manually

Attachments are flushed when `driver.quit()` is called on the decorated driver. To flush earlier — for example, before teardown logic runs — call `bidi.close()` explicitly:

```java
bidi.close(); // flush buffered events as attachments now
driver.quit(); // then quit the browser — no second flush occurs
```

Info:
`close()` has the same context requirement as `driver.quit()`: events are only attached if an active Allure test context exists when `close()` is called. If you call it after the test result has been finalized, the collected events are discarded.

After `close()`, the subsequent `driver.quit()` does not produce a second flush — the session has already been removed.
