pub struct Browser { /* private fields */ }Expand description
A connected Chromium browser driven over CDP.
Created via Browser::launch or Browser::connect_over_cdp. Cheaply
cloneable (shares one connection).
Implementations§
Source§impl Browser
impl Browser
Sourcepub async fn launch(opts: LaunchOptions) -> Result<Browser>
pub async fn launch(opts: LaunchOptions) -> Result<Browser>
Spawn a local Chromium-based browser per opts.
Sourcepub async fn connect_over_cdp(
endpoint: &str,
opts: Option<ConnectOverCdpOptions>,
) -> Result<Browser>
pub async fn connect_over_cdp( endpoint: &str, opts: Option<ConnectOverCdpOptions>, ) -> Result<Browser>
Attach to an already-running Chromium given an http://host:port or
ws://... endpoint.
Sourcepub fn connection(&self) -> &Arc<CdpConnection> ⓘ
pub fn connection(&self) -> &Arc<CdpConnection> ⓘ
The browser-level CDP connection (advanced/power-user access).
Sourcepub fn new_browser_cdp_session(&self) -> CdpSession
pub fn new_browser_cdp_session(&self) -> CdpSession
A browser-level CdpSession (no sessionId). Equivalent to
Playwright’s browser.new_browser_cdp_session().
Sourcepub async fn new_context(&self) -> Result<BrowserContext>
pub async fn new_context(&self) -> Result<BrowserContext>
Create a new isolated browser context (incognito-style).
Sourcepub async fn version(&self) -> Result<String>
pub async fn version(&self) -> Result<String>
Browser version string (e.g. “HeadlessChrome/…”).
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether the underlying connection is still open.
Sourcepub fn browser_type(&self) -> BrowserType
pub fn browser_type(&self) -> BrowserType
The browser engine type this browser was launched as (always Chromium here).
Sourcepub fn contexts(&self) -> Vec<BrowserContext>
pub fn contexts(&self) -> Vec<BrowserContext>
All browser contexts created on this browser.
Sourcepub fn on_disconnected<F, Fut>(&self, handler: F)
pub fn on_disconnected<F, Fut>(&self, handler: F)
Register a handler invoked when the connection drops.