Skip to main content

ChromeForTestingManager

Struct ChromeForTestingManager 

Source
pub struct ChromeForTestingManager { /* private fields */ }
Expand description

Lower-level orchestrator for chrome-for-testing artifacts.

Most users should use crate::Chromedriver, which wraps this manager with sensible defaults and handles process lifecycle automatically. Reach for ChromeForTestingManager directly when you need finer control:

  • Pre-warm a cache without spawning chromedriver: call Self::resolve_version and Self::download, then drop the result.
  • Run multiple chromedriver instances off a single resolved version: call Self::launch_chromedriver repeatedly with the same LoadedChromePackage.
  • Inspect or modify the resolved version before downloading (channel, available platforms).
  • Pin a custom cache directory via Self::new_with_cache_dir (useful in CI).
  • Drive sessions through a non-thirtyfour WebDriver client by using the chromedriver process and port directly.

Implementations§

Source§

impl ChromeForTestingManager

Source

pub fn new() -> Result<Self, Report<ChromeForTestingManagerError>>

Create a manager that uses the platform-default cache directory.

§Errors

Returns an error if the current platform is unsupported or the cache directory cannot be determined or created.

Source

pub fn new_with_cache_dir( cache_dir: PathBuf, ) -> Result<Self, Report<ChromeForTestingManagerError>>

Create a manager that caches downloaded artifacts under cache_dir.

The directory is created if it does not exist. Useful in CI to share the cache across runs, or to keep artifacts out of the user-default cache location.

§Errors

Returns an error if the current platform is unsupported or the directory cannot be created.

Source

pub async fn clear_cache( &self, ) -> Result<(), Report<ChromeForTestingManagerError>>

§Errors

Returns an error if the cache directory cannot be deleted or re-created.

Source

pub async fn resolve_version( &self, version_selection: VersionRequest, ) -> Result<SelectedVersion, Report<ChromeForTestingManagerError>>

Resolve a VersionRequest against the chrome-for-testing release index.

Returns a SelectedVersion suitable for Self::download. No artifacts are downloaded at this point; this only performs the HTTP requests needed to determine which version to fetch.

§Errors

Returns an error if the version manifest cannot be fetched or no matching version exists.

Source

pub async fn download( &self, selected: SelectedVersion, ) -> Result<LoadedChromePackage, Report<ChromeForTestingManagerError>>

Download Chrome and ChromeDriver for selected into the cache directory.

If both binaries already exist on disk this is a no-op and returns the cached paths.

§Errors

Returns an error if no platform-matching download exists, the cache directory cannot be prepared, or the download / extraction fails.

Source

pub async fn launch_chromedriver( &self, loaded: &LoadedChromePackage, port: PortRequest, output_listener: Option<DriverOutputListener>, shutdown: GracefulShutdown, ) -> Result<(ProcessHandle<BroadcastOutputStream<ReliableWithBackpressure, ReplayEnabled>>, Port, DriverOutputInspectors), Report<ChromeForTestingManagerError>>

Launch a chromedriver process from loaded on the requested port.

Returns the spawned process handle, the actual bound port (relevant when PortRequest::Any was used), and the long-lived output inspectors that drive the optional DriverOutputListener. Keep the inspectors alive while you want to receive output lines.

The returned ProcessHandle is not auto-terminated. Either wrap it with ProcessHandle::terminate_on_drop or call its terminate method explicitly. The shutdown argument is only used for the internal cleanup path that fires when chromedriver fails to report successful startup. Pass the same value you intend to use for graceful shutdown so a startup failure honors your tuned budget.

§Errors

Returns an error if the chromedriver binary cannot be spawned or does not report successful startup within 10 seconds.

§Panics

Panics if the chromedriver executable path contains non-Unicode bytes.

Source

pub fn prepare_caps( &self, loaded: &LoadedChromePackage, ) -> Result<ChromeCapabilities, Report<ChromeForTestingManagerError>>

Prepare a thirtyfour::ChromeCapabilities pre-wired with the loaded Chrome binary path and the headless flag set.

Useful when constructing a thirtyfour::WebDriver manually instead of using crate::Chromedriver::with_session.

§Errors

Returns an error if the underlying capability setup fails.

§Panics

Panics if the cached Chrome executable path contains non-Unicode bytes.

Trait Implementations§

Source§

impl Debug for ChromeForTestingManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<O> ObjectMarkerFor<Local> for O
where O: 'static,

Source§

impl<O> ObjectMarkerFor<SendSync> for O
where O: 'static + Send + Sync,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Sink for T
where T: Send + 'static,