You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Allow Chrome to launch in the background during headful mode #41306
Allow chrome to open in headful mode but in the background without removing focus from an active window. Firefox already supports this via Playwright flags, but Chrome does not have a flag.
This is a reincarnation of #4822 which had 36+ people support this motive: #4822 (comment) but the issue was already closed
New browserType.launch({ createPagesInBackground: true }) option (default false, no behavior change otherwise).
When enabled, headed Chromium passes background: true to Target.createTarget, so newPage() no longer activates the browser app and steals OS focus from the user (verified on macOS).
Pages remain normal visible windows: document.hasFocus() / visibilityState are unaffected thanks to focus emulation, and page.bringToFront() still raises the window. Skipped for headless (headless shell does not support the parameter) and Android.
Why Chromium-only
Firefox and WebKit do not reproduce the problem on current builds: headed Firefox never stole focus in testing even though -foreground is passed (older builds did), and WebKit never steals.
Firefox's (historical) steal was a one-time app activation at launch caused by the -foreground CLI arg — a different mechanism than Chromium's per-newPage() foreground target creation, and there is no juggler equivalent of background: true. Affected Firefox users can already opt out via ignoreDefaultArgs: ['-foreground'].
Extending the option to Firefox would mean skipping -foreground in defaultArgs() when the option is set; left out for now since it is untestable against current builds and changes launch activation rather than page creation. Happy to generalize if preferred.
I have a script launches Okta and automatically re-authenticates for me. If the script runs while I'm typing in a different browser, Chrome focuses and my typing is interrupted.
Motivation
There is currently no way to activate Chrome in the background during headful mode without stealing focus from active tasks. This is particularly annoying when trying to work in multiple contexts.
Reacted by Petr Přikryl, Rózsa Zoltán, Ani Shakhkyan, Derek Ellis, Poglavar Svemira, Adam Westbrook, Pavel (Pavlo) Gyrya and nibe
Andrew Chen Wang (@Andrew-Chen-Wang) Thank you for explaining your usecase. It sounds very niche, so it's probably not worth a separate API. I'd recommend employing some workaround, for example ctrl-click a link instead of calling newPage() - this should open a background tab instead.
Running into this issue again; we have tons of coding agents running browser instances to verify their code is correct, but it steals away input focus.
Until Chrome can open pages in the background, here's a workaround on Windows: Staypaw (https://github.com/hazeliscoding/staypaw; I'm its author) notices when headed Chrome takes focus while you're typing elsewhere, and puts focus straight back, along with the keys you typed meanwhile. It can also keep one app you pick, such as your editor, in front even while you're idle. It doesn't touch the browser or Playwright.
We're closing all P3-collecting-feedback issues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.
Activity
dgozman commentedon Jun 16, 2026
Andrew Chen Wang (@Andrew-Chen-Wang) Thank you for explaining your usecase. It sounds very niche, so it's probably not worth a separate API. I'd recommend employing some workaround, for example ctrl-click a link instead of calling
newPage()- this should open a background tab instead.injust commentedon Aug 29, 2026
Dmitry Gozman (@dgozman) How do you ctrl-click a link without a page open?
Andrew-Chen-Wang commentedon Aug 31, 2026
Running into this issue again; we have tons of coding agents running browser instances to verify their code is correct, but it steals away input focus.
fluidsonic commentedon Oct 1, 2026
Same for us. We run plenty of coding agents that keep testing stuff in Playwright, and the autofocus keeps disrupting the user's work.
We don't use headless, as we want to (a) monitor what the agent is doing and (b) frequently interact with the test website in Playwright.
Andrew-Chen-Wang commentedon Oct 1, 2026
linking my temporary solution here: #4822 (comment)
hazeliscoding commentedon Oct 25, 2026
Until Chrome can open pages in the background, here's a workaround on Windows: Staypaw (https://github.com/hazeliscoding/staypaw; I'm its author) notices when headed Chrome takes focus while you're typing elsewhere, and puts focus straight back, along with the keys you typed meanwhile. It can also keep one app you pick, such as your editor, in front even while you're idle. It doesn't touch the browser or Playwright.
pavelfeldman commentedon Oct 31, 2026
We're closing all
P3-collecting-feedbackissues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.