pub struct LaunchOptions {Show 23 fields
pub engine: EngineType,
pub launch: LaunchMode,
pub user_data_dir: Option<PathBuf>,
pub headless: bool,
pub slow_mo: u64,
pub verbose: bool,
pub restrictions: Vec<String>,
pub args: Vec<String>,
pub extra_args: Vec<String>,
pub ignore_default_args: Vec<String>,
pub ignore_all_default_args: bool,
pub env: Option<HashMap<String, String>>,
pub channel: Option<String>,
pub executable_path: Option<PathBuf>,
pub remote_debugging_port: Option<u16>,
pub color_scheme: Option<ColorScheme>,
pub launch_timeout: Option<Duration>,
pub sandbox: bool,
pub node_executable: Option<PathBuf>,
pub node_working_dir: Option<PathBuf>,
pub automation_parity: bool,
pub fingerprint: Option<FingerprintProfile>,
pub downloads: DownloadSetting,
}Expand description
Options for launching a browser.
Fields§
§engine: EngineTypeThe browser engine to use.
launch: LaunchModeWho starts the browser; LaunchMode::Real by default.
user_data_dir: Option<PathBuf>Persistent profile directory. When None a fresh temporary profile is
created for the launch and deleted by LaunchResult::close.
headless: boolRun in headless mode.
slow_mo: u64Slow down operations by this many milliseconds (default 0).
verbose: boolEnable verbose logging.
restrictions: Vec<String>Opt-in restrictions from launch-restrictions.json, such as
no-extensions or the legacy-defaults preset (issue #103).
args: Vec<String>Additional Chrome arguments.
extra_args: Vec<String>Additional Chrome arguments appended after the compatibility args.
ignore_default_args: Vec<String>Engine default switches to omit (LaunchMode::Engine only).
ignore_all_default_args: boolOmit every engine default switch (LaunchMode::Engine only).
env: Option<HashMap<String, String>>Extra environment for the browser process only; the parent’s environment is never modified.
channel: Option<String>Installed browser channel, such as chrome, chrome-beta, msedge,
brave or chromium.
executable_path: Option<PathBuf>Explicit path to a Chrome or Chromium executable.
remote_debugging_port: Option<u16>Fixed CDP port for the real launch; a free one is reserved when None.
color_scheme: Option<ColorScheme>Color scheme to emulate. None uses the system default.
launch_timeout: Option<Duration>Optional timeout for the browser launch handshake.
sandbox: boolWhether to run the browser with the Chromium sandbox enabled.
Defaults to true. Disable when running in environments where the
sandbox is unavailable (e.g. CI containers without the required
capabilities). This adds --no-sandbox.
node_executable: Option<PathBuf>Node.js executable for Playwright/Puppeteer fallback engines.
node_working_dir: Option<PathBuf>Working directory used to resolve Playwright/Puppeteer Node packages.
automation_parity: boolKeep navigator.webdriver false where a launch switch would turn it on
(headless or engine launches).
Defaults to true. Set to false to launch with the engine’s own
defaults, which is what the parity tests use as a negative control.
fingerprint: Option<FingerprintProfile>The environment pages should see: user agent, time zone, locale, core count, screen and the rest.
Applied over CDP once the browser is up, so it only works for the
chromiumoxide engine; see
fingerprint::profile for the field list
and presets for ready-made machines.
downloads: DownloadSettingManage the browser’s downloads: where they are saved, how they are named, and whether they outlive the browser.
Downloads are redirected over CDP, so this only works for the
chromiumoxide engine; the other engines refuse rather than accept a
setting they cannot honor. See downloads.
Implementations§
Source§impl LaunchOptions
impl LaunchOptions
Sourcepub fn engine(self, engine: EngineType) -> Self
pub fn engine(self, engine: EngineType) -> Self
Set the browser automation engine.
Sourcepub fn chromiumoxide() -> Self
pub fn chromiumoxide() -> Self
Create options for chromiumoxide engine.
Sourcepub fn fantoccini() -> Self
pub fn fantoccini() -> Self
Create options for fantoccini (WebDriver) engine.
Sourcepub fn playwright() -> Self
pub fn playwright() -> Self
Create options for Playwright through the Node.js CLI bridge.
Sourcepub fn launch(self, launch: LaunchMode) -> Self
pub fn launch(self, launch: LaunchMode) -> Self
Choose who starts the browser.
Sourcepub fn user_data_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn user_data_dir(self, dir: impl Into<PathBuf>) -> Self
Use a persistent profile directory instead of a temporary one.
Sourcepub fn restrictions<I, S>(self, restrictions: I) -> Self
pub fn restrictions<I, S>(self, restrictions: I) -> Self
Opt in to restrictions or presets from launch-restrictions.json.
Sourcepub fn with_extra_args(self, args: Vec<String>) -> Self
pub fn with_extra_args(self, args: Vec<String>) -> Self
Add Chrome arguments after the compatibility args field.
Sourcepub fn ignore_default_args(self, args: Vec<String>) -> Self
pub fn ignore_default_args(self, args: Vec<String>) -> Self
Omit selected engine default switches (LaunchMode::Engine only).
Sourcepub fn ignore_all_default_args(self) -> Self
pub fn ignore_all_default_args(self) -> Self
Omit every engine default switch (LaunchMode::Engine only).
Sourcepub fn env(self, env: HashMap<String, String>) -> Self
pub fn env(self, env: HashMap<String, String>) -> Self
Extra environment for the browser process only.
Sourcepub fn executable_path(self, executable_path: impl Into<PathBuf>) -> Self
pub fn executable_path(self, executable_path: impl Into<PathBuf>) -> Self
Select an explicit Chrome or Chromium executable.
Sourcepub fn remote_debugging_port(self, port: u16) -> Self
pub fn remote_debugging_port(self, port: u16) -> Self
Use a fixed CDP port for the real launch.
Sourcepub fn color_scheme(self, color_scheme: ColorScheme) -> Self
pub fn color_scheme(self, color_scheme: ColorScheme) -> Self
Set the color scheme for media emulation.
Sourcepub fn launch_timeout(self, timeout: Duration) -> Self
pub fn launch_timeout(self, timeout: Duration) -> Self
Override the browser launch timeout.
Sourcepub fn sandbox(self, sandbox: bool) -> Self
pub fn sandbox(self, sandbox: bool) -> Self
Enable or disable the Chromium sandbox for the launched browser.
Sourcepub fn node_executable(self, executable: impl Into<PathBuf>) -> Self
pub fn node_executable(self, executable: impl Into<PathBuf>) -> Self
Override the Node.js executable used by Playwright/Puppeteer engines.
Sourcepub fn node_working_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn node_working_dir(self, dir: impl Into<PathBuf>) -> Self
Set the directory where Node resolves playwright or puppeteer.
Sourcepub fn automation_parity(self, automation_parity: bool) -> Self
pub fn automation_parity(self, automation_parity: bool) -> Self
Turn fingerprint parity with a hand-started Chrome on or off.
Sourcepub fn fingerprint(self, fingerprint: FingerprintProfile) -> Self
pub fn fingerprint(self, fingerprint: FingerprintProfile) -> Self
Set the environment pages should see.
Sourcepub fn downloads(self, downloads: impl Into<DownloadSetting>) -> Self
pub fn downloads(self, downloads: impl Into<DownloadSetting>) -> Self
Manage this browser’s downloads.
§Arguments
downloads-truefor the defaults,falsefor none, orDownloadOptions
Sourcepub fn all_chrome_args(&self) -> Result<Vec<String>>
pub fn all_chrome_args(&self) -> Result<Vec<String>>
The Chrome arguments an engine launch passes: the opt-in restrictions,
then args and extra_args, with repeated feature-list switches
merged and, with automation parity, the AutomationControlled off
switch the engine’s own switches need.
Browser Commander adds nothing else since issue #103; the old defaults
are the legacy-defaults restriction preset.
§Errors
Returns an error for an unknown restriction.
Sourcepub fn all_ignored_default_args(&self) -> Vec<String>
pub fn all_ignored_default_args(&self) -> Vec<String>
Engine default switches to suppress so the command line matches a
hand-started Chrome (LaunchMode::Engine only).
Merged with the caller’s ignore_default_args, because a switch the
engine appends after the caller’s arguments cannot be countered by
passing a different value for it.
Sourcepub fn get_user_data_dir(&self) -> PathBuf
👎Deprecated since 0.13.0: launch_browser uses a fresh temporary profile unless user_data_dir is set; read LaunchResult::browser.user_data_dir
pub fn get_user_data_dir(&self) -> PathBuf
launch_browser uses a fresh temporary profile unless user_data_dir is set; read LaunchResult::browser.user_data_dir
Get the user data directory, using a default if not specified.
Trait Implementations§
Source§impl Clone for LaunchOptions
impl Clone for LaunchOptions
Source§impl Debug for LaunchOptions
impl Debug for LaunchOptions
Auto Trait Implementations§
impl !RefUnwindSafe for LaunchOptions
impl !UnwindSafe for LaunchOptions
impl Freeze for LaunchOptions
impl Send for LaunchOptions
impl Sync for LaunchOptions
impl Unpin for LaunchOptions
impl UnsafeUnpin for LaunchOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more