- Headless Chromium in a Sailbox, printing the title of
https://example.com. - A sign-in where the browser types a placeholder and the site receives the password.
Copy agent prompt (recommended):
Share this page with your coding agent or paste the prompt below.Manual steps
1. Build the image and create a Sailbox
You’ll need the latest Sail SDK (pip install -U sail) and a
Sail API key in SAIL_API_KEY. If
you’ve already run sail auth login on this machine, you can skip the key.Run this script on your machine. It prints the Sailbox ID, which later
commands take as <sailbox-id>.create_box.py
2. Open a page
Save this script on your machine:browse.py
Example Domain.3. Sign in without giving the browser the password
Save this egress policy aslogin.json. It sets LOGIN_PASSWORD in the
Sailbox to a placeholder such as sail_ph_3kTq9..., and replaces the
placeholder with the secret DEMO_PASSWORD in the password field of a form
posted to httpbin.org, a test site.login.json
login.py
Output
hunter2 is in the output because
httpbin sends back what it received.For your own site, name its host, the path its form posts to, and its
password field in the policy. A site that signs in with a JSON request needs
json in place of form, with a JSON Pointer such as "/password" as the
key. The reference covers form and json.Run Chromium with a window
A Sailbox has no screen. To give Chromium a window, addheadless=False to
launch and run the script under xvfb-run, which provides a virtual
screen:Watch or take over the browser
Launch Chromium with a debugging port, and keep the script running while you watch, for example withpage.wait_for_timeout(600_000) before
browser.close():sail box exec as before. In a second terminal on your
machine, run
sail box shell <sailbox-id>. While that
shell is open, the Sailbox’s port 9222 is also on localhost:9222 on your
machine, unless that port is already in use there. Open chrome://inspect in
Chrome and choose inspect under the page. You see the page as it changes
and can click and type in it.When you’re done, terminate the Sailbox with
sail box terminate <sailbox-id>.Gotchas
Submitting a form fails with ERR_HTTP_RESPONSE_CODE_FAILURE
Submitting a form fails with ERR_HTTP_RESPONSE_CODE_FAILURE
Sail answered with status 502 and didn’t send the form. The rule matched,
but the placeholder was in a field it doesn’t name, or the form uploads
files (
multipart/form-data), which a rule can’t change.The site rejects the password
The site rejects the password
The rule probably didn’t match, and the site received the placeholder.
Check the rule’s host, method, and path.
How do I turn on Chromium's sandbox?
How do I turn on Chromium's sandbox?
Playwright starts Chromium without its sandbox. Chromium won’t enable it
as root. Add a user to the image with
.run_commands("useradd -m browser"), pass chromium_sandbox=True to
launch, and run the script as that user: