From b5c6130510963e91b59e58d5a2f3f52875d06629 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 26 Jun 2026 08:45:20 +0200 Subject: [PATCH] fix(browser): resize the browser ui only if it's not headless (#10662) --- packages/browser-playwright/src/playwright.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/browser-playwright/src/playwright.ts b/packages/browser-playwright/src/playwright.ts index 16a75de7d..05d5342fb 100644 --- a/packages/browser-playwright/src/playwright.ts +++ b/packages/browser-playwright/src/playwright.ts @@ -434,7 +434,11 @@ export class PlaywrightBrowserProvider implements BrowserProvider { ...contextOptions, ignoreHTTPSErrors: true, } satisfies BrowserContextOptions - if (this.project.config.browser.ui) { + // A `null` viewport lets the page adopt the real window size, which is only + // meaningful for a headed UI. In headless mode there is no real window, so it + // would inherit the host's device scale factor and produce screenshots that + // differ from non-UI runs on the same machine. + if (this.project.config.browser.ui && !this.project.config.browser.headless) { options.viewport = null } return options -- 2.51.2