Skip to content
Back to search

playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/microsoft/playwright with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/microsoft/playwright'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/microsoft--playwright/badge.svg)](/listings/microsoft--playwright)

HTML

<a href="/listings/microsoft--playwright"><img src="/api/listings/microsoft--playwright/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

npm init playwright@latest

Or add manually:

npm i -D @playwright/test
npx playwright install

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 318 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # 🎭 Playwright
  2. [![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-159.0.8154.6-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-159.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-27.2-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop --> [![Join Discord](https://img.shields.io/badge/join-discord-informational)](https://aka.ms/playwright/discord)
  3. ## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)
  4. Playwright is a framework for web automation and testing. It drives Chromium, Firefox, and WebKit with a single API — in your tests, in your scripts, and as a tool for AI agents.
  5. ## Get Started
  6. Choose the path that fits your workflow:
  7. | | Best for | Install |
  8. |---|---|---|
  9. | **[Playwright Test](#playwright-test)** | End-to-end testing | `npm init playwright@latest` |
  10. | **[Playwright CLI](#playwright-cli)** | Coding agents (Claude Code, Copilot) | `npm i -g @playwright/cli@latest` |
  11. | **[Playwright MCP](#playwright-mcp)** | AI agents and LLM-driven automation | `npx @playwright/mcp@latest` |
  12. | **[Playwright Library](#playwright-library)** | Browser automation scripts | `npm i playwright` |
  13. | **[VS Code Extension](#vs-code-extension)** | Test authoring and debugging in VS Code | [Install from Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) |
  14. ---
  15. ## Playwright Test
  16. Playwright Test is a full-featured test runner built for end-to-end testing. It runs tests across Chromium, Firefox, and WebKit with full browser isolation, auto-waiting, and web-first assertions.
  17. ### Install
  18. ```bash
  19. npm init playwright@latest
  20. ```
  21. Or add manually:
  22. ```bash
  23. npm i -D @playwright/test
  24. npx playwright install
  25. ```
  26. ### Write a test
  27. ```TypeScript
  28. import { test, expect } from '@playwright/test';
  29. test('has title', async ({ page }) => {
  30. await page.goto('https://playwright.dev/');
  31. await expect(page).toHaveTitle(/Playwright/);
  32. });
  33. test('get started link', async ({ page }) => {
  34. await page.goto('https://playwright.dev/');
  35. await page.getByRole('link', { name: 'Get started' }).click();
  36. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
  37. });
  38. ```
  39. ### Run tests
  40. ```bash
  41. npx playwright test
  42. ```
  43. Tests run in parallel across all configured browsers, in headless mode by default. Each test gets a fresh browser context — full isolation with near-zero overhead.
  44. ### Key capabilities
  45. **Auto-wait and web-first assertions.** No artificial timeouts. Playwright waits for elements to be actionable, and assertions automatically retry until conditions are met.
  46. **Locators.** Find elements with resilient locators that mirror how users see the page:
  47. ```TypeScript
  48. page.getByRole('button', { name: 'Submit' })
  49. page.getByLabel('Email')
  50. page.getByPlaceholder('Search...')
  51. page.getByTestId('login-form')
  52. ```
  53. **Test isolation.** Each test runs in its own browser context — equivalent to a fresh browser profile. Save authentication state once and reuse it across tests:
  54. ```TypeScript
  55. // Save state after login
  56. await page.context().storageState({ path: 'auth.json' });
  57. // Reuse in other tests
  58. test.use({ storageState: 'auth.json' });
  59. ```
  60. **Tracing.** Capture execution traces, screenshots, and videos on failure. Inspect every action, DOM snapshot, network request, and console message in the [Trace Viewer](https://playwright.dev/docs/trace-viewer):
  61. ```TypeScript
  62. // playwright.config.ts
  63. export default defineConfig({
  64. use: {
  65. trace: 'on-first-retry',
  66. },
  67. });
  68. ```
  69. ```bash
  70. npx playwright show-trace trace.zip
  71. ```
  72. <!-- TODO: screenshot of trace viewer -->
  73. **Parallelism.** Tests run in parallel by default across all configured browsers.
  74. [Full testing documentation](https://playwright.dev/docs/intro)
  75. ---
  76. ## Playwright CLI
  77. [Playwright CLI](https://github.com/microsoft/playwright-cli) is a command-line interface for browser automation designed for coding agents. It's more token-efficient than MCP — commands avoid loading large tool schemas and accessibility trees into the model context.
  78. ### Install
  79. ```bash
  80. npm install -g @playwright/cli@latest
  81. ```
  82. Optionally install skills for richer agent integration:
  83. ```bash
  84. playwright-cli install --skills
  85. ```
  86. ### Usage
  87. Point your coding agent at a task:
  88. ```
  89. Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
  90. Take screenshots for all successful and failing scenarios.
  91. ```
  92. Or run commands directly:
  93. ```bash
  94. playwright-cli open https://demo.playwright.dev/todomvc/ --headed
  95. playwright-cli type "Buy groceries"
  96. playwright-cli press Enter
  97. playwright-cli screenshot
  98. ```
  99. ### Session monitoring
  100. Use `playwright-cli show` to open a visual dashboard with live screencast previews of all running browser sessions. Click any session to zoom in and take remote control.
  101. ```bash
  102. playwright-cli show
  103. ```
  104. <!-- TODO: screenshot of playwright-cli show dashboard -->
  105. [Full CLI documentation](https://playwright.dev/agent-cli/introduction) | [GitHub](https://github.com/microsoft/playwright-cli)
  106. ---
  107. ## Playwright MCP
  108. The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) gives AI agents full browser control through the [Model Context Protocol](https://modelcontextprotocol.io). Agents interact with pages using structured accessibility snapshots — no vision models or screenshots required.
  109. ### Setup
  110. Add to your MCP client (VS Code, Cursor, Claude Desktop, Windsurf, etc.):
  111. ```json
  112. {
  113. "mcpServers": {
  114. "playwright": {
  115. "command": "npx",
  116. "args": ["@playwright/mcp@latest"]
  117. }
  118. }
  119. }
  120. ```
  121. **One-click install for VS Code:**
  122. [<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20MCP%20Server&color=0098FF" alt="Install in VS Code" />](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
  123. **For Claude Code:**
  124. ```bash
  125. claude mcp add playwright npx @playwright/mcp@latest
  126. ```
  127. ### How it works
  128. Ask your AI assistant to interact with any web page:
  129. ```
  130. Navigate to https://demo.playwright.dev/todomvc and add a few todo items.
  131. ```
  132. The agent sees the page as a structured accessibility tree:
  133. ```
  134. - heading "todos" [level=1]
  135. - textbox "What needs to be done?" [ref=e5]
  136. - listitem:
  137. - checkbox "Toggle Todo" [ref=e10]
  138. - text: "Buy groceries"
  139. ```
  140. It uses element refs like `e5` and `e10` to click, type, and interact — deterministically and without visual ambiguity. Tools cover navigation, form filling, screenshots, network mocking, storage management, and more.
  141. [Full MCP documentation](https://playwright.dev/mcp/introduction) | [GitHub](https://github.com/microsoft/playwright-mcp)
  142. ---
  143. ## Playwright Library
  144. Use `playwright` as a library for browser automation scripts — web scraping, PDF generation, screenshot capture, and any workflow that needs programmatic browser control without a test runner.
  145. ### Install
  146. ```bash
  147. npm i playwright
  148. ```
  149. ### Examples
  150. **Take a screenshot:**
  151. ```TypeScript
  152. import { chromium } from 'playwright';
  153. const browser = await chromium.launch();
  154. const page = await browser.newPage();
  155. await page.goto('https://playwright.dev/');
  156. await page.screenshot({ path: 'screenshot.png' });
  157. await browser.close();
  158. ```
  159. **Generate a PDF:**
  160. ```TypeScript
  161. import { chromium } from 'playwright';
  162. const browser = await chromium.launch();
  163. const page = await browser.newPage();
  164. await page.goto('https://playwright.dev/');
  165. await page.pdf({ path: 'page.pdf', format: 'A4' });
  166. await browser.close();
  167. ```
  168. **Emulate a mobile device:**
  169. ```TypeScript
  170. import { chromium, devices } from 'playwright';
  171. const browser = await chromium.launch();
  172. const context = await browser.newContext(devices['iPhone 15']);
  173. const page = await context.newPage();
  174. await page.goto('https://playwright.dev/');
  175. await page.screenshot({ path: 'mobile.png' });
  176. await browser.close();
  177. ```
  178. **Intercept network requests:**
  179. ```TypeScript
  180. import { chromium } from 'playwright';
  181. const browser = await chromium.launch();
  182. const page = await browser.newPage();
  183. await page.route('**/*.{png,jpg,jpeg}', route => route.abort());
  184. await page.goto('https://playwright.dev/');
  185. await browser.close();
  186. ```
  187. [Library documentation](https://playwright.dev/docs/library) | [API reference](https://playwright.dev/docs/api/class-playwright)
  188. ---
  189. ## VS Code Extension
  190. The [Playwright VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) brings test running, debugging, and code generation directly into your editor.
  191. <!-- TODO: hero screenshot of VS Code with Playwright sidebar -->
  192. **Run and debug tests** from the editor with a single click. Set breakpoints, inspect variables, and step through test execution with a live browser view.
  193. **Generate tests with CodeGen.** Click "Record new" to open a browser — navigate and interact with your app while Playwright writes the test code for you.
  194. **Pick locators.** Hover over any element in the browser to see the best available locator, then click to copy it to your clipboard.
  195. **Trace Viewer integration.** Enable "Show Trace Viewer" in the sidebar to get a full execution trace after each test run — DOM snapshots, network requests, console logs, and screenshots at every step.
  196. [Install the extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) | [VS Code guide](https://playwright.dev/docs/getting-started-vscode)
  197. ---
  198. ## Cross-Browser Support
  199. | | Linux | macOS | Windows |
  200. | :--- | :---: | :---: | :---: |
  201. | Chromium<sup>1</sup> <!-- GEN:chromium-version -->159.0.8154.6<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
  202. | WebKit <!-- GEN:webkit-version -->27.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
  203. | Firefox <!-- GEN:firefox-version -->159.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
  204. Headless and headed execution on all platforms. <sup>1</sup> Uses [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing) by default.
  205. ## Other Languages
  206. Playwright is also available for [Python](https://playwright.dev/python/docs/intro), [.NET](https://playwright.dev/dotnet/docs/intro), and [Java](https://playwright.dev/java/docs/intro).
  207. ## Resources
  208. * [Documentation](https://playwright.dev)
  209. * [API reference](https://playwright.dev/docs/api/class-playwright)
  210. * [MCP server](https://github.com/microsoft/playwright-mcp)
  211. * [CLI for coding agents](https://github.com/microsoft/playwright-cli)
  212. * [VS Code extension](https://github.com/microsoft/playwright-vscode)
  213. * [Contribution guide](CONTRIBUTING.md)
  214. * [Changelog](https://github.com/microsoft/playwright/releases)
  215. * [Discord](https://aka.ms/playwright/discord)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.