> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-cli.md).

# With Playwright CLI

Record what an agent did with Playwright CLI, with a trace, video, screenshots and page snapshots, and share it as a Currents session

[Playwright CLI](https://www.npmjs.com/package/@playwright/cli) (`playwright-cli`) drives a browser from shell commands, so any agent with a shell can use it. When the agent records the browser while it works, you can check what it did: the screenshots, the video, the trace of every click and request, and the page text. Save the recording to Currents as a [session](/ai/agent-evidence.md), and you get one link to all of it.

## What you need

* Playwright CLI. See its [install steps](https://www.npmjs.com/package/@playwright/cli).
* The Currents CLI and a key. See [Install the Currents CLI and set a key](/ai/agent-evidence.md#install-the-currents-cli-and-set-a-key).

## Record a browser session

Start a Currents session, record with Playwright CLI, then attach the files and share the session:

```bash
npx currents session start --project-id <project-id> --title "Lowercase discount code applies 10% off" --status passed

playwright-cli open
playwright-cli tracing-start
playwright-cli video-start
playwright-cli goto http://localhost:3000/
playwright-cli snapshot
# ... fill, click and other commands
playwright-cli snapshot --filename=discount-applied-a11y.yml
playwright-cli screenshot --filename=discount-applied.png
playwright-cli video-stop
playwright-cli tracing-stop
playwright-cli close

npx currents session attach discount-applied.png discount-applied-a11y.yml .playwright-cli/traces
npx currents session share
```

* `snapshot` saves the page's accessibility tree, with its text, as a `.yml` file.
* `session attach` packs the `.playwright-cli/traces` folder into one trace. The video is also in `.playwright-cli`: attach it by name.
* Attach only the files you name. Do not attach the whole `.playwright-cli` folder: it holds the browser's storage state, with cookies, and anyone with the link could read it.
* Empty `.playwright-cli/traces` before each recording. Two recordings at once write to the same folder, and `session attach` would pack their traces together.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-61633d039dd5f596655ddfb602ac96cb4edc91d5%2Fterminal-playwright-cli.gif?alt=media" alt="A terminal running the commands above: currents session start, the playwright-cli commands and their output, currents session attach, and share, which prints the session link"><figcaption></figcaption></figure>

To have an agent do these steps, give it a Currents [skill](/ai/agent-skills.md). See [Record a bug and its fix](/ai/agent-evidence/bug-and-fix.md).

## What you get

The session page puts the screenshot, video, trace, page snapshot and console log on one timeline:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f9667d0741f6b5ed00de58fae0ca758953b5baea%2Fsession-playwright-cli.png?alt=media" alt="A session recorded with Playwright CLI on the Timeline view: rows for screenshots, videos, traces, and text and logs, with the video open below"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
