pub struct ChromeCapabilities {
pub base_capabilities: CapabilityRequest,
pub chrome_options: ChromeOptions,
}Expand description
Chrome-specific capabilities for configuring browser behavior.
This struct provides a fluent API for setting Chrome capabilities and options.
Use the builder methods to configure the browser, then call build() to generate
the capabilities request for session creation.
§Examples
use rustenium::browsers::ChromeCapabilities;
let mut caps = ChromeCapabilities::default();
caps.add_arg("--headless")
.add_arg("--disable-gpu")
.accept_insecure_certs(true);
let capabilities_request = caps.build();Fields§
§base_capabilities: CapabilityRequest§chrome_options: ChromeOptionsImplementations§
Source§impl ChromeCapabilities
impl ChromeCapabilities
Sourcepub fn new(base_capabilities: Option<CapabilityRequest>) -> Self
pub fn new(base_capabilities: Option<CapabilityRequest>) -> Self
Creates a new ChromeCapabilities instance.
Sourcepub fn accept_insecure_certs(&mut self, accept: bool) -> &mut Self
pub fn accept_insecure_certs(&mut self, accept: bool) -> &mut Self
Sets whether to accept insecure (self-signed) certificates.
Sourcepub fn browser_name(&mut self, name: impl Into<String>) -> &mut Self
pub fn browser_name(&mut self, name: impl Into<String>) -> &mut Self
Sets the browser name.
Sourcepub fn browser_version(&mut self, version: impl Into<String>) -> &mut Self
pub fn browser_version(&mut self, version: impl Into<String>) -> &mut Self
Sets the desired browser version.
Sourcepub fn platform_name(&mut self, platform: impl Into<String>) -> &mut Self
pub fn platform_name(&mut self, platform: impl Into<String>) -> &mut Self
Sets the platform name.
Sourcepub fn proxy(&mut self, proxy: ProxyConfiguration) -> &mut Self
pub fn proxy(&mut self, proxy: ProxyConfiguration) -> &mut Self
Configures proxy settings.
Sourcepub fn unhandled_prompt_behavior(
&mut self,
behavior: UserPromptHandler,
) -> &mut Self
pub fn unhandled_prompt_behavior( &mut self, behavior: UserPromptHandler, ) -> &mut Self
Sets how to handle unhandled prompts.
Sourcepub fn add_arg(&mut self, arg: impl Into<String>) -> &mut Self
pub fn add_arg(&mut self, arg: impl Into<String>) -> &mut Self
Adds a single Chrome command-line argument (e.g., “–headless”, “–disable-gpu”).
Sourcepub fn add_args<I, S>(&mut self, new_args: I) -> &mut Self
pub fn add_args<I, S>(&mut self, new_args: I) -> &mut Self
Adds multiple Chrome command-line arguments.
Sourcepub fn binary(&mut self, binary: impl Into<String>) -> &mut Self
pub fn binary(&mut self, binary: impl Into<String>) -> &mut Self
Sets the path to the Chrome binary.
Sourcepub fn extensions(&mut self, extensions: Vec<String>) -> &mut Self
pub fn extensions(&mut self, extensions: Vec<String>) -> &mut Self
Sets Chrome extensions to load (as base64-encoded .crx files).
Sourcepub fn add_extension(&mut self, extension: impl Into<String>) -> &mut Self
pub fn add_extension(&mut self, extension: impl Into<String>) -> &mut Self
Adds a Chrome extension to load.
Sourcepub fn local_state(&mut self, local_state: HashMap<String, Value>) -> &mut Self
pub fn local_state(&mut self, local_state: HashMap<String, Value>) -> &mut Self
Sets Chrome’s local state preferences.
Sourcepub fn prefs(&mut self, prefs: HashMap<String, Value>) -> &mut Self
pub fn prefs(&mut self, prefs: HashMap<String, Value>) -> &mut Self
Sets Chrome user preferences.
Sourcepub fn add_pref(&mut self, key: impl Into<String>, value: Value) -> &mut Self
pub fn add_pref(&mut self, key: impl Into<String>, value: Value) -> &mut Self
Adds a single Chrome user preference.
Sourcepub fn detach(&mut self, detach: bool) -> &mut Self
pub fn detach(&mut self, detach: bool) -> &mut Self
Sets whether Chrome should continue running after the driver disconnects.
Sourcepub fn debugger_address(&mut self, address: impl Into<String>) -> &mut Self
pub fn debugger_address(&mut self, address: impl Into<String>) -> &mut Self
Sets the debugger address to connect to an existing Chrome instance.
Sourcepub fn exclude_switches(&mut self, switches: Vec<String>) -> &mut Self
pub fn exclude_switches(&mut self, switches: Vec<String>) -> &mut Self
Sets command-line switches to exclude.
Sourcepub fn add_exclude_switch(&mut self, switch: impl Into<String>) -> &mut Self
pub fn add_exclude_switch(&mut self, switch: impl Into<String>) -> &mut Self
Adds a command-line switch to exclude.
Sourcepub fn minidump_path(&mut self, path: impl Into<String>) -> &mut Self
pub fn minidump_path(&mut self, path: impl Into<String>) -> &mut Self
Sets the directory path for Chrome minidump files.
Sourcepub fn mobile_emulation(
&mut self,
emulation: HashMap<String, Value>,
) -> &mut Self
pub fn mobile_emulation( &mut self, emulation: HashMap<String, Value>, ) -> &mut Self
Configures mobile device emulation.
Sourcepub fn perf_logging_prefs(&mut self, prefs: PerfLoggingPrefs) -> &mut Self
pub fn perf_logging_prefs(&mut self, prefs: PerfLoggingPrefs) -> &mut Self
Sets performance logging preferences.
Sourcepub fn window_types(&mut self, types: Vec<String>) -> &mut Self
pub fn window_types(&mut self, types: Vec<String>) -> &mut Self
Sets which window types to consider.
Sourcepub fn add_window_type(&mut self, window_type: impl Into<String>) -> &mut Self
pub fn add_window_type(&mut self, window_type: impl Into<String>) -> &mut Self
Adds a window type to consider.
Sourcepub fn enable_extension_targets(&mut self, enable: bool) -> &mut Self
pub fn enable_extension_targets(&mut self, enable: bool) -> &mut Self
Sets whether to enable extension targets.
Sourcepub fn use_automation_extension(&mut self, use_it: bool) -> &mut Self
pub fn use_automation_extension(&mut self, use_it: bool) -> &mut Self
Sets whether to use the automation extension.
Sourcepub fn build(self) -> CapabilitiesRequest
pub fn build(self) -> CapabilitiesRequest
Builds the final CapabilitiesRequest for session creation.
Trait Implementations§
Source§impl Clone for ChromeCapabilities
impl Clone for ChromeCapabilities
Source§fn clone(&self) -> ChromeCapabilities
fn clone(&self) -> ChromeCapabilities
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChromeCapabilities
impl Debug for ChromeCapabilities
Auto Trait Implementations§
impl Freeze for ChromeCapabilities
impl RefUnwindSafe for ChromeCapabilities
impl Send for ChromeCapabilities
impl Sync for ChromeCapabilities
impl Unpin for ChromeCapabilities
impl UnwindSafe for ChromeCapabilities
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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