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_versionandSelf::download, then drop the result. - Run multiple chromedriver instances off a single resolved version: call
Self::launch_chromedriverrepeatedly with the sameLoadedChromePackage. - 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-
thirtyfourWebDriverclient by using the chromedriver process and port directly.
Implementations§
Source§impl ChromeForTestingManager
impl ChromeForTestingManager
Sourcepub fn new() -> Result<Self, Report<ChromeForTestingManagerError>>
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.
Sourcepub fn new_with_cache_dir(
cache_dir: PathBuf,
) -> Result<Self, Report<ChromeForTestingManagerError>>
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.
Sourcepub async fn clear_cache(
&self,
) -> Result<(), Report<ChromeForTestingManagerError>>
pub async fn clear_cache( &self, ) -> Result<(), Report<ChromeForTestingManagerError>>
§Errors
Returns an error if the cache directory cannot be deleted or re-created.
Sourcepub async fn resolve_version(
&self,
version_selection: VersionRequest,
) -> Result<SelectedVersion, Report<ChromeForTestingManagerError>>
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.
Sourcepub async fn download(
&self,
selected: SelectedVersion,
) -> Result<LoadedChromePackage, Report<ChromeForTestingManagerError>>
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.
Sourcepub async fn launch_chromedriver(
&self,
loaded: &LoadedChromePackage,
port: PortRequest,
output_listener: Option<DriverOutputListener>,
shutdown: GracefulShutdown,
) -> Result<(ProcessHandle<BroadcastOutputStream<ReliableWithBackpressure, ReplayEnabled>>, Port, DriverOutputInspectors), Report<ChromeForTestingManagerError>>
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.
Sourcepub fn prepare_caps(
&self,
loaded: &LoadedChromePackage,
) -> Result<ChromeCapabilities, Report<ChromeForTestingManagerError>>
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.