felix-starman

felix-starman

Bibbidi - Low-level Elixir client for W3C WebDriver BiDi

Bibbidi — W3C WebDriver BiDi Protocol for Elixir

I’m excited to share Bibbidi, a low-level Elixir implementation of the W3C WebDriver BiDi Protocol.

BEAM Interface to Browsers with BiDi — the name is a nod to the Fairy Godmother’s spell in Disney’s Cinderella.

What is WebDriver BiDi?

WebDriver BiDi is a bidirectional protocol for browser automation. Unlike classic WebDriver (HTTP request/response), BiDi uses a persistent WebSocket connection that lets you send commands and receive real-time events from the browser — think console logs, network requests, navigation events, and more. It’s the successor to CDP (Chrome DevTools Protocol) but is a W3C standard with cross-browser support.

What is Bibbidi?

Bibbidi is a building-block library. It gives you WebSocket connectivity, command/response correlation, and event dispatch, but imposes no supervision tree. You supervise Bibbidi.Connection processes yourself, exactly how you want.

It’s designed as a foundation for RPA frameworks, browser testing libraries, and anything else that needs to talk BiDi to a browser.

Features

  • Full protocol coverage — command builder modules for all BiDi domains: BrowsingContext, Script, Session, Input, Network, Storage, Browser, Emulation, Log, and WebExtension (although I’m adding more Integration tests to validate functionality)

  • Real-time events — subscribe to browser events and receive them as regular Erlang messages ({:bibbidi_event, method, params})

  • Swappable transport — ships with a mint_web_socket transport; bring your own via the Bibbidi.Transport behaviour

  • Browser lifecycleBibbidi.Browser GenServer can launch and manage browser OS processes for you (OS process “culling” PRs or comments would be appreciated, this is an area for improvement)

  • Types & events generated from the W3C CDDL spec — attempts to stay as close to the protocol definition as possible

  • No opinionated supervision — fits into any OTP application architecture (I may add Igniter recipes in the future that include some useful supervision abstractions, but ideally this is not part of the library)

  • Interactive Livebook — an included example with a Kino UI for navigating, clicking, running JS, taking screenshots, and watching live events

Quick example


{:ok, conn} = Bibbidi.Connection.start_link(url: "ws://localhost:9222/session")

{:ok, _caps} = Bibbidi.Session.new(conn)

{:ok, tree} = Bibbidi.Commands.BrowsingContext.get_tree(conn)

context = hd(tree["contexts"])["context"]

{:ok, _} = Bibbidi.Commands.BrowsingContext.navigate(conn, context, "https://example.com", wait: "complete")

{:ok, %{"result" => %{"value" => title}}} =

Bibbidi.Commands.Script.evaluate(conn, "document.title", %{context: context})

IO.puts("Page title: #{title}")

Supervision

Bibbidi doesn’t impose a process tree — add connections to your own supervisor:


children = [

{Bibbidi.Connection, url: "ws://localhost:9222/session", name: MyApp.Browser}

]

Supervisor.start_link(children, strategy: :one_for_one)

Try it in Livebook

The repo includes an Interactive Browser Livebook that lets you point-and-click navigate, run JavaScript, take screenshots, and watch browser events in real time.

Links

Installation


def deps do

[
  {:bibbidi, "~> 0.1.0"}
]

end

This is v0.1.0 and still fairly early, so feedback, bug reports, and contributions are very welcome! I’d love to hear what you think and what you’d like to build with it.

https://github.com/petermueller/bibbidi

Most Liked

felix-starman

felix-starman

A note: This was created with heavy use of LLMs, although the CDDL parsing did most of the codegen, and the actual GenServer parts aren’t particularly complicated.

For anyone curious on next steps, I’m planning to take a crack at making a bibbidi_wallaby or phoenix_test_bibbidi mainly to stress the interface, and because it won’t cause as many issues if the API needed to change, since end users would be less likely to interact w/ Bibbidi directly.

I’d also be adding some useful igniter generators of different supervision patterns that someone could use.

Medium time horizon, I want to play around with some dependent plugins in the vein of puppeteer-extra and it’s sub-project playwright-extra, in particular the stealth plugins

Longer term, once the interface is more stable (I may go to structs/protocols, we’ll see, FEEDBACK WELCOME!) I am hoping to have some useful graph-walking approaches and Jido examples w/ igniter templates. The idea being it could walk a graph to control the browser and/or have a Jido Agent able to work w/ JidoBrowser (I need to look into this more anyways) and Bibbidi to provide a full set of functionality and controls.

mikehostetler

mikehostetler

Felix, happy to collab on this! I have hit some of the same issues you ran into that prompted creating this package - would be interesting to discuss the best way forward.

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_orde...
New
blatyo
The best overview for how things are tied together is this presentation. Modules and functions are pretty well documented at this point, ...
New
sbs
Only 650 LOC, wrote for fun :slight_smile: https://github.com/sunboshan/qrcode
New
sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10858 107
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement