The playwright skill gives Codex a full headless (or headed) browser it can drive entirely from the terminal. It wrapsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/openai/skills/llms.txt
Use this file to discover all available pages before exploring further.
playwright-cli in a bundled shell script so the CLI works via npx even without a global install, and it establishes a consistent element-reference model — snapshot first, then interact using stable refs — that keeps automation reliable across navigation and dynamic UI changes.
Trigger Conditions
Codex activates this skill when you ask it to:- Automate a browser workflow or user journey
- Navigate to a URL and interact with the page
- Fill a form, click a button, or submit data in a browser
- Take a screenshot or PDF of a page
- Extract text or structured data from a live page
- Debug a UI flow with traces or console inspection
Prerequisite Check
Before proposing any commands, the skill verifies thatnpx is available, because the wrapper depends on it:
npx is missing, the skill pauses and asks you to install Node.js/npm:
npx is present the wrapper script takes over. A global install of playwright-cli is optional.
Setting Up the Wrapper Script
The skill sets$PWCLI once per session so every command goes through the bundled wrapper:
$CODEX_HOME/skills (default: ~/.codex/skills).
You can add a convenience alias:
npx --package @playwright/cli playwright-cli internally, so the CLI runs without a global install. Use "$PWCLI" unless your repo already standardizes on a global install.
Key Commands
Core interaction
Navigation
Data extraction
DevTools & tracing
Tabs
Core Workflow
Snapshot to get element refs
e3. Refs become stale after navigation or significant DOM changes — snapshot again whenever a command fails with a missing ref.Re-snapshot after navigation or DOM changes
Common Workflows
Sessions
Use named sessions to isolate work across projects:Configuration File
The CLI readsplaywright-cli.json from the current directory by default. Use --config to point at a specific file. Minimal example:
Guardrails
- Prefer explicit commands over
evalandrun-codeunless the task requires them. - When you do not have a fresh snapshot, use placeholder refs like
eXand explain why — do not bypass refs withrun-code. - Use
--headedwhen a visual check will help. - Default to CLI commands and workflows, not Playwright test specs (
@playwright/test). Use test specs only if you explicitly ask for them.
Troubleshooting
| Problem | Fix |
|---|---|
| Element ref fails | Run "$PWCLI" snapshot again and retry with the new ref |
| Page looks wrong | Re-open with --headed and resize the window |
| Flow needs prior state | Use a named --session |