๐ข ๐๐ก๐๐ญ ๐๐ฅ๐๐ฒ๐ฐ๐ซ๐ข๐ ๐ก๐ญ ๐๐๐ ๐๐๐ญ๐ฎ๐๐ฅ๐ฅ๐ฒ ๐๐ฌ
Playwright CLI is a command-line tool for controlling a browser that is mostly used to generate UI tests, scrap data or build workflows.
You run commands in the terminal, and Playwright CLI can:
โ Open a website
โ Click buttons
โ Fill inputs
โ Press keys
โ Take screenshots
โ Read a page snapshot
It was designed for AI coding agents. But it is not only for AI. You can use it yourself from the terminal to check that the browser opens, the page loads, and the command returns useful page information.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ข ๐๐ก๐๐ญ ๐๐ฎ๐ง๐ฌ ๐๐ก๐๐ง ๐๐จ๐ฎ ๐จ๐ซ ๐๐ง ๐๐ ๐๐ ๐๐ง๐ญ ๐๐ฒ๐ฉ๐ ๐ ๐๐จ๐ฆ๐ฆ๐๐ง๐
1. You or your AI agent type a command in the terminal.
2. Playwright CLI reads it and opens the browser. It can run in headed mode (you see the window) or headless (no UI).
3. After the browser opens and the page loads, Playwright CLI takes a snapshot of the page. The snapshot is a small `.md` file with page details, including locators.
4. You or the AI agent read the snapshot and decide what to do next. If it shows a Login button, you see its accessibility ID (often something like `e10` or `e12`). Then you run a command such as `playwright-cli click e10` to click it.
That is the workflow in a nutshell:
Step 1 โ load the web page
Step 2 โ get a snapshot of it
Step 3 โ act on the snapshot information
Playwright CLI does not replace Playwright, Selenium, or Cypress. It is a different tool that sits on top of them.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๐๐๐๐๐๐ ๐ฏ๐ฌ ๐๐๐๐๐ฅ๐๐ฌ๐ฌ
Playwright CLI can open browsers in two modes: headed and headless.
Headed mode shows the browser on your screen. Use it when you set up the tool or when you need to see what happened.
Headless mode runs without a window. It is faster for repeat runs, but harder to watch.
Some failures only show up in one mode. If a command fails in headless, try headed once before you change the test.