Course
ai-dev-tools-zoomcamp
Question
Module 2's homework (Q6) suggests asking your agent to use the browser to verify
the frontend-backend connection. I did that. It ran npx playwright install, the
download succeeded, and the Chromium binary is confirmed present on disk — but
every attempt to actually navigate to a page fails. Why does an installed browser
fail to launch, and what should I do if my agent's environment can't fix it?
Answer
Root cause: Playwright has two separate install steps, and only the first one
works without root.
npx playwright install chromium downloads the browser binaries into a
user-writable cache directory. No root needed — this is the step that
succeeded for you.
npx playwright install --with-deps chromium additionally invokes the distro
package manager (apt-get on Debian/Ubuntu) to install the OS-level shared
libraries Chromium dynamically links against — NSS/crypto, graphics/GBM,
font, and audio libraries a desktop install has but a slim container generally
doesn't. Installing system packages needs root. If your agent runs in a
sandbox without sudo, this step can't complete.
So the binary exists and is executable, but the dynamic loader can't resolve its
dependencies. Playwright's own launch error names the specific missing
libraries directly — read that list from your own error output rather than
copying one from a FAQ, since exact names vary by distro and Playwright
version.
What to do, in order of preference:
- Check whether your environment can actually install them. If
id -u
returns 0 or sudo -n true succeeds, just run
npx playwright install --with-deps chromium. If you control the container,
Playwright's official Docker images ship the browsers and system deps
preinstalled.
- Run the browser check outside the agent's sandbox. The homework allows
manual verification — start both servers, open the frontend yourself, click
through, watch the Network tab. Least effort, and a genuinely real browser
check.
- Otherwise, verify at the HTTP contract level and say so explicitly. The
thing a browser adds over curl that matters most is CORS enforcement —
exercise it directly by sending the Origin header the browser would send
(substitute your own ports/routes):
curl -i -X OPTIONS http://localhost:8000/api/teams \
-H "Origin: http://localhost:5173" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: content-type"
curl -i -X POST http://localhost:8000/api/teams \
-H "Origin: http://localhost:5173" \
-H "Content-Type: application/json" \
-d '{"name": "Example"}'
Check the response carries an access-control-allow-origin header matching
your frontend's origin — a missing one is the most common "works in curl,
breaks in the browser" cause. Pair this with a type-check of your frontend's
API client (npx tsc --noEmit or npx tsc -b) to catch request/response
shape drift.
One caveat: this is weaker than a browser test — it doesn't exercise
rendering or client-side routing. If your agent falls back to it, make sure it
tells you a real browser navigation never happened, rather than reporting it as
a browser verification.
Checklist
Course
ai-dev-tools-zoomcamp
Question
Module 2's homework (Q6) suggests asking your agent to use the browser to verify
the frontend-backend connection. I did that. It ran
npx playwright install, thedownload succeeded, and the Chromium binary is confirmed present on disk — but
every attempt to actually navigate to a page fails. Why does an installed browser
fail to launch, and what should I do if my agent's environment can't fix it?
Answer
Root cause: Playwright has two separate install steps, and only the first one
works without root.
npx playwright install chromiumdownloads the browser binaries into auser-writable cache directory. No root needed — this is the step that
succeeded for you.
npx playwright install --with-deps chromiumadditionally invokes the distropackage manager (
apt-geton Debian/Ubuntu) to install the OS-level sharedlibraries Chromium dynamically links against — NSS/crypto, graphics/GBM,
font, and audio libraries a desktop install has but a slim container generally
doesn't. Installing system packages needs root. If your agent runs in a
sandbox without sudo, this step can't complete.
So the binary exists and is executable, but the dynamic loader can't resolve its
dependencies. Playwright's own launch error names the specific missing
libraries directly — read that list from your own error output rather than
copying one from a FAQ, since exact names vary by distro and Playwright
version.
What to do, in order of preference:
id -ureturns
0orsudo -n truesucceeds, just runnpx playwright install --with-deps chromium. If you control the container,Playwright's official Docker images ship the browsers and system deps
preinstalled.
manual verification — start both servers, open the frontend yourself, click
through, watch the Network tab. Least effort, and a genuinely real browser
check.
thing a browser adds over
curlthat matters most is CORS enforcement —exercise it directly by sending the
Originheader the browser would send(substitute your own ports/routes):
curl -i -X OPTIONS http://localhost:8000/api/teams \ -H "Origin: http://localhost:5173" \ -H "Access-Control-Request-Method: POST" \ -H "Access-Control-Request-Headers: content-type" curl -i -X POST http://localhost:8000/api/teams \ -H "Origin: http://localhost:5173" \ -H "Content-Type: application/json" \ -d '{"name": "Example"}'Check the response carries an
access-control-allow-originheader matchingyour frontend's origin — a missing one is the most common "works in curl,
breaks in the browser" cause. Pair this with a type-check of your frontend's
API client (
npx tsc --noEmitornpx tsc -b) to catch request/responseshape drift.
One caveat: this is weaker than a browser test — it doesn't exercise
rendering or client-side routing. If your agent falls back to it, make sure it
tells you a real browser navigation never happened, rather than reporting it as
a browser verification.
Checklist