pub async fn browser() -> Result<Browser, Error>Expand description
Returns a managed headless Chromium Browser for the current test,
launching it on first call and closing it when the test ends.
The browser integrates directly with the test session:
- Pages reach gateways and frontends at their normal
encore runaddresses (such ashttp://localhost:4000), automatically routed to the test session. - Every request from the browser carries the test’s ID, so backend work
runs against the test’s isolated data and is awaited by
settled. - Browser actions, page requests, console errors, uncaught exceptions, and
failed requests appear in
telemetryalongside the backend spans they triggered. - Page activity is recorded; on failure, an HTML replay file is saved
(
Browser::recording).
Enable the chromiumoxide feature to use testing::chromiumoxide::connect,
or connect any other Chrome DevTools Protocol client to
Browser::ws_endpoint. Encore downloads the browser/chromium component
automatically on first use.
ⓘ
let browser = system::browser().await?;
let (chromium, handler) = chromiumoxide::Browser::connect(browser.ws_endpoint()).await?;
let page = chromium.new_page(browser.url("web")?).await?;