diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..972cd4e Binary files /dev/null and b/.DS_Store differ diff --git a/thirtyfour/.DS_Store b/thirtyfour/.DS_Store new file mode 100644 index 0000000..fc1d333 Binary files /dev/null and b/thirtyfour/.DS_Store differ diff --git a/thirtyfour/src/common/config.rs b/thirtyfour/src/common/config.rs index 898817d..e4e04cc 100644 --- a/thirtyfour/src/common/config.rs +++ b/thirtyfour/src/common/config.rs @@ -6,6 +6,7 @@ use crate::{ use const_format::formatcp; use http::HeaderValue; use std::sync::Arc; +use std::time::Duration; /// Configuration options used by a `WebDriver` instance and the related `SessionHandle`. /// @@ -19,6 +20,8 @@ pub struct WebDriverConfig { pub poller: Arc, /// The user agent to use when sending commands to the webdriver server. pub user_agent: HeaderValue, + /// The timeout duration for reqwest client requests. + pub reqwest_timeout: Duration, } impl Default for WebDriverConfig { @@ -68,6 +71,7 @@ pub struct WebDriverConfigBuilder { keep_alive: bool, poller: Option>, user_agent: Option>, + reqwest_timeout: Duration, } impl Default for WebDriverConfigBuilder { @@ -83,6 +87,7 @@ impl WebDriverConfigBuilder { keep_alive: true, poller: None, user_agent: None, + reqwest_timeout: Duration::from_secs(120), } } @@ -108,12 +113,19 @@ impl WebDriverConfigBuilder { self } + /// Set the reqwest timeout. + pub fn reqwest_timeout(mut self, timeout: Duration) -> Self { + self.reqwest_timeout = timeout; + self + } + /// Build `WebDriverConfig` using builder options. pub fn build(self) -> WebDriverResult { Ok(WebDriverConfig { keep_alive: self.keep_alive, poller: self.poller.unwrap_or_else(|| Arc::new(ElementPollerWithTimeout::default())), user_agent: self.user_agent.transpose()?.unwrap_or(WebDriverConfig::DEFAULT_USER_AGENT), + reqwest_timeout: self.reqwest_timeout, }) } } diff --git a/thirtyfour/src/web_driver.rs b/thirtyfour/src/web_driver.rs index 51fb80a..a975de5 100644 --- a/thirtyfour/src/web_driver.rs +++ b/thirtyfour/src/web_driver.rs @@ -95,9 +95,9 @@ impl WebDriver { S: Into, C: Into, { - // TODO: create builder and make timeout configurable. + // TODO: create builder #[cfg(feature = "reqwest")] - let client = create_reqwest_client(std::time::Duration::from_secs(120)); + let client = create_reqwest_client(config.reqwest_timeout); #[cfg(not(feature = "reqwest"))] let client = crate::session::http::null_client::create_null_client(); Self::new_with_config_and_client(server_url, capabilities, config, client).await