Skip to content

fix: Playwright 1.58+ / Chrome CDP compatibility (DOMSnapshot API changes)#16

Open
Kyzcreig wants to merge 2 commits intontegrals:masterfrom
Kyzcreig:fix/chromium-dom-snapshot-compat
Open

fix: Playwright 1.58+ / Chrome CDP compatibility (DOMSnapshot API changes)#16
Kyzcreig wants to merge 2 commits intontegrals:masterfrom
Kyzcreig:fix/chromium-dom-snapshot-compat

Conversation

@Kyzcreig
Copy link

Problem

openbrowser fails silently on Playwright 1.58+ / modern Chrome due to breaking changes in Chrome's DOMSnapshot.captureSnapshot CDP API. The agent either quits at step 0 or crashes with DOM extraction errors on every step.

Root Causes & Fixes

1. strings array moved to top level

Chrome moved the shared string lookup table from result.documents[0].strings to result.strings (top-level). All tag names, attribute values, and text content were resolving to undefined.

2. childNodeIndexes removed — use parentIndex instead

Chrome removed childNodeIndexes entirely. The DOM tree was built with zero children for every node → empty interactive element map → Element with index X not found on every action.

Fix: invert parentIndex on load to build a childrenMap.

3. paintOrder renamed to paintOrders

4. inputValue entries contain -1 sentinel (no value) — previously crashed

5. querySelectorAll non-iterable in Turndown DOM shim

content-extractor.ts iterates querySelectorAll results. Turndown's shim returns non-iterable → {} is not iterable on every extract call. Fixed with Array.from().

6. CLI --max-steps never applied

Commander maps --max-stepsoptions.maxSteps but code read options.stepLimitNaN → agent quit at step 0.

Bonus

  • Added ollama provider (local, free, no API key)
  • Added openrouter provider (free tier models available)

Tested

Playwright 1.58.2 / Chrome 133 — agent successfully navigates, builds element map, extracts content.

Forge added 2 commits March 13, 2026 15:19
Three breaking changes in newer Chrome DOMSnapshot API:

1. strings array moved to top level
   - Old: result.documents[0].strings
   - New: result.strings (top-level, shared across docs)
   - Fix: snapshot.strings ?? doc.strings ?? []

2. childNodeIndexes removed, replaced by parentIndex
   - Old: nodes.childNodeIndexes[nodeIndex] gave children directly
   - New: nodes.parentIndex[i] gives parent of node i
   - Fix: build childrenMap by inverting parentIndex on load

3. paintOrder renamed to paintOrders (plural)
   - Fix: layout.paintOrder ?? layout.paintOrders

4. inputValue entries can contain -1 (no value) sentinel
   - Fix: skip valueIdx < 0

5. querySelectorAll in content-extractor returns non-iterable
   object via Turndown DOM shim
   - Fix: wrap all querySelectorAll calls with Array.from()

6. CLI --max-steps option parsed as maxSteps but code read
   stepLimit → NaN → agent quit at step 0
   - Fix: options.maxSteps ?? options.stepLimit ?? '25'

Tested against https://news.ycombinator.com - agent now
successfully extracts page content in step 1.
- Add ollama provider (local, free, OLLAMA_BASE_URL configurable)
- Add openrouter provider (OPENROUTER_API_KEY, access free models)
- Install ollama-ai-provider@1.2.0
- Patch instructions.md: agent now calls done immediately on
  read/extract tasks once it has the answer, no more wandering
- qwen2.5:7b pull initiated for local use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant