Rayrun

How do I run tests in headed mode or UI Mode using Playwright?

Answer

Running Tests in Normal Mode with Playwright

Absolutely, you can run tests in normal mode with Playwright. By default, tests run in headless mode, but you can switch to headed mode for a visual representation of the browser window. This is especially useful when working with third-party libraries that need a visible browser environment.

Headed Mode

To run tests in headed mode, use the --headed flag with the npx playwright test command:

npx playwright test --headed

UI Mode

Playwright also offers a UI Mode for an enhanced developer experience. It includes features like time travel debugging and watch mode. You can inspect the DOM snapshot in its own window for better debugging capabilities.

To run tests in UI Mode, use the --ui flag followed by either HTML or JSON:

npx playwright test --ui HTML

In UI Mode, you get a timeline view of each action of your test. You can hover over actions to see image snapshots and pick locators from DOM snapshots.

Browser Support

Playwright supports multiple browsers such as Chromium (default), Firefox, and WebKit. You can configure which browsers your tests should run on in the playwright.config.js file.

In conclusion, Playwright provides options to run tests in headed mode and UI Mode, allowing you to have a visible browser environment and access additional debugging features.

References

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

TwitterGitHubLinkedIn
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.