Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
Python interview question
Browser automationMiddleCommonPractical

What does running a browser in "headless" mode mean for Selenium or Playwright test automation, and why does it matter for CI?

Answer

A headless browser runs the rendering and JavaScript engine without opening any visible window or GPU-accelerated display surface, which lets it run on a CI server or container with no display attached at all, and it is typically faster and lighter on memory than a full graphical browser session, since no pixels need to be drawn to a screen. It is not guaranteed to behave identically to a headed session in every respect, though: modern Playwright, for example, uses a separate "headless shell" build of Chromium by default in some configurations, and its own documentation notes that headless mode, headed mode, and different browser channels can render or behave subtly differently for specific features. For most functional test automation the difference is unnoticeable, but teams working on visually sensitive or browser-feature-sensitive flows often keep a headed or stable-channel lane in CI as well, rather than assuming full parity is guaranteed.

Strong answer includes

  • runs without a visible window or display, enabling CI with no display attached
  • not guaranteed to behave identically to headed mode in every respect — modern tooling's own docs note this
  • visually or feature-sensitive suites often keep a headed/stable-channel lane rather than assuming full parity

Practical example

A GitHub Actions runner has no display server, so

Python example
webdriver.Chrome(options=headless_options)

is required for the suite to run at all in that pipeline, while a developer debugging a failing test locally often temporarily switches back to headed mode to watch the browser act.

#selenium#ci-cd#test-automation

Sources

Selenium with PythonSelenium · WebDriver automation patterns used from Python test code