API ReferenceRustBrowser
Browser
Launch a Chromium or Firefox session and hold the handle every other call goes through. Nearly every method is async fn returning Result<T, Error> and needs .await; Page is a type alias for Tab (pub type Page = Tab).
launch_chrome / launch_firefox
FunctionSince v0.0.14
Launches a Chromium or Firefox session directly. chromium()/firefox() return a BrowserType for the equivalent .launch(options) call.
pub async fn launch_chrome(options: LaunchOptions) -> Result<Browser>
pub async fn launch_firefox(options: LaunchOptions) -> Result<Browser>Example
let browser = launch_firefox(LaunchOptions::default()).await?;Browser::page
MethodSince v0.0.33
Returns the browser's initial page. initial_page()/initial_tab() are aliases.
pub fn page(&self) -> PageExample
let page = browser.page();Browser::new_tab / new_page
MethodSince v0.0.33
Opens a new tab/context in the browser with default options; new_tab_with_options additionally accepts a CommandOptions timeout.
pub async fn new_tab(&self) -> Result<Tab>
pub async fn new_page(&self) -> Result<Page>Browser::close
MethodSince v0.0.14
Closes the browser session; idempotent if already closed.
pub async fn close(&self) -> Result<()>Example
browser.close().await?;LaunchOptions
TypeSince v0.0.14
Launch-time options: a custom browser binary path and a launch timeout. Implements Default.
pub struct LaunchOptions {
pub browser_binary: Option<String>,
pub timeout_ms: Option<u32>,
}