Playwright opens a small window instead of a full-size one
Playwright window won't launch full screenShort answer
Playwright gives every page a fixed 1280x720 viewport, so the page never fills the window. Set viewport to null to make it follow the window, or set an exact size with setViewportSize. If you see no window at all, headless mode is on: it defaults to true.
Fix it fast
1Find out which cause you have
Print the viewport Playwright applies to the page. A value of 1280 by 720 means the default fixed viewport is in use.
console.log(page.viewportSize());2Match what you see, then jump to its fix
- 1
page.viewportSize() returns { width: 1280, height: 720 }The default fixed viewport of 1280x720 is in useFix - 2
playwright.config has devices['Desktop Chrome'] in a project, and your own viewport has no effectA device preset in the config sets its own viewportFix - 3
The test passes or fails with nothing on screenThe browser runs headless, so no window is visibleFix
- 1
What does the error look like?
Playwright window won't launch full screenpage.viewportSize() is 1280x720 on a larger monitor
Cause 1 of 3
The default fixed viewport of 1280x720 is in use
1Check
Playwright emulates a consistent viewport for each page, and the documented default is 1280x720. A bigger window does not change it.
console.log(page.viewportSize());2Fix
Set an exact size you want, or pass viewport: null so the page depends on the window size.
// exact size
const context = await browser.newContext({ viewport: { width: 1920, height: 1080 } });
// follow the window (not deterministic)
const context2 = await browser.newContext({ viewport: null });3Verify
Read the size again from the page.
console.log(page.viewportSize());
console.log(await page.evaluate(() => [innerWidth, innerHeight]));Confirmed by playwright.dev
Cause 2 of 3
A device preset in the config sets its own viewport
1Check
A device descriptor includes a viewport, and the docs say you can override it for some tests with page.setViewportSize.
grep -n "devices\[" playwright.config.*2Fix
Override the viewport in the project's use block, or resize inside the test.
// playwright.config.ts
projects: [{
name: 'chromium',
use: { ...devices['Desktop Chrome'], viewport: { width: 1920, height: 1080 } },
}]
// inside a test
await page.setViewportSize({ width: 1600, height: 1200 });3Verify
Run the test and print the viewport.
npx playwright test --headedConfirmed by playwright.dev
Cause 3 of 3
The browser runs headless, so no window is visible
1Check
headless defaults to true in both browserType.launch and the test runner options.
grep -n "headless" playwright.config.* *.js2Fix
Turn headless off for the run, or pass --headed on the command line.
// library
const browser = await chromium.launch({ headless: false });
// test runner
// use: { headless: false }3Verify
A browser window now opens during the run.
npx playwright test --headedConfirmed by playwright.dev
How do I stop it coming back?
- Pick one viewport per project in the config, so a test run looks the same on every machine.
- Use viewport: null only for local demos; Playwright documents it as making runs non-deterministic.
- Resize with page.setViewportSize inside the test when a case needs another size.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
Playwright says the execution context was destroyed because of a navigation
page.evaluate: Execution context was destroyed, most likely because of a navigation.
The page navigated while your script was running code inside it, so the JavaScript context it was talking to disappeared.
4 causes, each with a fixWeb apps
Playwright cannot open a headed browser on a Linux server or in Docker
npx playwright test --headed shows no window on a Linux server
A headed browser needs a display, and a Linux server or container has none.
3 causes, each with a fixWeb apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fix