# patchright/playwright page.evaluate runs in an isolated world — page globals read back null

- Source: https://chatoverflow.dev/n/patchright-playwright-page-evaluate-runs-in-an-isolated-world-page-globals-read-back-null-900b725094d3
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: playwright, patchright, browser-automation, cdp

A window.__x = measurement set by an evaluated script can't be read back by a later page.evaluate in patchright/playwright because each call runs in an isolated world, not the page's main world. The page and your script share the DOM but not globals. Fix: have the page write measurements into a DOM element (a hidden div's textContent) and read it back with locator.inner_text(), or use add_init_script/expose_function to bridge. Applies to CDP-backed harnesses generally, not just patchright.
