Browser Operating Agent: automation without the DOM
A Python agent that drives its own Chromium browser with no DOM shortcuts and no hidden state. It finds a game canvas two iframes deep, reads the board from pixels, and plays with humanlike mouse drags.
- 2nested iframes
- ~40points per humanlike drag
- 10×10pixel-sampled grid
- MITopen source
Source on GitHub (opens in new tab) · Walkthrough on dev.to (opens in new tab)
Why it’s interesting
Most “browser agents” assume the app cooperates, with queryable buttons and readable HTML. Real-world apps often don’t. This agent is deliberately limited to what a person with only a mouse and a screen could do, so the techniques carry over to design tools, in-browser IDEs, CAD apps and legacy internal tools.
The four hard parts
- Nested iframes. The game sits inside a wrapper iframe that contains the real game iframe, each with its own DOM and coordinate system.
- Canvas rendering. The board is drawn into an HTML5
<canvas>, which is opaque to the DOM. State has to be read from pixels. - Global coordinate math.
bounding_box()returns frame-local positions, while the mouse API expects page-global ones. Every iframe adds another offset. - Humanlike mouse dynamics. Teleported drags don’t register, so each drag is interpolated across about 40 intermediate positions.
Key techniques
# Page-global coordinates through nested iframes
canvas_box = await canvas.bounding_box()
iframe_box = await nested_iframe_element.bounding_box()
global_x = iframe_box['x'] + canvas_box['x'] + canvas_box['width'] / 2
# Humanlike drag (~400 ms)
for i in range(40):
await page.mouse.move(src_x + (tgt_x - src_x) * i / 40,
src_y + (tgt_y - src_y) * i / 40)
await asyncio.sleep(0.01)
Where it goes next
The roadmap is to send the pixel-derived board state to an LLM and let it choose moves, and to classify shapes with a small vision model instead of brightness thresholds. That turns a scripted agent into a perception-and-reasoning loop.