pub struct Chromedriver { /* private fields */ }Expand description
A handle to a spawned chromedriver process plus its resolved Chrome / ChromeDriver binaries.
Terminates automatically when dropped, using the budget configured via
ChromedriverRunConfig::graceful_shutdown. The on-drop automation keeps tests safe in the
face of panics. Call Self::terminate to drive the same shutdown explicitly and surface any
error.
Drive WebDriver sessions through Self::with_session / Self::with_custom_session.
Sessions are independent, so multiple of them can run concurrently against the same chromedriver
via tokio::join! or tokio::spawn on a multi-thread runtime.
Implementations§
Source§impl Chromedriver
impl Chromedriver
Sourcepub async fn run_default() -> Result<Chromedriver, Report<ChromeForTestingManagerError>>
pub async fn run_default() -> Result<Chromedriver, Report<ChromeForTestingManagerError>>
Convenience: resolve, download, and launch chromedriver using
ChromedriverRunConfig::default. Equivalent to
Chromedriver::run(ChromedriverRunConfig::default()).await.
§Errors
Returns an error if the runtime is not multithreaded, version resolution fails, the download fails, or the chromedriver process cannot be spawned.
Sourcepub async fn run(
config: ChromedriverRunConfig,
) -> Result<Chromedriver, Report<ChromeForTestingManagerError>>
pub async fn run( config: ChromedriverRunConfig, ) -> Result<Chromedriver, Report<ChromeForTestingManagerError>>
Resolve, download, and launch a chromedriver process.
§Errors
Returns an error if the runtime is not multithreaded, version resolution fails, the download fails, or the chromedriver process cannot be spawned.
Sourcepub fn port(&self) -> Port
pub fn port(&self) -> Port
The port the chromedriver process is listening on.
When constructed with PortRequest::Any this reflects the OS-assigned port.
Sourcepub async fn terminate(
self,
) -> Result<ExitStatus, Report<ChromeForTestingManagerError>>
pub async fn terminate( self, ) -> Result<ExitStatus, Report<ChromeForTestingManagerError>>
Gracefully terminate the chromedriver process with the configured GracefulShutdown,
configurable via the graceful_shutdown field of ChromedriverRunConfig.
§Errors
Returns an error if the process cannot be terminated within the configured graceful-shutdown budget.
Sourcepub async fn with_session<T, E, F>(
&self,
f: F,
) -> Result<T, Report<ChromeForTestingManagerError>>
pub async fn with_session<T, E, F>( &self, f: F, ) -> Result<T, Report<ChromeForTestingManagerError>>
Execute an async closure with a WebDriver session.
The session will be automatically cleaned up after the closure completes.
§Errors
Returns an error if session creation fails or the user closure returns an error.
Sourcepub async fn with_custom_session<T, E, F>(
&self,
setup: impl FnOnce(&mut ChromeCapabilities) -> Result<(), WebDriverError>,
f: F,
) -> Result<T, Report<ChromeForTestingManagerError>>
pub async fn with_custom_session<T, E, F>( &self, setup: impl FnOnce(&mut ChromeCapabilities) -> Result<(), WebDriverError>, f: F, ) -> Result<T, Report<ChromeForTestingManagerError>>
Execute an async closure with a custom-configured WebDriver session.
The session will be automatically cleaned up after the closure completes.
§Errors
Returns an error if capability setup, session creation, or the user closure fails.