Running tests with Playwright is a breeze. You can run a single test, a set of tests, or all tests. By default, tests run in headless mode, meaning no browser window opens, and you see results in the terminal.
Here's how to run your tests from the command line:
npx playwright test
npx playwright test landing-page.spec.ts
npx playwright test tests/todo-page/ tests/landing-page/
npx playwright test landing login
npx playwright test -g "add a todo item"
If you want to see your tests running in UI mode for a better developer experience, use this command:
npx playwright test --ui
Playwright comes with its own inspector for stepping through API calls and exploring locators. You can debug your Playwright API calls using tools like console.log
or directly in VS Code with its extension. If a test fails, VS Code shows error messages right in the editor.
For more on mastering Playwright test automation, check out this comprehensive cheat sheet.
If you still have questions, please ask a question and I will try to answer it.
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 [email protected].