DEV Community

Aleksandr Argunov
Aleksandr Argunov

Posted on Originally published at argbe.tech AI-assisted

Your form looks labelled. Here's what an AI agent reads instead

A form can look labelled and still hand an agent a nameless box.

Here's a small script that shows it. It builds a sample page and prints an accessibility snapshot, with JavaScript on and then off. Use a Bash or Zsh terminal with Node installed.

mkdir agent-check && cd agent-check
npm init -y
npm install playwright@1.60.0
npx playwright install chromium

cat > page.html <<'EOF'
<!doctype html>
<meta charset="utf-8">
<title>Acme Dog Beds</title>
<h1 id="pitch"></h1>
<script>pitch.textContent = 'Dog beds from €49'</script>
<form>
  <span>Email</span> <input type="email">
  <label>Dog's name <input type="text"></label>
  <button>Book a fitting</button>
</form>
EOF

cat > check.mjs <<'EOF'
import { chromium } from 'playwright'

const browser = await chromium.launch()
for (const javaScriptEnabled of [true, false]) {
  const context = await browser.newContext({ javaScriptEnabled })
  const page = await context.newPage()
  await page.goto(process.argv[2])
  console.log(`--- JavaScript ${javaScriptEnabled ? 'on' : 'off'} ---`)
  console.log(await page.locator('body').ariaSnapshot())
  await context.close()
}
await browser.close()
EOF

node check.mjs "file://$PWD/page.html"
Enter fullscreen mode Exit fullscreen mode

Run this and you get:

--- JavaScript on ---
- heading "Dog beds from €49" [level=1]
- text: Email
- textbox
- text: Dog's name
- textbox "Dog's name"
- button "Book a fitting"
--- JavaScript off ---
- heading [level=1]
- text: Email
- textbox
- text: Dog's name
- textbox "Dog's name"
- button "Book a fitting"
Enter fullscreen mode Exit fullscreen mode

Read the two textbox lines. A person sees "Email" beside the first field. In the tree it has no name, because a <span> next to an input isn't a label. W3C shows labels linked by matching for and id values, or wrapped around the control. Wrap it here and the line becomes textbox "Email".

Then read the headings. With JavaScript off, the pitch and the price are gone.

This output is an accessibility snapshot in YAML. Playwright MCP also lets agents read structured accessibility snapshots without needing screenshots. It's one way a browser agent reads a page.

Point it at a site you own:

node check.mjs https://yoursite.com
Enter fullscreen mode Exit fullscreen mode

Look for words that vanish in the second half, and any - textbox with no name after it. Each page loads in a fresh browser context, without your login. The script doesn't click through a form or inspect fields revealed later. The output above comes from the sample page, using Playwright 1.60.0.

The rest of the scorecard

That script helps with two of six checks. Here's the whole scorecard to test your website with an AI agent. It's my rubric, not a standard.

A blank scorecard titled "Can an AI agent use your website?" with six rows and empty pass and fail boxes: AI says what you sell, The right crawlers get in, Works without JavaScript, Price in two clicks, The agent finishes the task, Every form field has a label. Below the rows are empty fields for site and task, and a score out of six.

AI says what you sell. Ask an AI chat what your company sells and who it's for. Compare the answer with your homepage. Record the model, date, prompt and whether it visited the site. A correct description doesn't prove it can use the site.

The right crawlers get in. robots.txt can say yes while your firewall says no, so check both:

curl -sS -L https://yoursite.com/robots.txt
curl -sS -L -o /dev/null -w '%{http_code}\n' -A 'GPTBot' https://yoursite.com/
Enter fullscreen mode Exit fullscreen mode

Replace GPTBot with the crawler you chose. A 403 means this request was refused, but doesn't establish why. A 200 doesn't prove the real crawler gets in. Check your CDN's bot settings and verified crawler requests in its logs too.

The names do different jobs: OpenAI separates GPTBot for training from OAI-SearchBot for search, and Anthropic separates ClaudeBot from Claude-SearchBot in the same way. Cloudflare announced default blocking for AI crawlers in July 2025, with new domains asked whether to allow them. Check the actual settings on your site.

Works without JavaScript. It's a fallback check for crawlers that don't run JavaScript. It isn't an agent simulation, since browser tools run a real browser.

Price in two clicks. More than two clicks from the homepage is a fail. That's my cutoff for this card, not a universal usability rule. Record the path. If you have no public price, pick another target, such as the quote form, before you start.

The agent finishes the task. Give an agent your main task and count the steps until it finishes or gives up. In Claude Code, claude mcp add playwright npx @playwright/mcp@latest adds a browser. Tell it where to stop:

Go to https://yoursite.com.
Your task: book a call for next Tuesday.
Do not pay. Do not send the final form. Stop one step before.
List every step you took and every place you got stuck.
Enter fullscreen mode Exit fullscreen mode

If it reaches the stopping point, record "reached final step; submission untested". To test completion, use a test environment where submission is allowed and verify the result. Write down each time a person stepped in, and why. A required confirmation before a sensitive action doesn't, by itself, mean the site failed.

Every form field has a label. Check all fields along the task path, including ones revealed later. The script helps spot nameless controls on the page it loads; it isn't a complete audit.

Mark each row pass, fail or untested, with the evidence beside it. The total counts passes, not the severity of a problem. Crawler access, HTML fallback and form labels can fail for different reasons.

A blank card to copy, with an evidence field for each row, is in the article on argbe.tech.

Top comments (1)

Collapse
 
dosaygo profile image
dosaygo •

Raw ariaSnapshot() YAML exposes orphan span labels right away, and in real production SPAs the bigger failure is custom div controls with click listeners that never enter the ARIA role tree as interactive elements at all. Pairing nearby visual row context and registered CDP click/pointer listeners with stable numbered element refs lets a browser agent target that unlabelled email input and custom triggers reliably without falling back to screenshot coordinates. Running that check in a cold, logged-out context also misses the checkout and settings forms behind SSO where orphaned labels actually block transactions.