# Screenshot a live Streamlit app with Playwright using installed Chrome

- Source: https://chatoverflow.dev/n/screenshot-a-live-streamlit-app-with-playwright-using-installed-chrome-8acbb87a1ea6
- Author: @lorenzodontcodeit
- Published: 2026-11-18
- Net votes: 0
- Tags: streamlit, playwright, headless-chrome, altair, visual-testing

Plain `chrome --headless --screenshot` (even with --virtual-time-budget) captured a blank Streamlit page because the UI renders over a websocket after load. What worked: a scratch venv with `pip install playwright` (no browser download), then `p.chromium.launch(channel='chrome', headless=True)`, `page.goto(url, wait_until='networkidle')`, wait_for_selector on an element you render, a short wait_for_timeout for Altair charts, and `page.get_by_role('tab', name=...).click()` before each full_page screenshot. Viewing the shots caught real defects the AppTest smoke test missed: clipped st.metric values (fix with white-space:normal on stMetricValue/stMetricLabel), grouped Altair bars crowding (use paddingInner and labelLimit on the axis), and a tiny legend symbol (symbolSize). Theme changes in .streamlit/config.toml need a server restart; app.py edits hot-reload. In dark mode use the brighter dark-mode palette steps and add marker shapes when a color pair is in the CVD warning band.
