DEV Community

Cover image for How Cursor + BrowserAct Handles Dynamic Pages Without Brittle Selectors

How Cursor + BrowserAct Handles Dynamic Pages Without Brittle Selectors

Anthony Max on July 28, 2026

TL;DR Modern web applications change constantly. Components are re-rendered, generated attributes may differ between builds. Even when t...
Collapse
 
mia_keller_ffd2584c046ecb profile image
Mia Keller

Bypassing fragile DOM selectors by letting the agent infer UI intent is such a cleaner approach for dynamic pages! Have you noticed any trade-offs in execution speed or latency when letting the agent parse the visual layout compared to traditional selector-based automation?

Collapse
 
anthonymax profile image
Anthony Max

Thanks! Yes, I don't think speed is all that important in testing, but I've noticed that Cursor works quite quickly.

Collapse
 
mia_keller_ffd2584c046ecb profile image
Mia Keller

Thanks for clarifying, Anthony! That makes total senseβ€”reliability and avoiding flaky CI/CD pipelines definitely trump raw execution speed for dynamic web apps.

Follow-up question on scaling this approach: as test suites grow to hundreds of scenarios, how do you manage the higher LLM API token costs and inference latency that come with parsing full visual layouts repeatedly compared to lightweight DOM snapshots?

Collapse
 
citedy profile image
Dmitry Sergeev

finally someone addressing the brittle selector nightmare lol. does this actually hold up with heavy shadow DOM usage?

Collapse
 
anthonymax profile image
Anthony Max

ShadowDOM is not too important in this case because it is a browser layer.

Collapse
 
citedy profile image
Dmitry Sergeev

finally someone talking about this. brittle selectors are the worst part of automation lol

Collapse
 
leob profile image
leob

Downside: token spend, and possibly some added latency ...

If your page's selectors are "known", and aren't brittle, then 'deterministic testing' (e.g. Playwright) still wins - right?

Collapse
 
anthonymax profile image
Anthony Max

I wrote a chapter called "Where Playwright Still Fits." It has its advantages.

Collapse
 
joe_sanders_5765420f14129 profile image
Joe Sanders

Dom is so un reliable approach for browser automation

Collapse
 
anthonymax profile image
Anthony Max

What do you think about the article?

Collapse
 
leee_rodgers1 profile image
Lee Rodgers1

Gemini also fits?

Collapse
 
anthonymax profile image
Anthony Max

Yes.

Collapse
 
mudassirworks profile image
Mudassir Khan

the inspect β†’ act β†’ reassess loop is exactly what we were missing when we tried wiring Playwright into an MCP tool set. hardcoded selectors are fine until the first deploy that adds a loading skeleton β€” then every test that assumed .result-card would just be there on load starts flapping.

we ended up wrapping Playwright's page.locator in a short polling layer that rereads the accessibility tree every 2s before acting. uglier than BrowserAct but solves the same class of failure. tbh i should just swap it out.

does BrowserAct expose the page state as structured JSON or is it closer to a visual snapshot?

Collapse
 
citedy profile image
Dmitry Sergeev

finally something that doesn't rely on hardcoded css classes. does this work well with shadow dom too?

Collapse
 
citedy profile image
Dmitry Sergeev

finally someone addressing the brittle selector nightmare lol. does this actually hold up with heavily shadowed DOMs?