pub struct BrowserType { /* private fields */ }Expand description
Playwright-shaped browser factory. Construct via chromium /
firefox / webkit (top-level free functions in this crate)
or BrowserType::chromium_with for the Chromium transport
override.
Copy because the type is just two enum tags — keeping it copy
lets callers write chromium().launch(opts) without having to
bind the factory to a let first when reusing it across multiple
launches.
Implementations§
Source§impl BrowserType
impl BrowserType
Sourcepub fn chromium() -> Self
pub fn chromium() -> Self
Construct a Chromium BrowserType. Equivalent to the top-level
chromium function. Defaults to the CDP-pipe transport.
Sourcepub fn chromium_with(opts: &BrowserTypeOptions) -> Self
pub fn chromium_with(opts: &BrowserTypeOptions) -> Self
Construct a Chromium BrowserType with explicit
BrowserTypeOptions. transport: Some(Ws) switches to the
CDP-over-WebSocket backend (CdpRaw) instead of the pipe default.
Sourcepub fn firefox() -> Self
pub fn firefox() -> Self
Construct a Firefox BrowserType. Equivalent to the top-level
firefox function.
Sourcepub fn webkit() -> Self
pub fn webkit() -> Self
Construct a WebKit BrowserType. Equivalent to the top-level
webkit function. Only meaningfully usable on macOS — the
Self::launch path returns a typed error elsewhere.
Sourcepub fn with_backend(kind: BrowserKind, backend: BackendKind) -> Self
pub fn with_backend(kind: BrowserKind, backend: BackendKind) -> Self
Rust-only escape hatch used by the test runner to pin both the
product and the wire backend explicitly. NOT exposed in the JS
bindings — it’s intended for the test scaffolding that needs to
hold BrowserKind::Chromium + BackendKind::CdpRaw (etc.) without
going through chromium_with({ transport: Ws }).
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Playwright BrowserType.name() — "chromium" / "firefox" /
"webkit".
Sourcepub fn kind(self) -> BrowserKind
pub fn kind(self) -> BrowserKind
Underlying BrowserKind.
Sourcepub fn executable_path(self) -> Option<PathBuf>
pub fn executable_path(self) -> Option<PathBuf>
Path where ferridriver expects to find a bundled browser
executable. Mirrors Playwright’s BrowserType.executablePath().
Returns None if no bundled binary is available for this
product on the current platform.
Sourcepub async fn launch(self, options: LaunchOptions) -> Result<Browser>
pub async fn launch(self, options: LaunchOptions) -> Result<Browser>
Playwright: browserType.launch(options?) -> Browser.
§Errors
Returns an error if the browser process fails to start.
Sourcepub async fn connect(
self,
ws_endpoint: &str,
options: ConnectOptions,
) -> Result<Browser>
pub async fn connect( self, ws_endpoint: &str, options: ConnectOptions, ) -> Result<Browser>
Playwright: browserType.connect(wsEndpoint, options?) -> Browser.
ferridriver currently has no Playwright-server protocol of its
own; this accepts a CDP WebSocket endpoint and behaves like
Self::connect_over_cdp under the hood. Kept as a separate
method for surface parity with Playwright.
§Errors
Returns an error if the WebSocket handshake fails.
Sourcepub async fn connect_over_cdp(
self,
endpoint_url: &str,
_options: ConnectOverCdpOptions,
) -> Result<Browser>
pub async fn connect_over_cdp( self, endpoint_url: &str, _options: ConnectOverCdpOptions, ) -> Result<Browser>
Playwright: browserType.connectOverCDP(endpointURL, options?) -> Browser.
Chromium-only.
§Errors
Returns an error if the WebSocket handshake fails or the product is not Chromium.
Sourcepub async fn launch_persistent_context(
&self,
user_data_dir: &Path,
options: LaunchPersistentContextOptions,
) -> Result<ContextRef>
pub async fn launch_persistent_context( &self, user_data_dir: &Path, options: LaunchPersistentContextOptions, ) -> Result<ContextRef>
Playwright: browserType.launchPersistentContext(userDataDir, options?) -> BrowserContext.
Launches a browser whose default context shares storage with the
supplied user-data directory and applies the provided
BrowserContextOptions to that default context. Returns the
default ContextRef; closing the returned context (or the
underlying browser) terminates the launch.
§Errors
Returns an error if the browser process fails to start.
Trait Implementations§
Source§impl Clone for BrowserType
impl Clone for BrowserType
Source§fn clone(&self) -> BrowserType
fn clone(&self) -> BrowserType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more