Description: CLI for common Playwright actions. Record and generate Playwright code, inspect selectors and take screenshots.
View microsoft/playwright-cli on GitHub ↗
The Microsoft Playwright CLI repository provides a command-line interface (CLI) for interacting with the Playwright testing framework. Playwright is a powerful and versatile end-to-end testing library for modern web applications, supporting Chromium, Firefox, and WebKit browsers across various operating systems. This CLI enhances the developer experience by offering a streamlined way to perform common Playwright tasks directly from the terminal.
The core functionality of the Playwright CLI revolves around several key commands. `playwright install` is used to download and install the necessary browser binaries (Chromium, Firefox, and WebKit) required for running tests. This simplifies setup and ensures that the correct browser versions are available for testing. `playwright test` is the primary command for executing tests. It runs the test suite, reports results, and provides options for filtering tests, specifying browser configurations, and generating reports. The CLI supports various reporting formats, including HTML, JUnit, and JSON, allowing for integration with CI/CD pipelines and other testing tools.
Beyond test execution and browser installation, the CLI offers features that aid in test development and debugging. `playwright codegen` is a particularly useful command. It allows users to record browser interactions and generate Playwright test code automatically. This significantly speeds up the process of writing tests by capturing user actions and translating them into executable code. `playwright show-report` opens the HTML report generated by the test runner, providing a detailed view of test results, including screenshots, videos, and console logs, which are invaluable for debugging failing tests.
The repository also includes commands for managing Playwright's configuration. `playwright config` allows users to initialize a new Playwright project, generating a `playwright.config.ts` file that defines test settings, browser configurations, and other project-specific options. This file centralizes the configuration, making it easier to manage and customize the testing environment. The CLI also provides commands for generating TypeScript definitions, ensuring type safety and improved code completion when writing tests in TypeScript.
The Playwright CLI is designed to be extensible and integrates well with other tools and workflows. It supports command-line arguments for fine-grained control over test execution, such as specifying test files, filtering tests by name or tag, and configuring browser options. The CLI is actively maintained and updated by Microsoft, with regular releases that include bug fixes, performance improvements, and new features. The repository's documentation and examples provide comprehensive guidance on using the CLI and integrating it into various development environments. Overall, the Playwright CLI is a crucial component of the Playwright ecosystem, providing a convenient and efficient way to interact with the framework and streamline the end-to-end testing process.
Fetching additional details & charts...