Skip to main content

bidiwave

WebDriver BiDi for Python — talk to any browser via W3C standard.

CI PyPI Python License

Features

  • W3C WebDriver BiDi — standard protocol, not proprietary CDP
  • Cross-browser — Chrome, Firefox, Edge (Safari when BiDi support lands)
  • Async-first — native async/await with asyncio
  • Browsing — contexts, navigation, screenshots, viewport control with DPR, element waiting, CSS/XPath locators, PDF printing, dialog handling, download events, history traversal, user prompt management
  • Script — evaluate JS, call functions, typed RemoteValue with match pattern narrowing, preload scripts with channel communication, realm inspection, serialization options, user activation
  • Input simulation — clicks, keyboard, scroll, drag & drop, file upload, file dialog events
  • Network interception — block, modify, mock requests, cache overrides, response body retrieval, authentication handling, extra headers, data collectors, cache behavior control
  • Storage — get, set, delete cookies with full attribute support, partition key support, cookie change monitoring
  • Emulation — geolocation, locale, screen orientation, timezone, user agent override, network conditions
  • Permissions — grant or deny browser permissions without user dialogs
  • Preload scripts — inject JS before page load for polyfills or monitoring with user context support
  • Web extensions — install and uninstall browser extensions
  • CDP bridge — access Chrome DevTools Protocol for browser-specific features
  • Event streaming — 27 event types with async handlers and error isolation
  • Type-safe — Pydantic v2 models, full type hints, mypy clean
  • Spec-compliant — W3C WebDriver BiDi (WD 2025-07-28), full coverage
  • Resilient — automatic reconnection with exponential backoff
  • Lightweight — no Selenium, no Playwright required

Install

pip install bidiwave

Quick start

import asyncio
from bidiwave import BiDiClient, StringValue

async def main():
    async with await BiDiClient.connect("ws://localhost:9515/session") as client:
        async with await client.browsing.open("https://example.com") as page:
            # Evaluate JS
            result = await page.evaluate("document.title")
            match result:
                case StringValue(value=title):
                    print(f"Title: {title}")

            # Screenshot
            screenshot = await page.screenshot()
            with open("screenshot.png", "wb") as f:
                f.write(screenshot)

asyncio.run(main())

Console log monitoring

async with await BiDiClient.connect(url) as client:
    async def on_log(entry):
        print(f"[{entry.level}] {entry.text}")

    client.on("log.entryAdded", on_log)
    await client.session.subscribe(["log.entryAdded"])

    async with await client.browsing.open("https://example.com") as page:
        await page.evaluate("console.log('hello!')")
        await asyncio.sleep(2)

Input simulation

async with await BiDiClient.connect(url) as client:
    async with await client.browsing.open("https://example.com") as page:
        ctx = page.id

        # Click at coordinates
        await client.input.click(ctx, x=100, y=200)

        # Type text
        await client.input.type_text(ctx, "Hello, world!")

        # Press Enter
        await client.input.press_key(ctx, "Enter")

        # Scroll down 500px
        await client.input.scroll(ctx, delta_y=500)

        # Drag and drop
        await client.input.drag_and_drop(ctx, 100, 100, 300, 300)

Network interception

async with await BiDiClient.connect(url) as client:
    # Block all requests to ads
    intercept = await client.network.add_intercept(
        phases=["beforeRequestSent"],
        url_patterns=["*ads.example.com*"],
    )

    async with await client.browsing.open("https://example.com") as page:
        await asyncio.sleep(2)

    await client.network.remove_intercept(intercept.intercept_id)

Cookies & storage

from bidiwave import Cookie

async with await BiDiClient.connect(url) as client:
    async with await client.browsing.open("https://example.com") as page:
        # Set a session cookie
        await client.storage.set_cookie(
            page.id,
            cookie=Cookie(
                name="session",
                value="abc123",
                domain="example.com",
                http_only=True,
                secure=True,
            ),
        )

        # Read all cookies
        cookies = await client.storage.get_cookies(page.id)
        for c in cookies:
            print(f"{c.name}={c.value}")

        # Delete one cookie
        await client.storage.delete_cookie(page.id, "session")

Emulation & permissions

from bidiwave import ViewportSize

async with await BiDiClient.connect(url) as client:
    async with await client.browsing.open("https://example.com") as page:
        ctx = page.id

        # Simulate iPhone viewport
        await client.browsing.set_viewport(
            ctx,
            viewport=ViewportSize(width=375, height=812),
            device_pixel_ratio=3.0,
        )

        # Simulate Tokyo location on 3G
        await client.emulation.set_geolocation_override(
            coordinates={"latitude": 35.6762, "longitude": 139.6503, "accuracy": 1.0},
            contexts=[ctx],
        )
        await client.emulation.set_network_conditions(
            network_conditions={
                "offline": False,
                "download_throughput": 50000,
                "upload_throughput": 25000,
                "latency": 400,
            },
            contexts=[ctx],
        )

        # Grant geolocation permission
        await client.permissions.set_permission(
            descriptor={"name": "geolocation"},
            state="granted",
            contexts=[ctx],
        )

Preload scripts

async with await BiDiClient.connect(url) as client:
    # Inject a script that runs before every page load
    result = await client.preload.add_preload_script(
        function_declaration="() => { window.__testMode = true; }",
    )

    async with await client.browsing.open("https://example.com") as page:
        value = await page.evaluate("window.__testMode")
        print(f"Test mode: {value}")

    await client.preload.remove_preload_script(result.script)

Web extensions

async with await BiDiClient.connect(url) as client:
    # Install a browser extension
    result = await client.web_extension.install("/path/to/extension.crx")
    print(f"Installed: {result}")

    # Uninstall when done
    await client.web_extension.uninstall(result.extension)

Launch a browser with BiDi

Chrome / Edge

# Chrome — requires ChromeDriver as BiDi proxy
chromedriver --port=9515

# Edge — requires EdgeDriver
msedgedriver --port=9516

Firefox

Firefox implements BiDi natively — no driver needed:

firefox --headless --remote-debugging-port=9223 --no-remote

See Browser Setup for detailed instructions.

Documentation

Full documentation at mathiaspaulenko.github.io/bidiwave

License

MIT

Metadata

Release files for bidiwave 1.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bidiwave 1.8.2
File Size Uploaded
bidiwave-1.8.2.tar.gz 141.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bidiwave 1.8.2
File Interpreter ABI Platform
bidiwave-1.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 193.6 kB

Release files / bidiwave-1.8.2.tar.gz

Download URL bidiwave-1.8.2.tar.gz
Size 141.0 kB
Tags Source
SHA-256 checksum
How to use checksums
02bf3d42d2e26e75462f0e9af95fcac9b8f1e7934945afda8bc3ece18dc502b8
BLAKE2b-256 checksum
How to use checksums
b682a86e1def6439f26c386adc5d7bb6515bc7c7b1ec90286c1fd092de263101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.

Transparency log

Release files / bidiwave-1.8.2-py3-none-any.whl

Download URL bidiwave-1.8.2-py3-none-any.whl
Size 52.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03b048cff2f124d17819cbe3dec7997524ff40f4ed0d37b994b5748b0513f289
BLAKE2b-256 checksum
How to use checksums
6c5603dfdd5d4879ab7665c29cd5489c0ab24cd7ea02558b32145ef1c5bf4125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.8.2 This release

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page