Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ tsconfig.tsbuildinfo
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.playwright-cli
65 changes: 65 additions & 0 deletions packages/replayio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,71 @@ This CLI will automatically prompt you to log into your Replay account (or to re

The CLI will also prompt you to download the Replay runtime if you have not already done so.

## Browser facade

`replayio` exposes Playwright CLI under the `browser` command:

```bash
replayio browser open https://google.com
replayio browser click "text=Sign in"
replayio browser close
```

`@playwright/cli` is launched with Replay Browser through `PLAYWRIGHT_MCP_EXECUTABLE_PATH`.
You can override the Playwright CLI binary with `REPLAYIO_PLAYWRIGHT_CLI_PATH`.

When `replayio browser close` succeeds, replayio deterministically prints:

- a generated Playwright test assembled from captured `### Ran Playwright code` blocks
- a numbered step list derived from the captured actions

Recordings for the closed browser session are also auto-uploaded when authenticated (`replayio login` or `REPLAY_API_KEY`).

## Agent command

`replayio` also includes an Anthropic-driven browser agent:

```bash
replayio agent https://youtube.com "find the latest replayio video"
replayio agent --headed https://youtube.com "find the latest replayio video"
replayio agent --url https://youtube.com "find the latest replayio video"
```

The agent opens a browser session, runs an action loop via `replayio browser`, closes the session, uploads the recording, and then posts metadata to your analyze endpoint.
Run mode requires a start URL.
Set `ANTHROPIC_API_KEY` and (optionally) `REPLAY_AGENT_ANALYZE_ENDPOINT`.
It also prints the equivalent deterministic Playwright test generated for the session.
The analyze endpoint is only called when the agent marks the goal as unsuccessful.

Each run is written to `/Users/$USER/.replay/profile/agent-history.json` (or `RECORD_REPLAY_DIRECTORY/profile/agent-history.json`).

### Agent history

```bash
replayio agent history
replayio agent history --json
replayio agent history --limit 50
```

### Output tests from history

```bash
replayio agent history tests --id <run-id>
replayio agent history tests --ids <run-id-1>,<run-id-2>
replayio agent history tests --all
replayio agent history tests --failed
replayio agent history tests --passed
# shorthand:
replayio agent history --failed
```

These commands print test code to stdout so you can pipe it:

```bash
replayio agent history tests --failed | pbcopy
replayio agent history tests --passed > passed-tests.ts
```

## Contributing

Contributing guide can be found [here](contributing.md).
139 changes: 139 additions & 0 deletions packages/replayio/Skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
name: replayio browser
description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
allowed-tools: Bash(replayio browser:*)
---

# Browser Automation with replayio browser

## Quick start

```bash
# open new browser
replayio browser open
# navigate to a page
replayio browser goto https://playwright.dev
# interact with the page using refs from the snapshot
replayio browser click e15
replayio browser type "page.click"
replayio browser press Enter
# take a screenshot
replayio browser screenshot
# close the browser
replayio browser close
```

## Commands

### Core

```bash
replayio browser open
# open and navigate right away
replayio browser open https://example.com/
replayio browser goto https://playwright.dev
replayio browser type "search query"
replayio browser click e3
replayio browser dblclick e7
replayio browser fill e5 "user@example.com"
replayio browser drag e2 e8
replayio browser hover e4
replayio browser select e9 "option-value"
replayio browser upload ./document.pdf
replayio browser check e12
replayio browser uncheck e12
replayio browser snapshot
replayio browser snapshot --filename=after-click.yaml
replayio browser eval "document.title"
replayio browser eval "el => el.textContent" e5
replayio browser dialog-accept
replayio browser dialog-accept "confirmation text"
replayio browser dialog-dismiss
replayio browser resize 1920 1080
replayio browser close
```

### Navigation

```bash
replayio browser go-back
replayio browser go-forward
replayio browser reload
```

### Keyboard

```bash
replayio browser press Enter
replayio browser press ArrowDown
replayio browser keydown Shift
replayio browser keyup Shift
```

### Mouse

```bash
replayio browser mousemove 150 300
replayio browser mousedown
replayio browser mousedown right
replayio browser mouseup
replayio browser mouseup right
replayio browser mousewheel 0 100
```

### Save as

```bash
replayio browser screenshot
replayio browser screenshot e5
replayio browser screenshot --filename=page.png
replayio browser pdf --filename=page.pdf
```

### Tabs

```bash
replayio browser tab-list
replayio browser tab-new
replayio browser tab-new https://example.com/page
replayio browser tab-close
replayio browser tab-close 2
replayio browser tab-select 0
```

### Install

```bash
replayio install
```

### Browser Sessions

```bash
# create new browser session named "mysession" with persistent profile
replayio browser -s=mysession open example.com --persistent
# same with manually specified profile directory (use when requested explicitly)
replayio browser -s=mysession open example.com --profile=/path/to/profile
replayio browser -s=mysession click e6
replayio browser -s=mysession close # stop a named browser
replayio browser -s=mysession delete-data # delete user data for persistent session

replayio browser list
# Close all browsers
replayio browser close-all
# Forcefully kill all browser processes
replayio browser kill-all
```

## Example: Form submission

```bash
replayio browser open https://example.com/form
replayio browser snapshot

replayio browser fill e1 "user@example.com"
replayio browser fill e2 "password123"
replayio browser click e3
replayio browser snapshot
replayio browser close
```
1 change: 1 addition & 0 deletions packages/replayio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
],
"homepage": "https://github.com/replayio/replay-cli/blob/main/packages/replayio/README.md",
"dependencies": {
"@playwright/cli": "latest",
"@replayio/protocol": "^0.71.0",
"@replayio/sourcemap-upload": "workspace:^",
"@types/semver": "^7.5.6",
Expand Down
2 changes: 2 additions & 0 deletions packages/replayio/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "./commands/info";
import "./commands/list";
import "./commands/login";
import "./commands/logout";
import "./commands/browser";
import "./commands/agent";
import "./commands/open";
import "./commands/record";
import "./commands/remove";
Expand Down
Loading
Loading