How a Browser Agent Sees a Web Page: DOM, AX Tree, Pixels
By BlogLLM
5 days ago · Edited 8 hours ago
7 min read
An agent cannot act on what it cannot see. So the first job of any browser agent is perception: turn a live page into something a model can read in one prompt. This part shows four ways to look at the same page, what browser-use 0.x built from them, and what 1.0 does instead.
Animation: the Wikipedia "Web browser" page shrinks from 532,732 characters of HTML to 500 named controls an agent can act on. Numbers from a real Chromium run on November 28, 2026.
Problem: the DOM is the truth, but most of it is noise
The DOM holds every element. On the Wikipedia "Web browser" article it held 6,532 nodes (counted with CDP, piercing shadow roots and frames). Most of those are wrappers, text nodes and hidden parts. A model does not need 6,532 nodes. It needs the few things a person could click or type into.
Loading 3D diagram…
One Wikipedia page, five views: 532,732 characters of HTML, 6,532 DOM nodes, 5,131 accessibility nodes, 500 named controls and a 1440 x 757 screenshot. Measured in a real Chromium run, Nov 28, 2026.
The same page as stacked layers. Drag to rotate. Each layer is smaller than the one below it, and the model only reads the top ones.
Solution: filter the accessibility tree down to named controls
Chrome builds a second tree for screen readers: the accessibility tree. Each node has a role, such as button or link, and a name, such as "Search". That is already close to what an agent wants.
This cell keeps only nodes with a control role and a name, then gives each one an index. It ran in the browser-use 1.0.9 REPL on the same page:
python
CONTROLS = {'button','link','textbox','searchbox','combobox','checkbox','radio','tab','menuitem'}
def v(o): return (o or {}).get('value')
acts = [n for n in ax if not n.get('ignored') and v(n.get('role')) in CONTROLS and v(n.get('name'))]
from collections import Counter
print('actionable AX nodes:', len(acts))
print(Counter(v(n['role']) for n in acts).most_common())
lines = [f"[{i}] {v(n['role'])} \"{v(n['name'])[:60]}\" (backend {n.get('backendDOMNodeId')})" for i, n in enumerate(acts)]
listing = '\n'.join(lines)
print('indexed listing chars:', len(listing))
print('\n'.join(lines[:12]))
Real output:
text
actionable AX nodes: 500
[('link', 478), ('button', 13), ('radio', 8), ('searchbox', 1)]
indexed listing chars: 20347
[0] link "Jump to content" (backend 74)
[1] link "Wikipedia The Free Encyclopedia" (backend 108)
[2] button "Main menu" (backend 60)
[3] button "Search" (backend 114)
[4] button "145 languages" (backend 64)
[5] link "Parsoid" (backend 4088)
[6] link "Creative Commons Attribution-ShareAlike 4.0 License" (backend 4093)
[7] link "Terms of Use" (backend 4096)
[8] link "Privacy Policy" (backend 4099)
[9] link "Wikimedia Foundation, Inc." (backend 4102)
[10] link "Privacy policy" (backend 4107)
[11] link "About Wikipedia" (backend 4110)
Wikipedia 'Web browser': node counts
Data from the sources listed below.
The backend node id at the end of each line is the key. It is Chrome's handle for that element. With it, the harness can ask Chrome where the element is on screen and click there. Note the order: footer links appear early here because the AX tree order is not the visual order. A good serializer fixes that.
Problem: a list of 500 links is still too much, and order matters
Wikipedia is link-heavy. An indexed list of all 500 controls was 20,347 characters, about the same as the page text. So the list alone is not the win. The win comes from two more filters: what is visible right now, and what is on top.
How 0.x did it: three CDP calls and a serializer
browser-use 0.13.14 (the last 0.x line) built its view in dom/service.py. It fired three CDP requests in parallel:
DOMSnapshot.captureSnapshot with computed styles, paint order and DOM rects,
DOM.getDocument(depth=-1, pierce=True) for the full tree, including shadow roots,
Accessibility.getFullAXTree for every frame,
then waited up to 10 seconds with a retry. Its serializer then decided what was interactive. clickable_elements.py checks JavaScript click listeners, iframes bigger than 100 x 100 pixels, labels and more. A paint-order filter (PaintOrderRemover with a RectUnion) drops elements hidden under others, and a bounding-box filter drops children that sit inside a clickable parent.
The result was an indexed list sent with every prompt, plus colored boxes drawn on the page.
Real screenshot, re-created overlay. We drew one box per visible actionable element using DOM.getBoxModel on each backend node id. 96 of the 500 were in the first viewport. browser-use 1.0 does not draw this; it shows orange corner brackets for one second on the element it acts on, and keeps them out of its own screenshots.
How 1.0 does it: the model asks for what it needs
browser-use 1.0 drops the always-on extraction. The model gets a screenshot and writes code to read what it wants. The system prompt in agent/prompt.py tells it to "Prefer the accessibility tree for discovery", gives a recipe for clicking the center of an element's box model, and warns that "IDs expire after navigation".
The launch post backs this with data from 199 traces: the agents used about 47 distinct CDP commands. Accessibility.getFullAXTree appeared in 126 traces, DOM.getBoxModel in 107 and Input.dispatchMouseEvent in 54. Left to choose, models went to the AX tree.
Ultrafast mode: a compact text view, built for you
For speed, 1.0 also ships an ultrafast mode. The source file ax.py describes itself as a Python port of Browser Use Pi's src/ax.ts. It adds bu.state(), bu.click(id) and bu.type(id, text). bu exists only in this mode.
This scripted run opened Wikipedia's main page with mode='ultrafast':
python
new_tab('https://en.wikipedia.org/wiki/Main_Page'); wait_for_load()
s = bu.state()
print(len(s), 'chars')
print(s[:2500])
The first lines of the real output:
text
[state] Wikipedia, the free encyclopedia | https://en.wikipedia.org/wiki/Main_Page
[64] link "Jump to content"
[14] button "Main menu"
[98] link "Wikipedia The Free Encyclopedia"
[13] searchbox "Search Wikipedia"
[104] button "Search"
[109] link "Donate"
[112] link "Create account"
[115] link "Log in"
[122] link "Main Page"
[125] link "Talk"
[130] link "Read"
[133] link "View source"
[136] link "View history"
[139] link "Save"
[18] button "Tools"
Appearance
[209] button "Hide Appearance"
Text
[23] radio "Small" unchecked
Small
[24] radio "Standard" checked
Standard
It mixes controls (with ids and state such as checked) and plain text lines in reading order. By default it stops at 3,000 characters and says how many lines it cut, so the prompt stays small. On this page the returned state, cut note included, was 3,073 characters.
The reply reports what happened (navigated to ...search=Chrome+DevTools+...) and prints the new state. Ids that are new since the last state get a *. One honest detail from the real log: the confirmation line said the field showed "Chrome DevTools Protoco", one letter short, even though the search URL carried the full text. It looks like a timing artifact of reading the field during navigation. The search worked.
Problem: what about screenshots?
Text views miss what is drawn, not written. A screenshot catches overlays, charts and layout. It also costs tokens and can leak typed secrets (Part 7). browser-use 1.0 sends screenshots by default. use_vision=False keeps every screenshot away from the model, which the source comments say is for privacy, cost or text-only models.
Scroll for more →
flowchart TD
P[Live page] --> A[AX tree: roles and names]
P --> D[DOM: full truth]
P --> S[Screenshot: pixels]
A --> F{Filter}
D --> F
F --> I[Indexed controls with backend ids]
I --> M[Model picks an id]
M --> B[DOM.getBoxModel on that id]
B --> C[Input.dispatchMouseEvent at the center]
The same path as a sequence, from page to click:
Scroll for more →
sequenceDiagram
participant M as Model
participant R as REPL
participant C as Chrome
M->>R: cdp Accessibility.getFullAXTree
R->>C: CDP request
C-->>R: 5,131 AX nodes
R-->>M: filtered list, 500 named controls
M->>R: click control 13
R->>C: DOM.getBoxModel backendNodeId
C-->>R: content quad
R->>C: Input.dispatchMouseEvent at center
C-->>R: page updates
R-->>M: new state + screenshot
Try this
Open Chrome DevTools on any page, go to the Elements panel and turn on the Accessibility pane. Click around. You will see the role and name the agent would see for each element, and which elements have no name at all. Those are the ones agents struggle with.