Browser agents: test your site the way the agent sees it|INEMA.CLUB-PRO

Lesson 2 · 20 min

Playwright MCP in Claude Code/Codex: the accessibility snapshot in practice

Playwright MCP gives your coding agent a browser. It doesn't send a screenshot: it sends the accessibility snapshot, with a reference (ref) on each control, and the agent acts through those refs. In this lesson a script makes exactly the calls the agent would make, without a model, and then you connect the server to Claude Code or Codex.

Start the lesson
A laptop open in a dark terminal, next to a monitor showing a booking form, neutral office light.

In this lesson you will

  1. 1The snapshot with refs (e13, e15, e18)
  2. 2The calls: navigate, snapshot, type, select, click, wait_for
  3. 3The common mistake: taking the snapshot before the page has finished loading
  4. 4Connect to Claude Code (.mcp.json) and Codex (config.toml)

Goal: do with Playwright MCP what the agent does: read the snapshot, find the control by its ref and act, and connect the server to your agent.

01From snapshot to click

Click each block.

Click each block in the diagram to see what it does.

A ref is valid for that snapshot only. If the page changed, take another.

02What the agent receives and what it does

Reading the dry-run output.

1. The tools

The server exposes 25 browser tools (browser_navigate, browser_snapshot, browser_click, browser_type, browser_select_option, browser_wait_for, browser_console_messages…). The agent sees them all in the list and chooses.

The project's documentation today also recommends a CLI-and-skills route for coding agents; the kit uses the tools over MCP, which is what Claude Code and Codex read.

03The dry run: the agent's calls, without a model

ver-como-agente.mjs connects Playwright MCP over stdio, the way Claude Code would, and does the task "see the times for Revisão completa".

Terminal · do the task through Playwright MCP
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node ver-como-agente.mjs; echo "saída: $?"
Terminal · the same, without waiting for the list
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node ver-como-agente.mjs --sem-esperar; echo "saída: $?"
Example from the repository
→ browser_navigate {"url":"http://127.0.0.1:PORTA/agendar.html"}
→ browser_snapshot {}
  achei: textbox "Seu nome" = e13 · combobox "Serviço" = e15 · button "Ver horários" = e18
→ browser_type {"target":"e13","text":"Ana"}
→ browser_select_option {"target":"e15","values":["Revisão completa"]}
→ browser_click {"target":"e18"}
→ browser_wait_for {"text":"horários livres para"}
→ browser_snapshot {}
  status na página: 2 horários livres para Revisão completa em 2026-11-03.
tarefa: horários de Revisão completa em 2026-11-03 → 2 (08:00, 13:00) em 7 chamadas
saída: 0

Seven calls. Each line with → is a tool called by the MCP client; PORTA stands in for the local server's random port.

04Your site and your agent

First read-only on your site; then the server connected to Claude Code and Codex, with the kit's Chromium.

Terminal · snapshot of one of your sites
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node ver-como-agente.mjs https://inema.club/; echo "saída: $?"
Terminal · connect to Claude Code and Codex
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node configurar.mjs && claude mcp get playwright; echo "saída: $?"
Example from the repository
→ browser_navigate {"url":"https://inema.club/"}
→ browser_snapshot {}
- generic [active] [ref=e1]:
  - banner [ref=e2]:
    - generic [ref=e3]:
      - link "INEMA.VIP Participe da Comunidade" [ref=e4] [cursor=pointer]:
        - /url: https://inema.vip
        - img "INEMA.VIP" [ref=e5]
        - generic [ref=e6]: Participe da Comunidade
      - link "INEMA.PRO Assine o INEMA.PRO" [ref=e7] [cursor=pointer]:
        - /url: https://inema.pro
        - img "INEMA.PRO" [ref=e8]
        - generic [ref=e9]: Assine o INEMA.PRO
      - generic [ref=e10]:
        - heading "INEMA.CLUB Portal INEMA" [level=1] [ref=e11]
        - paragraph [ref=e12]: "Aprenda Inteligência Artificial na prática: cursos, agentes, automação e comunidade"
        - generic [ref=e13]:
(…)
ferramentas WebMCP vistas: 8 · buscar_conhecimento [readOnly], buscar_cursos [readOnly], comparar_cursos [readOnly], …
snapshot: 1040 linhas · 749 elementos com ref
saída: 0

Here the site is inema.club, INEMA's own. On your machine, swap in the address of one of your own sites: a browser agent only against your own site. The summary shows how many lines and refs the agent receives; inema.club has an origin trial token, so the kit's Chromium 156 also saw its 8 WebMCP tools, with no flag at all.

05Practice

The dry run, your site, and your agent. Each exercise has a "done when".

E1 · The seven calls

10 min

Run the dry run, then the no-wait version. For each line with →, say in one sentence what the agent knew at that moment.

Done when: node ver-como-agente.mjs → 2 (08:00, 13:00) em 7 chamadas and saída: 0; with --sem-esperar → 0 (nenhum) and saída: 1.

E2 · The snapshot of your site

10 min

Run the read block with the address of one of your own sites. Open the same page in the browser and find three controls in the output by name.

Done when: node ver-como-agente.mjs with your site's address → snapshot: N linhas · M elementos com ref and saída: 0.

E3 · The server in your agent

10 min

Run configurar.mjs. In Claude Code, open claude inside kit/ and approve the project server. In Codex, paste the printed snippet into config.toml.

Done when: claude mcp get playwright → Scope: Project config and, after you approve, Status: ✓ Connected; in Codex, the server shows up in the /mcp list.

06Lesson quiz

Question 1 of 4

The snapshot shows textbox "Seu nome" [ref=e13]. How does the agent type into this field?skill

07In three sentences

Snapshot with refsThe agent receives the accessibility tree and acts through refs, not pixels.
Wait for the proofA snapshot taken too early becomes a wrong answer that looks right.
Connected to your agentA .mcp.json in the kit for Claude Code, the same snippet in Codex's config.toml.

Going further

Previous lessonNext lesson