Skip to main content

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

Project description

bidiwave

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

CI PyPI Python License

Features

  • W3C WebDriver BiDi — estándar, no CDP propietario
  • Cross-browser — Chrome, Firefox, Edge (Safari cuando soporte BiDi)
  • Async-firstasync/await nativo con asyncio
  • Event streaming — console logs, navegación, network, contexts en tiempo real
  • Input simulation — clicks, keyboard, scroll, drag & drop via input.performActions
  • Network interception — bloquear, modificar y mockear requests HTTP
  • Type-safe — Pydantic v2 models, type narrowing con match
  • Sin dependencias pesadas — no requiere Selenium, no requiere Playwright

Install

pip install bidiwave

Quick start

import asyncio
from bidiwave import BiDiClient, StringValue

async def main():
    async with await BiDiClient.connect("ws://localhost:9222/session") as client:
        await client.session.new()

        async with await client.browsing.open("https://example.com") as page:
            # Evaluar 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.context

        # 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)

Lanzar un browser con BiDi

Chrome

google-chrome --headless=new --remote-debugging-port=9222 --enable-bidi

Firefox

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

Documentation

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bidiwave-1.5.0.tar.gz (77.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bidiwave-1.5.0-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file bidiwave-1.5.0.tar.gz.

File metadata

  • Download URL: bidiwave-1.5.0.tar.gz
  • Upload date:
  • Size: 77.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bidiwave-1.5.0.tar.gz
Algorithm Hash digest
SHA256 dea60e11c805f32ff3d47892fdadb89a25a3748ae643183ba27f20b84e568443
MD5 3662ea06aa0774b4b89a5f1f13df3801
BLAKE2b-256 35e98c9929b8962ba41a1e85dd3e6f4ee87d953114eb66417abbd339b8682414

See more details on using hashes here.

Provenance

The following attestation bundles were made for bidiwave-1.5.0.tar.gz:

Publisher: release.yml on MathiasPaulenko/bidiwave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bidiwave-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: bidiwave-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bidiwave-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5ca6cf592683704b80000515d56aae1240559f87a5f1dd0a40517e84e330c9b
MD5 7c38c70985078afb336e2d63bf6ba52e
BLAKE2b-256 4ebf8e5e5a81edfbec47ea2d681626567ab867be3a63bd0e20e30495c31578c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for bidiwave-1.5.0-py3-none-any.whl:

Publisher: release.yml on MathiasPaulenko/bidiwave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page