All skills
fugazi avatar

/playwright-cli

@f84a7be

Drive a live browser from the CLI with playwright-cli to navigate, interact, snapshot, and capture evidence. Use for ad-hoc browser commands, page inspection, screenshots, traces, network mocking, session management, or interactive debugging—not authoring @playwright/test specs. Keywords: playwright-cli, browser automation, live session, snapshot, console, tracing.

Use this Skill: https://skilld.dev/gh/fugazi/test-automation-skills-agents/playwright-cli

This session only. Nothing lands on disk.

referencesrequest-mocking.md

≈589 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Request Mocking

Part of the playwright-cli skill. See SKILL.md for full context.

Intercept, mock, modify, and block network requests.

CLI Route Commands

# Mock with custom status
playwright-cli route "**/*.jpg" --status=404

# Mock with JSON body
playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json

# Mock with custom headers
playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value"

# Remove headers from requests
playwright-cli route "**/*" --remove-header=cookie,authorization

# List active routes
playwright-cli route-list

# Remove a route or all routes
playwright-cli unroute "**/*.jpg"
playwright-cli unroute

URL Patterns

**/api/users           - Exact path match
**/api/*/details       - Wildcard in path
**/*.{png,jpg,jpeg}    - Match file extensions
**/search?q=*          - Match query parameters

Advanced Mocking with run-code

For conditional responses, request body inspection, response modification, or delays:

Conditional Response Based on Request

playwright-cli run-code "async page => {
  await page.route('**/api/login', route => {
    const body = route.request().postDataJSON();
    if (body.username === 'admin') {
      route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
    } else {
      route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
    }
  });
}"

Modify Real Response

playwright-cli run-code "async page => {
  await page.route('**/api/user', async route => {
    const response = await route.fetch();
    const json = await response.json();
    json.isPremium = true;
    await route.fulfill({ response, json });
  });
}"

Simulate Network Failures

playwright-cli run-code "async page => {
  await page.route('**/api/offline', route => route.abort('internetdisconnected'));
}"
# Options: connectionrefused, timedout, connectionreset, internetdisconnected

Delayed Response

playwright-cli run-code "async page => {
  await page.route('**/api/slow', async route => {
    await new Promise(r => setTimeout(r, 3000));
    route.fulfill({ body: JSON.stringify({ data: 'loaded' }) });
  });
}"

Source: SKILL.md on GitHub

1 warning5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    The playwright-cli skill provides powerful browser automation capabilities, including arbitrary JavaScript execution, network interception, and browser state management. While these tools are essential for the skill's purpose, they create a vulnerability surface for indirect prompt injection if the agent navigates to untrusted websites. The skill also facilitates capturing sensitive browser data such as cookies and session tokens to local files.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: MEDIUM · 1 issue

Signed by skilld at f84a7be. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 5 days ago

README badge

README badge for fugazi/test-automation-skills-agents/playwright-cli