Running tests with Playwright is a breeze. You can use either the command line interface (CLI) or the UI mode.
By default, tests run in headless mode. This means no browser window opens while running the tests. You'll see the results in your terminal.
To run all tests, type the following command in your terminal:
npx playwright test
To run a single test file, for example landing-page.spec.ts
, use:
npx playwright test landing-page.spec.ts
To run a set of test files located in specific folders, use:
npx playwright test tests/todo-page/ tests/landing-page/
You can also run files with certain keywords such as 'landing' or 'login':
npx playwright test landing login
If you prefer a better developer experience with features like time travel debugging and watch mode, use UI Mode. To do this, simply add --ui
at the end of your command:
npx playwright test --ui
You're not limited to one default browser like Chrome. The VS Code extension lets you debug your Playwright scripts right within VS Code. You can set breakpoints and live debug your code.
CodeGen lets you record new automated testing scripts quickly. You don't have to write them from scratch. It auto generates these scripts for you as you perform actions within the browser window.
For more tips on writing efficient Playwright test scripts, check out this blog post.
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].