Fill and submit a web form from a script with verification

A button click is not a submitted record. The browser can deliver the click while validation rejects a field, the network fails, or the application returns an error page. A useful script checks what came back after submission and stops if the evidence is missing.

This walkthrough fills a public demonstration form at httpbin.org, submits it, and asserts both echoed fields in the response. Because httpbin.org is an HTTP echo endpoint, it confirms request delivery rather than database persistence. Send only synthetic test data, and run automated form scripts only against endpoints you own or whose terms permit automated submission.

Browser actions in Grip 6.5.1 require an active paid license (there is no free tier), and commands halt if a license expires or becomes invalid. Solo Dev ($79/year) is restricted to local developer work on up to 2 machines (no CI runners), whereas unattended headless and CI runs like the script below fall under Pro Runner ($499/year, up to 3 machines or CI runners); Platform (starts at $10k/year) covers bundling and external users. Plans renew annually with a 2-day refund window, and Grip renews its signed lease with gripui.com every 5 hours via gripui license activate <your-key> and gripui license status -- see Grip download and Grip pricing.

Run the example

Checked https://httpbin.org/robots.txt before running (Disallow: /deny only; /forms/post was allowed). Save this script and run it on a local machine with Grip 6.5.1 and Chrome installed, using a fresh profile name so quitting never deletes a profile you keep:

#!/bin/sh
set -eu
trap 'gripui quit --profile grip-review03c-20261204 >/dev/null 2>&1 || true' EXIT
export GRIPUI_SYNC=1
gripui @grip-review03c-20261204 set temporary
gripui @grip-review03c-20261204 set headless
gripui @grip-review03c-20261204 go https://httpbin.org/forms/post
gripui @grip-review03c-20261204 hud
gripui @grip-review03c-20261204 focus 'selector:input[name="custname"]'
gripui @grip-review03c-20261204 type 'Guide Test'
gripui @grip-review03c-20261204 hud
gripui @grip-review03c-20261204 click 'selector:input[value="small"]'
gripui @grip-review03c-20261204 hud
gripui @grip-review03c-20261204 click 'selector:button'
gripui @grip-review03c-20261204 hud || :
result=$(gripui @grip-review03c-20261204 read --full)
printf '%s\n' "$result" | grep -F '"custname": "Guide Test"' >/dev/null
printf '%s\n' "$result" | grep -F '"size": "small"' >/dev/null
printf '%s\n' 'Verified httpbin echoed the submitted values.'

On the tested macOS run, focus returned ok: focused tab=1 strategy=trusted_click_selector editable=true, type returned ok: typed tab=1 strategy=key_events chars=10 len=10, clicking the radio button returned ok: clicked tab=1 Small (now checked), and clicking button returned ok: clicked tab=1 Submit order. The final read --full returned len=2358 from https://httpbin.org/post with "custname": "Guide Test" and "size": "small" inside the echoed form JSON object.

Setting GRIPUI_SYNC=1 forces every command to wait for completion rather than returning a background handle after 2 seconds (normally inspected with gripui handle). The EXIT trap stops the daemon and deletes the temporary profile on normal exit or trapped shell errors, though a SIGKILL still requires a manual gripui quit --profile .... Keep profile names unique per concurrent job so scripts never collide on the same browser session.

Why these steps are separate

The opening hud confirms the form loaded ([2] Customer name:, [8] Small radio, [25] Submit order). Focusing selector:input[name="custname"] and typing into the active element avoids guessing stale refs across edits, while intermediate hud calls verify [active-element] and [checked] state before submitting. Because the selector: queries target this exact HTML form, a layout change will fail loudly instead of clicking the wrong control.

Notice that gripui do --help documents label matching (<query>), yet a label-based do attempt failed in earlier testing on this build while focus + type + click succeeded reliably. Re-running the exact sequence on the installed binary catches gaps between general CLI help and a specific form's DOM.

After clicking Submit order, hud navigated to https://httpbin.org/post and exited with code 1 (informational: Sheet: s2 | t1:top, exit: non-zero because available actions changed). That is why the script guards only that post-navigation hud with || : while keeping set -e active for every focus, type, click, read, and grep assertion.

Searching rendered text for "custname": "Guide Test" and "size": "small" works for httpbin.org's echo output, not as a general security boundary. Production applications may localize confirmation text, echo unsubmitted input on an error banner, or save asynchronously. Anchor real production checks on a created record ID, server read-back, or authoritative confirmation state.

Treat ambiguous outcomes as unknown

If click succeeds but the follow-up verification fails, do not blindly submit again. The server may have accepted the first POST even if the navigation timed out. Read the resulting page and query a safe read endpoint before retrying non-idempotent actions like payments, bookings, or account edits.

Validation errors differ from ambiguous network timeouts: inspect the error message, fix the input, and re-submit only when the form shows valid state. Stop if a site presents a CAPTCHA, human check, or terms prohibiting automation; never automate around access controls, and use only your own authorized accounts on permitted sites.

Remember too that httpbin.org/post echoes request headers back into the rendered page. Never print full read --full responses into shared CI logs if cookies, tokens, or personal data are in play. Log only the minimal non-sensitive assertion result.

When Playwright or an API fits better

When a service exposes a documented HTTP API with idempotency keys, prefer that API over driving UI forms. APIs survive CSS and layout churn and give explicit status codes on retry.

For repeatable browser-based form and regression testing in CI, Playwright is the better choice: page.getByLabel(...), page.getByRole(...), and .fill(...) pair with auto-retrying expect assertions, isolated browser contexts, and Trace Viewer across Chromium, Firefox, and WebKit. Grip fits shell-driven operator tasks where a script drives a persistent local profile or pauses for human sign-in via gripui human-drives. To run Grip against an isolated BrowserBox server you own instead of a local browser, use gripui connect browserbox '<login-link>' --engine (not exercised in this walkthrough); see BrowserBox evaluation and Grip pricing.

Your agent. Your browser.

Put it to work.

Get started

macOS · Linux · Windows
Paid licence required. Bring your own AI agent.

Demo recording

Player unavailable? Watch on YouTube ↗