iCreatAI News
Skip to content
Browser Use Blog· Gregor Zunic·· 20 days agoAI score38

Why Playwright Scripts Break When the Site Changes

Why Playwright Scripts Break When the Site Changes

AI summary

The article explains that Playwright scripts break on redesigns because they locate elements by page structure (CSS classes, DOM position, XPath, generated IDs) rather than by what users see, and recommends role, label, text, or owned test-ID locators with auto-waiting instead of fixed timeouts. It catalogs causes and fixes for flakiness, including strict-mode violations, copy changes, A/B variants, iframes and shadow DOM, expired sessions, and overlays handled via page.addLocatorHandler() since v1.42. For sites you don't control, it lays out options from manual fixes to Playwright's healer agent and agent fallbacks, with a Python example attaching Browser Use to Chrome over CDP.

Source: Browser Use Blog · browser-use.com