DOM-Native Execution
DOM-Native Execution is Layer 0 of Hunch's action dispatch system. It works on every website on day one with no configuration.
What It Does
Instead of taking screenshots and simulating clicks with a headless browser, Hunch dispatches real DOM events directly in the page's JavaScript context. This matches how a human user interacts with a form — typing into inputs, selecting dropdowns, clicking submit — but runs programmatically.
How It Works
Field Discovery
The executor finds form fields using multiple strategies, tried in order:
nameattribute —<input name="email">or<select name="country">idattribute —<input id="signup-email">aria-labelattribute —<input aria-label="Email address">- Label text — finds the
<label>element associated with the field - Placeholder text —
<input placeholder="Enter your email">
Value Setting
Values are set using native DOM APIs that work with any framework:
HTMLInputElement.value = "..."withinputandchangeevents dispatchedHTMLSelectElement.selectedIndexfor dropdown selections- React-compatible value setting via
Object.getOwnPropertyDescriptorfor controlled components
Form Submission
Forms are submitted using requestSubmit() when a submit button is available, or form.submit() as a fallback. No click simulation on submit buttons occurs.
Why Not Puppeteer
Previous versions of Hunch used Puppeteer (headless Chrome) for form automation. This approach had several problems:
| Problem | Puppeteer | DOM-Native |
|---|---|---|
| Requires headless browser | Yes | No |
| Breaks on SPA navigation | Common | Never |
| Slow (browser startup) | ~2-5s | ~0ms |
| Detectable by anti-bot | Yes | No |
| Works on mobile | No | Yes |
| Framework-agnostic | No (React quirks) | Yes |
DOM-native execution runs in the visitor's own browser. No external browser launches, no screenshots are parsed, and no DOM tree is serialized or deserialized. The widget operates in the same JavaScript context as the page itself.
Limitations
DOM-native execution cannot:
- Execute JavaScript beyond form events — it cannot trigger custom click handlers outside forms
- Handle multi-step wizards — each step must complete before the next begins
- Bypass CAPTCHAs — if a form has a CAPTCHA, the widget stops and asks for manual completion
- Access cross-origin iframes — forms inside iframes from a different domain cannot be reached
For these cases, the widget redirects the visitor to the form's page URL, where they complete the action manually.
Best Practices
- Use semantic HTML —
<label>elements,nameattributes, andaria-labelhelp the executor find fields faster - Avoid custom dropdowns — native
<select>elements work reliably; custom dropdown components may not - Keep forms simple — single-page forms work best; multi-step wizards need each step to be independently submittable
Related
- Live Action Capture — Four-layer architecture overview
- Action Manifest — Declare your own endpoints
- Tools — Manage discovered tools