Surviving DOM churn: BrowserAct's state index vs raw Playwright

Morgan80 Advanced 1h ago 201 views 2 likes 1 min read

Stale selectors are the #1 reason my Claude Code browser tasks die on the second run. The page looks identical, the button is right there, but the id changed because the build hash rotated — and Playwright's timeout error doesn't tell you a damn thing about why.

Surviving DOM churn: BrowserAct's state index vs raw Playwright

Full disclosure before the tech: BrowserAct sponsored this test, and the links in the original post were affiliate-tracked. That said, I ran it against my own deliberately hostile page, head-to-head with raw Playwright.

Here's the shape of the failure. A frontend re-renders with fresh CSS-module or styled-components hashes on every deploy. You write:

const id = await page.locator("button").getAttribute("id");
await page.reload();
await page.locator(`#${id}`).click({ timeout: 3000 });

Surviving DOM churn: BrowserAct's state index vs raw Playwright

Works the day you write it. Breaks the next time the build hash changes, and the failure is a bare timeout:

locator.click: Timeout 3000ms exceeded.

Playwright's own role/text locators fix this specific case — getByRole("button", { name: "Submit" }) survives id/class churn fine, because it never depended on the hash in the first place. That's a real fix, not a workaround. What it doesn't give you is a representation of the page an agent can reason about turn by turn, or a signal that says "the page under you just changed, stop and re-check." That's the gap BrowserAct is actually filling.

The interaction model is different. BrowserAct doesn't hand Claude Code a selector at all. The loop is: read the current state, choose an action from what's actually there, execute it, reassess.

```plaintext
state -> indexed list of interactive elements, as of right

webdevWorkflowAI Implementation

All Replies (4)

G
GhostFounder Intermediate 1h ago
The token overhead is real, but it only pays off when the DOM is genuinely unstable. On static pages, old-school selectors are still cheaper and faster—AI feels like overkill there.
0 Reply
R
Ray37 Intermediate 1h ago
Fair point, but static pages have a way of changing without warning—then you're debugging selectors instead of shipping.
0 Reply
A
Alex18 Expert 1h ago
I switched to data-testid plus fallback to visible text, fixed our flaky reruns immediately.
0 Reply
M
MicroPanda Intermediate 1h ago
Does the state index track shadow DOM nodes, or only the top-level document tree?
0 Reply

Write a Reply

Markdown supported