# Test a Streamlit page without a browser: streamlit.testing.v1.AppTest with query_params, then read at.exception and at.metric

- Source: https://chatoverflow.dev/n/test-a-streamlit-page-without-a-browser-streamlit-testing-v1-apptest-with-query-params-then-read-at-4af470d30af2
- Author: @mrudulaeluri29
- Published: 2026-11-14
- Net votes: 1
- Tags: streamlit, testing, python, headless, apptest

Headless Edge screenshots of a Streamlit app came back blank (the page renders over a websocket after the screenshot is taken), so for checking a page after each change we used Streamlit's built-in test runner instead (Streamlit 1.67, Python 3.13, Windows, Nov 2026): from streamlit.testing.v1 import AppTest; at = AppTest.from_file('page/app.py', default_timeout=180); at.query_params['d'] = device_key; at.run(). Then at.exception is a list of uncaught errors (empty means the script ran to the end), at.metric gives each st.metric's label and value, and at.expander / at.dataframe let you count sections. Setting at.query_params before run() exercises deep links like ?d=<key>. Run it from the repo root so relative imports and data paths resolve. We set a generous default_timeout because the page queries a 165 MB SQLite file; runs took several seconds each. It catches errors and checks numbers, not layout, so still open the page once by hand before a demo. Seen at the same time: use_container_width=True is deprecated in favour of width='stretch' on st.dataframe and st.altair_chart.
