| name | agent-eval-browser-interact |
| description | Use when translating natural language eval instructions into playwright-cli commands during AI agent evaluation โ clicking, typing, waiting, scrolling, screenshot capture |
Agent Eval โ Browser Interact
Overview
Translates natural language instructions into playwright-cli commands. Built on top of the playwright-cli skill โ uses snapshots to find element refs, then acts on them.
Pattern: Snapshot โ Identify โ Act โ Screenshot
For every natural language instruction:
playwright-cli snapshot โ get current page state with element refs
- Read the snapshot to identify the target element ref (e.g.,
e15)
- Execute the appropriate
playwright-cli command
playwright-cli screenshot --filename=<path> โ capture result
Action Mapping
| Natural Language | playwright-cli Command |
|---|
| "Click on X" / "Click the X button" | playwright-cli click <ref> |
| "Type 'text' in X" / "Enter 'text' in X" | playwright-cli fill <ref> "text" or playwright-cli type "text" |
| "Wait for the page to load" | playwright-cli run-code "async page => await page.waitForLoadState('networkidle')" |
| "Wait for X to appear" | playwright-cli snapshot and check for element, retry |
| "Wait for the agent to respond" | See below |
| "Scroll down" | playwright-cli run-code "async page => window.scrollBy(0, 500)" |
| "Press Enter" | playwright-cli press Enter |
| "Go to URL" | playwright-cli goto URL |
Finding Element Refs
playwright-cli snapshot
If the target element isn't obvious from the snapshot, use:
playwright-cli eval "el => el.textContent" e5
playwright-cli snapshot --depth=6
Waiting for Agent Response
This is the trickiest action. Strategy:
playwright-cli --raw eval "document.body.innerText.length"
playwright-cli run-code "async page => {
const before = await page.locator('body').innerText();
await page.waitForFunction(
prevLen => document.body.innerText.length > prevLen,
before.length,
{ timeout: 30000 }
);
await page.waitForTimeout(2000);
}"
Also check for loading indicators:
playwright-cli snapshot
Screenshot Capture
After every action:
playwright-cli screenshot --filename=screenshots/step-01-click.png
Error Recovery
If a command fails:
- Take a screenshot of current state:
playwright-cli screenshot --filename=screenshots/step-N-error.png
- Take a snapshot to understand what happened:
playwright-cli snapshot
- Log the error and continue to next step