pub struct Browser { /* private fields */ }Expand description
The main stealth browser
Implementations§
Source§impl Browser
impl Browser
Sourcepub fn owns_process(&self) -> bool
pub fn owns_process(&self) -> bool
Whether this handle owns the Chrome process, rather than borrowing it.
Sourcepub async fn watch_downloads(
&self,
directory: &Path,
) -> Result<DownloadWatch, Error>
pub async fn watch_downloads( &self, directory: &Path, ) -> Result<DownloadWatch, Error>
Reserve native download settings and subscribe before triggering a download. Only supported for owned processes. The directory must already exist.
Sourcepub async fn launch() -> Result<Browser, Error>
pub async fn launch() -> Result<Browser, Error>
Launch a new stealth browser with default config
Sourcepub async fn launch_visible() -> Result<Browser, Error>
pub async fn launch_visible() -> Result<Browser, Error>
Launch a new stealth browser with a visible window.
Sourcepub async fn launch_debug() -> Result<Browser, Error>
pub async fn launch_debug() -> Result<Browser, Error>
Launch a new visible stealth browser with debug logging behavior enabled.
Sourcepub async fn launch_with(
configure: impl FnOnce(&mut StealthConfig),
) -> Result<Browser, Error>
pub async fn launch_with( configure: impl FnOnce(&mut StealthConfig), ) -> Result<Browser, Error>
Launch with the default stealth config after applying inline changes.
This avoids constructing a full StealthConfig when only one or two
options need to change.
Sourcepub async fn launch_with_config(config: StealthConfig) -> Result<Browser, Error>
pub async fn launch_with_config(config: StealthConfig) -> Result<Browser, Error>
Launch with custom config
Sourcepub async fn connect(ws_url: &str) -> Result<Browser, Error>
pub async fn connect(ws_url: &str) -> Result<Browser, Error>
Connect to an existing Chrome instance at the given WebSocket CDP URL.
Obtain the URL from curl http://localhost:9222/json/version or use
Browser::connect_port for HTTP discovery.
Defaults to StealthConfig::live() so attaching to a user’s real browser
leaves their tabs untouched (no evasion script injection, full CDP access).
Sourcepub async fn connect_with_config(
ws_url: &str,
config: StealthConfig,
) -> Result<Browser, Error>
pub async fn connect_with_config( ws_url: &str, config: StealthConfig, ) -> Result<Browser, Error>
Connect to an existing Chrome instance with a custom config. Allows customizing CDP timeout, evasion scripts, proxy auth, etc.
Sourcepub async fn connect_port(port: u16) -> Result<Browser, Error>
pub async fn connect_port(port: u16) -> Result<Browser, Error>
Discover the DevTools URL on 127.0.0.1:<port> and connect.
Equivalent to curl http://127.0.0.1:<port>/json/version then Browser::connect.
Sourcepub async fn connect_port_with_config(
port: u16,
config: StealthConfig,
) -> Result<Browser, Error>
pub async fn connect_port_with_config( port: u16, config: StealthConfig, ) -> Result<Browser, Error>
connect_port with a custom config.
Sourcepub async fn new_page(&self, url: &str) -> Result<Page, Error>
pub async fn new_page(&self, url: &str) -> Result<Page, Error>
Create a new page and navigate to URL
Sourcepub async fn new_blank_page(&self) -> Result<Page, Error>
pub async fn new_blank_page(&self) -> Result<Page, Error>
Create a new page without navigation (at about:blank)
Sourcepub async fn attach_page(&self, target_id: &str) -> Result<Page, Error>
pub async fn attach_page(&self, target_id: &str) -> Result<Page, Error>
Attach to an existing browser target (e.g., a popup opened by window.open()).
Use tabs() to discover popup target IDs, then call this to get a Page handle.
Sourcepub async fn activate_tab(&self, target_id: &str) -> Result<(), Error>
pub async fn activate_tab(&self, target_id: &str) -> Result<(), Error>
Activate (focus) a tab by target ID
Sourcepub async fn close_tab(&self, target_id: &str) -> Result<(), Error>
pub async fn close_tab(&self, target_id: &str) -> Result<(), Error>
Close a specific tab by target ID
Sourcepub async fn close(self) -> Result<(), Error>
pub async fn close(self) -> Result<(), Error>
Gracefully close an owned browser, including owned live-session launches. Attached browsers are only disconnected, regardless of configuration. Chrome has a bounded opportunity to flush state before forced termination.
Sourcepub async fn disconnect(self) -> Result<(), Error>
pub async fn disconnect(self) -> Result<(), Error>
Drop the WebSocket without sending Browser.close. Use this when
connected to a user-owned browser to disconnect without killing it.