What is the reason for the chromium.exe console window opening while running Playwright tests in headless mode on Windows and how can it be prevented?


Controlling Chromium Console Window in Playwright Tests

Yes, it's normal for the chromium.exe console window to pop up when you're running Playwright tests in headless mode on Windows. This is because it's responsible for launching and controlling the headless Chromium browser.

Configuring Playwright

You can prevent this by tweaking your playwright.config.ts file. Here, you can set various test execution settings. For instance, you can change the number of workers used for test execution. By default, Playwright uses 3 workers. You can change this to use just one worker:

import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  workers: 1,

export default config;

You can also set environment variables visible to the browser using the "env" option:

const config: PlaywrightTestConfig = {
  env: {
    MY_ENV_VAR: 'value',

Using Command Line Flags

Another way to control this is by using specific command line flags when running your tests. For example, you can use the --headed flag instead of --headless to run your tests in headed mode. This will open a browser window during test execution.

UI Mode

For more control during debugging or development, consider using Playwright's UI Mode. This enables features like time travel debugging and watch mode, enhancing your developer experience.

In short, while the chromium.exe console window appearing is normal, there are several ways to prevent or customize this, such as modifying the worker count in the playwright.config.ts file or using specific command line flags. Plus, UI Mode gives you more control and a better developer experience during test execution.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.