microsoft/playwright
Playwright
Playwright is a comprehensive browser automation framework designed for end-to-end testing and web workflow automation. It provides a unified API to drive web applications across multiple browser engines, enabling developers to simulate complex user interactions, perform web scraping, and validate application behavior in consistent, isolated environments.
The framework distinguishes itself through a web-first testing paradigm that prioritizes stability and resilience. By utilizing an auto-waiting actionability engine and accessibility-tree-based locators, it eliminates common sources of test flakiness by ensuring elements are ready for interaction before execution. It further enhances reliability through browser-context-based isolation, which creates ephemeral sessions with independent storage and cookies, and a fixture-based dependency injection system that manages test lifecycles and environment setup.
Beyond core execution, the project offers an extensive suite of developer tooling, including visual debugging environments, time-travel trace viewers, and AI-driven capabilities for test failure healing and code generation. It supports advanced testing requirements such as cross-browser execution, device emulation, network request mocking, and visual regression testing. The framework is built to integrate into modern development workflows, providing native support for parallel execution, CI/CD pipeline automation, and component-level testing.
Features
- Browser Automation Frameworks - A cross-browser testing tool that drives web applications through a unified API to simulate user interactions and verify application behavior.
- Behavior-Driven Testing - Playwright verifies application behavior by interacting with rendered output rather than internal implementation details to ensure tests remain resilient to code refactoring.
- Accessibility-Tree-Based Locators - Resolves elements using semantic roles and labels to prioritize user-facing attributes over brittle, implementation-specific DOM structures.
- Actionability Engines - Performs continuous, asynchronous checks for visibility, stability, and readiness before executing user interactions to eliminate flakiness.
- Assertion Libraries - Playwright verifies web element states and properties using auto-retrying assertions that wait for conditions to be met before timing out.
- Headless Browser Controllers - Playwright executes browser automation commands via a command-line interface designed for coding agents, featuring live session monitoring and visual dashboard control.
- CLI Test Runners - Playwright executes test suites from the command line, running tests across configured browsers in headless mode by default to verify application functionality.
- Component Testing Utilities - Playwright mounts components into a real browser environment to verify layout, interactions, and visual regression while maintaining access to Node.js test utilities.
- Cross-Browser Testing Tools - Playwright executes tests across multiple browser configurations simultaneously to verify consistency, with options to toggle between headless and visible modes.
- End-to-End Testing Frameworks - Playwright runs end-to-end tests across multiple browsers with auto-waiting, web-first assertions, and full browser isolation for reliable, parallelized test execution.
- End-to-End Testing Suites - A comprehensive test runner that orchestrates parallel execution, manages browser contexts, and provides built-in assertions for reliable web application validation.
- Test Fixture Systems - Manages test lifecycle and environment setup through a dependency-injected system that automatically handles resource allocation and cleanup.
- Web-First Testing Tools - A testing paradigm that prioritizes user-facing locators and auto-waiting mechanisms to ensure test stability against dynamic DOM changes and asynchronous updates.
- Cross-Browser Execution Engines - A runtime environment that manages multiple browser binaries and device emulations to verify application consistency across different rendering engines and platforms.
- Browser Context Isolation - Playwright creates independent browser contexts that maintain separate local storage, session storage, and cookies for each test execution.
- Worker Process Management - Playwright orchestrates test execution across multiple OS worker processes, which run independently and are automatically restarted after failures to ensure a pristine environment.
- Auto-Waiting Assertions - Playwright performs assertions that automatically wait for elements to reach the expected state, reducing the need for manual waits or brittle timing logic.
- Browser Page Management - Playwright creates and manages browser pages within a context to navigate URLs, interact with page content, and perform actions on individual tabs or windows.
- Element Locators - Playwright identifies elements using standard CSS selectors, augmented with custom pseudo-classes to target elements based on visibility, content, or layout.
- Element State Assertions - Playwright verifies element states using auto-retrying assertions that wait for conditions to be met, effectively eliminating flakiness in test suites.
- Resilient UI Testing Frameworks - | Building stable test suites that remain functional despite frequent DOM changes by utilizing user-facing locators and auto-waiting mechanisms.
- Accessible Locators - Playwright identifies elements by their accessible role and name to ensure robust and accessible test interactions.
- Page Object Models - Playwright encapsulates common page operations and locators into a reusable class to simplify test code and improve maintainability.
- Actionability Verification - Playwright performs automatic actionability checks on elements before executing interactions to ensure they are visible, stable, enabled, and ready to receive events.
- Fixture Overriding - Playwright modifies the behavior of built-in or custom fixtures to inject custom configuration or replace them entirely for specific test suites.
- Accessibility Snapshot Testing - Playwright verifies page accessibility by comparing the current accessibility tree against a stored YAML-based snapshot template.
- Event Synchronization Mechanisms - Playwright waits for specific browser events to occur before proceeding with script execution, using promise-based patterns for requests, popups, or other asynchronous actions.
- Test Recording Tools - Playwright generates test code by interacting with a browser to record user actions, create assertions, and pick locators via a dedicated inspector window.
- Component Testing Frameworks - Playwright installs and configures component testing to enable rendering and testing components in a real browser environment.
- Component Mounting Utilities - Playwright passes props, event handlers, and children to components during the mounting process to simulate various component states and user interactions.
- Test Configuration Suites - Playwright configures test projects with custom options and environment-specific settings to run the same test suite across multiple configurations.
- Test Fixtures - Playwright extends the base test object to provide reusable setup and teardown logic for test environments and page objects.
- Visual Regression Testing - | Detecting unintended UI changes by comparing current page or element snapshots against baseline images to maintain design consistency.
- Visual Regression Testing Tools - Playwright generates reference screenshots for visual regression testing, automatically saving them to the file system when no baseline exists.
- Test Execution Strategies - Playwright distributes a test suite across multiple machines by sharding the execution, allowing large test sets to run concurrently in parallel environments.
- Test Suite Sharding - Playwright splits test files across multiple machines by passing command-line arguments to enable parallel execution and faster completion times.
- Global Test Lifecycle Hooks - Playwright executes setup and teardown functions once before and after the entire test suite, passing data between them using environment variables or state files.
- Test Setup Orchestrators - Playwright defines and executes setup or teardown tasks independently to manage authenticated states and database seeding before running primary test suites.
- API Request Mocking - Playwright intercepts network requests to specific URL patterns and returns custom responses to run tests without making actual network calls.
- Asynchronous Polling Mechanisms - Playwright polls asynchronous functions until a specific condition is met, using configurable timeouts and intervals for flexible wait logic.
- Browser API Mocking - Playwright injects initialization scripts before page navigation to override browser APIs and simulate specific hardware or environment states during automated testing.
- Browser Emulation - Playwright overrides the default browser user agent string to test application compatibility and behavior across different browsers or custom client identifiers.
- DOM Element Selectors - Playwright performs list operations such as counting items, asserting text content, or selecting specific items by index or filter criteria.
- Element Selectors - Playwright queries elements relative to the results of previous selectors, with support for capturing intermediate matches using a prefix.
- Network Traffic Monitors - Playwright monitors network requests and responses in real-time, or waits for specific network events using glob patterns, regular expressions, or custom predicate functions.
- Pointer Interaction Tools - Playwright executes human-like pointer interactions including clicks, double-clicks, right-clicks, and modifier-key combinations with automatic actionability checks.
- Test Fixture Management - Playwright defines automatic fixtures that execute for every test or worker regardless of whether they are explicitly requested, useful for global logging or monitoring.
- Test ID Selectors - Playwright identifies elements using resilient, developer-defined test ID attributes to ensure tests remain stable even when UI text or roles change.
- Resilient Locator Strategies - Playwright locates elements using resilient, user-facing attributes like roles and labels to ensure tests remain stable even when the underlying DOM structure changes.
- Browser Environment Emulators - Playwright emulates specific browser environments during test generation, including viewport size, device profiles, color schemes, geolocation, language, timezone, and authenticated state.
- Device Emulators - Playwright applies pre-configured parameters like user agent, screen size, and touch support to browser contexts to simulate specific device behavior.
- Test Failure Debugging Tools - Playwright debugs test failures using breakpoints, variable inspection, error messages, AI-powered suggestions, and a step-by-step trace viewer for deep analysis.
- API Testing Frameworks - Playwright executes HTTP requests using built-in fixtures to perform CRUD operations, validate responses, and assert on API data structures within test files.
- Parallel Execution Managers - Playwright configures the maximum number of parallel worker processes to optimize test execution speed based on available system resources.
- Test Reporting Tools - Playwright configures built-in test reporters to output results in various formats and customize verbosity or step-level reporting.
- API and UI Integration Tools - Playwright integrates API calls into UI-based browser tests to establish preconditions or validate postconditions on the server side during end-to-end testing.
- Assertion Timeouts - Playwright sets assertion timeouts globally or for individual auto-retrying assertions to handle varying wait times for UI elements.
- Action Timeout Configurations - Playwright defines default timeouts for actions and navigation globally or overrides them for specific actions to handle slow-loading pages.
- Parallel Worker Authentication - Playwright authenticates once per parallel worker process using unique accounts to prevent state interference when tests modify shared server-side data.
- Serial Test Execution Modes - Playwright annotates inter-dependent tests as serial to ensure they execute in a specific order, skipping subsequent tests if a preceding test fails.
- Test Dependency Managers - Playwright defines project dependencies to ensure specific setup tasks or prerequisite tests execute before dependent projects run.
- API Request Configurations - Playwright defines API request defaults like base URLs, headers, and proxy settings globally or per-test to standardize HTTP interactions across the test suite.
- API Response Modifiers - Playwright intercepts outgoing API requests and modifies their responses dynamically to inject custom data or patch existing payloads for reproducible testing.
- Authentication State Management - Playwright persists and reuses authenticated session state between API and browser contexts to streamline testing of protected endpoints and user flows.
- Custom Selector Engines - Playwright defines domain-specific element querying logic by registering custom selector engines for enhanced element identification.
- Form Interaction Utilities - Playwright inputs data into form fields by focusing elements and triggering events for text, date, time, and datetime inputs.
- Test Parameterization - Playwright generates unique test cases by iterating over data arrays, with support for scoped hooks and custom test descriptions.
- Time Manipulation Utilities - Playwright advances the clock by specific durations to manually trigger timers and animation frames for fine-grained control over time-based application state changes.
- Visual and Environment Emulation - Playwright emulates system color schemes and media types to verify responsive design and theme-based styling.
- WebSocket Mocking Tools - Playwright intercepts WebSocket connections to mock server communication or modify individual messages sent between the client and the server during runtime.
- Input State Interactions - Playwright checks or unchecks checkboxes and radio buttons by interacting with standard input elements or custom roles.
- Accessibility Auditing Tools - Playwright audits web pages for accessibility violations by running automated scans against the DOM and asserting that no violations are present.
- Accessibility Violation Suppression - Playwright suppresses specific accessibility violations by excluding DOM elements or disabling individual scan rules during the automated audit process.
- Soft Assertions - Playwright executes multiple assertions without immediately terminating the test, allowing for the collection and display of all failures at the end of the test run.
- Accessibility Compliance Auditings - | Automating the verification of web pages against accessibility standards to ensure inclusive user experiences and identify potential compliance violations.
- Accessibility Testing Configurations - Playwright defines reusable accessibility scan configurations to share builder settings and rule exclusions across multiple test files.
- Test Planning Utilities - Playwright generates human-readable test plans from application requirements and seed tests to outline scenarios and user flows for automated testing.
- Initialization Script Injections - Playwright injects scripts into the page before it loads to configure mocks, test data, or global environment overrides for every test.
- Test Suite Filters - Playwright filters test suites by applying glob patterns or regular expressions to include or exclude specific test files from the execution process.
- API Request Contexts - Playwright initializes standalone API request contexts manually to perform out-of-band HTTP operations outside of the standard test fixture lifecycle.
- Browser Extension Testing Tools - Playwright loads and tests browser extensions by configuring persistent browser contexts with extension-specific arguments and retrieving extension IDs for automated interaction.
- Locale and Timezone Emulators - Playwright configures the browser locale and timezone to test application behavior under different regional settings and time-based logic.
- Shadow DOM Selectors - Playwright identifies elements within Shadow DOM trees automatically, allowing seamless interaction with custom web components without special configuration.
- Synchronous Assertions - Playwright performs immediate, non-retrying assertions on values to validate logic, state, or data without waiting for asynchronous UI updates.
- Test Assertion Extensions - Playwright adds custom matchers to the assertion library to encapsulate domain-specific validation logic and improve test readability.
- Test Filtering Mechanisms - Playwright executes only specific tests while ignoring all others in the project during development or debugging sessions.
- Test Grouping Utilities - Playwright organizes tests into logical groups to share setup and teardown hooks or to apply common configurations and metadata to multiple tests.
- Test Lifecycle Hooks - Playwright executes setup and teardown logic before and after test suites using lifecycle hooks to ensure consistent test environments.
- Test Report Aggregators - Playwright merges test reports from multiple shards into a single, unified report by collecting blob-formatted results and processing them with a utility.
- Test Retry Strategies - Playwright configures test retries to automatically re-run failing tests until they pass or a maximum limit is reached.
- Test Tagging Systems - Playwright applies custom labels to tests to enable filtering, selective execution, or exclusion of specific test subsets via command-line arguments or configuration files.
- Test Timeouts - Playwright configures test timeouts globally or for individual tests, hooks, or suites to manage execution duration.
- Test Configuration Managers - Playwright switches between multiple configuration files to target different test environments or suites directly from the sidebar interface.
- Test Reporters - Playwright creates a class that adheres to the reporter API to handle test lifecycle events and generate specialized output formats.
- Screenshot Buffers - Playwright captures a screenshot as a raw buffer to enable post-processing, pixel-diffing, or custom handling without writing to the file system.
- Automated Test Execution - Playwright executes test suites from the command line using filtering, parallel processing, headed browser modes, and interactive debugging sessions.
- Visual Test Runners - Playwright executes tests in a visual interface that allows stepping through actions, inspecting locators, and watching for changes during the development process.
- Editor-Integrated Debugging - Playwright debugs tests directly within the editor by setting breakpoints, inspecting error messages, and stepping through code with integrated browser-side highlighting.
- Editor-Integrated Test Execution - Playwright runs individual tests, files, or full project suites directly from the editor with visual feedback on pass/fail status and execution time.
- Test Code Generators - Playwright records browser interactions to produce automated test scripts in multiple languages while customizing output files and test ID attributes.
- Test Generation Tools - Playwright generates test code by interacting with a browser to record user actions, create assertions, and pick locators directly within the editor.
- Test Trace Viewers - Playwright opens recorded trace files in a dedicated viewer to analyze and debug test execution with configurable host and port settings.
- Trace Inspection Tools - Playwright explores recorded test traces to visually examine DOM snapshots, network activity, console logs, and action details for every step of a test.
- Visual Debuggers - Playwright inspects and debugs test execution using a dedicated GUI to step through actions, live-edit locators, and view detailed actionability logs.
- Execution Tracing Systems - Records full-fidelity state, network activity, and console logs during execution to enable time-travel debugging and visual failure analysis.
- Visual Debugging Environments - A suite of integrated tools that provides trace viewers, live inspectors, and time-travel debugging to analyze test failures and browser state.
- Test Generation Utilities - Playwright invokes the test generator within a custom browser context to record interactions in non-standard or complex application environments.
- Watch Modes - Playwright enables automatic test re-execution by toggling watch mode to trigger runs whenever source code changes are detected.
- Browser Context Managers - Playwright creates multiple isolated browser contexts within a single test scenario to simulate multi-user interactions or complex cross-session functionality.
- Browser Configuration Profiles - Playwright configures test projects to run across multiple browsers, including branded browsers and emulated mobile or tablet devices, by defining project-specific device parameters and browser channels.
- Browser Workflow Automation - Playwright automates browser workflows programmatically for tasks like web scraping, PDF generation, and screenshot capture without requiring a test runner.
- Cross-Browser Automation - | Executing browser-based tasks programmatically to perform web scraping, data extraction, or automated workflows across different rendering engines.
- Browser Isolation Strategies - Creates independent, ephemeral browser sessions that maintain separate storage, cookies, and cache to ensure hermetic test execution.
- Browser Navigation - Playwright navigates to a specific URL and waits for the page to fire the load event, including all dependent resources like scripts, stylesheets, and images.
- JavaScript Execution Bridges - Playwright executes JavaScript code within the browser context by passing serializable data or object handles as arguments to bridge the gap between test and page environments.
- Locator Filtering Utilities - Playwright filters existing locators by text content or the presence of specific child elements to narrow down selection to the exact target.
- Frame Interactions - Playwright accesses and interacts with nested frame elements by name or URL to perform actions within isolated document contexts.
- Headed Browser Execution - Playwright executes tests with a visible browser window to observe real-time interactions between the automation script and the website under test.
- Service Worker Management - Playwright maintains persistent service worker handles across automatic suspension and restart cycles during browser automation.
- Viewport Emulators - Playwright overrides the browser viewport size or device scale factor to simulate different screen resolutions and high-DPI displays.
- Label-Based Selectors - Playwright identifies form controls by their associated label text to interact with inputs that have explicit label elements.
- DOM Selectors - Playwright identifies elements using XPath expressions, supporting union operators and standard document evaluation for complex DOM traversal.
- Browser Dialog Handlers - Playwright registers listeners to accept or dismiss browser dialogs like alerts, confirms, and prompts before the triggering action occurs.
- Placeholder Locators - Playwright identifies input elements using their placeholder attribute text, useful for form fields that lack explicit labels.
- Browser Binary Managers - Playwright manages browser binary locations, cache paths, and garbage collection policies to optimize disk usage and support hermetic installation environments.
- Browser Permission Management - Playwright grants or revoke browser permissions such as notifications or geolocation for specific origins to test application access requests.
- Full Page Screenshots - Playwright captures a screenshot of an entire scrollable page as if the viewport were tall enough to contain the full document content.
- Keyboard Input Simulations - Playwright types characters into fields character-by-character to simulate real keyboard events, including support for custom delays between keystrokes.
- Authentication State Persistence - Playwright authenticates once in a dedicated setup project and shares the resulting browser state across all test projects to bootstrap authenticated sessions.
- Test Failure Healing - Playwright heals failing tests by replaying steps, inspecting the UI to locate elements, and suggesting patches for broken locators or data fixes.
- API-Based Authentication - Playwright performs authentication via direct API requests instead of UI interactions to accelerate the setup process for test suites.
- Session Persistence Mechanisms - Playwright saves authenticated browser state to the file system to reuse across test runs, ensuring tests start in an already-authenticated session.
- CI Workflow Automations - Playwright configures automated test workflows in CI environments to execute test suites on code changes, install dependencies, and upload test reports as artifacts.
- CI Trace Debugging - Playwright analyzes test execution traces by inspecting individual actions and state changes to identify the root cause of failures in a visual interface.
- Browser Binary Installers - Playwright installs required browser binaries and system dependencies, with options for force-reinstallation or dry-run verification of system requirements.
- Remote Execution Environments - Playwright runs a remote server inside a container to execute browser automation tasks from a separate host machine or unsupported Linux distribution.
- Test Environment Configurations - Playwright sets project-specific base URLs, timeout limits, and retry policies to run tests against different environments.
- Test Execution Configurations - Playwright configures core test execution settings including parallelization, retry policies, reporter selection, and project-specific browser environments for consistent test runs.
- Network Response Modifiers - Playwright intercepts and modifies incoming network responses by overriding the body, headers, or status codes before delivery.
- Request Interception Utilities - Playwright intercepts and modifies outgoing network requests by deleting headers, changing methods, or altering parameters before they reach the server.
- Remote Server Connectivities - Playwright connects local test suites or applications to a remote browser server using WebSocket endpoints for distributed execution.
- HAR Network Mocking - Playwright records, modifies, and replays network traffic using HTTP Archive files to simulate complex API interactions and ensure consistent test environments.
- Browser Control Protocols - Communicates with browser instances via a low-level, bidirectional protocol to enable deep inspection and control of the browser engine.
- Process-Based Parallelism - Orchestrates test execution across multiple isolated OS processes to maximize CPU utilization while maintaining strict state separation.
- Forced Interactions - Playwright bypasses standard actionability checks for specific interactions by using a force option to perform actions regardless of element state.