Headless VS Headed Mode in Playwright

In Playwright, "headed" and "headless" modes refer to different ways of running a browser during automated tests.

Headed Mode:
In headed mode, the browser runs in a visible window, allowing you to see the actions being performed by the automated script. This mode is useful during development and debugging as it provides a visual representation of the browser's behavior. To run a test in headed mode, we need to add the "--headed" command at the end of the script while running the test.
Example: npx playwright test homePageTest.spec.js --headed

Headless Mode:
In headless mode, the browser runs without a visible graphical interface. It operates in the background, performing tasks without displaying the browser window. Headless mode is suitable for automated tasks that don't require user interaction or visual feedback. It's generally faster and consumes fewer resources compared to headed mode. By default, tests in Playwright run in headless mode. We do not need to define any extra command to run tests in headless mode.
Example: npx playwright test homePageTest.spec.js