pub struct WebDriverBuilder { /* private fields */ }Expand description
Builder for WebDriver sessions that talk to an externally-managed
driver (e.g. a Selenium Grid, a manually-launched chromedriver, or any
W3C-compatible WebDriver server).
Construct via WebDriver::builder. Awaiting the builder opens the
session.
§Example
let caps = DesiredCapabilities::chrome();
let driver = WebDriver::builder("http://localhost:4444", caps)
.request_timeout(Duration::from_secs(30))
.user_agent("my-app/1.0")
.await?;For driver-managed sessions (auto-download + spawn), use
WebDriver::managed instead.
Implementations§
Source§impl WebDriverBuilder
impl WebDriverBuilder
Sourcepub fn keep_alive(self, keep_alive: bool) -> Self
pub fn keep_alive(self, keep_alive: bool) -> Self
Set the Connection: keep-alive header on outgoing requests.
Default: true.
Sourcepub fn poller(self, poller: Arc<dyn IntoElementPoller + Send + Sync>) -> Self
pub fn poller(self, poller: Arc<dyn IntoElementPoller + Send + Sync>) -> Self
Set the element poller used by WebDriver::query and
WebElement::wait_until.
Sourcepub fn user_agent<V>(self, user_agent: V) -> Self
pub fn user_agent<V>(self, user_agent: V) -> Self
Override the User-Agent header sent with WebDriver requests.
Default: WebDriverConfig::DEFAULT_USER_AGENT.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Override the per-request HTTP timeout. Default: 120s. Applied to the
default reqwest-based client; custom HttpClient implementations
supplied via WebDriverBuilder::client may also honour it.
Sourcepub fn client(self, client: impl HttpClient + 'static) -> Self
pub fn client(self, client: impl HttpClient + 'static) -> Self
Use a custom HttpClient instead of the default reqwest-based one.
Useful for plugging in a proxy, custom TLS configuration, or running
without the reqwest feature.
Sourcepub async fn connect(self) -> WebDriverResult<WebDriver>
pub async fn connect(self) -> WebDriverResult<WebDriver>
Open the session.