e1, e2, e3 that Camofox automatically generates for interactive elements on a page. They enable reliable automation without brittle CSS selectors or XPath queries.
What are element refs?
When you call the snapshot endpoint, Camofox analyzes the page’s accessibility tree and assigns sequential refs to every interactive element:[eN] is a stable reference you can use in click/type operations.
How refs work
Generation process
- Snapshot extracts accessibility tree using Playwright’s
ariaSnapshot()API - Filters interactive roles (button, link, textbox, checkbox, radio, etc.)
- Assigns sequential IDs starting from
e1 - Stores mapping in tab state:
refs: Map<refId, {role, name, nth}>
Internal storage
From server.js:172:role: Element’s ARIA role (button, link, textbox)name: Accessible name (button text, link text, aria-label)nth: Occurrence index for disambiguation (0-based)
Disambiguation with nth
When multiple elements have the same role+name, Camofox usesnth to distinguish them:
e1 always refers to the first “Submit” button, e2 to the second, etc.
Using refs in automation
Click element
Type text
Fallback to CSS selectors
If you need more control, use raw selectors:Refs are preferred over selectors because they:
- Work across framework re-renders (React, Vue, Next.js)
- Survive dynamic class name changes
- Match how screen readers see the page
Ref lifecycle
When refs are generated
- After navigation:
POST /tabs/:tabId/navigateauto-generates refs - After click:
POST /tabs/:tabId/clickrefreshes refs - On snapshot:
GET /tabs/:tabId/snapshotrebuilds refs from current page state
When refs reset
From server.js:939:Auto-refresh on stale state
If you try to click a ref but the ref map is empty, Camofox auto-refreshes:Interactive roles
Included roles
From server.js:53-56:Excluded roles
From server.js:51-57 comments:Skip patterns
Elements matching these patterns are also excluded:Real-world examples
From AGENTS.md workflow:Search Google
Fill form
Troubleshooting
”Unknown ref: e5”
Cause: Ref doesn’t exist or refs were reset by navigation. Solution: Call snapshot to get current refs:“strict mode violation”
Cause: Multiple elements matched without disambiguation. Fix: Camofox automatically uses.nth() to prevent this. If you see this error, it’s a bug - report it.
Ref points to wrong element
Cause: Page changed after snapshot (SPA re-render, lazy load). Solution: Refresh snapshot before interacting:Performance
Ref generation timeout
From server.js:184:Max refs per page
From server.js:177:Advanced: Ref-to-locator conversion
From server.js:680-692:e2 → Playwright locator using stored role/name/nth metadata.