Skip to content

Commit 9dbc7a8

Browse files
committed
Remove internal config
1 parent e1530c2 commit 9dbc7a8

4 files changed

Lines changed: 8 additions & 87 deletions

File tree

src/common/config.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/common/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
pub mod capabilities;
22
pub mod command;
3-
pub mod config;
43
pub mod types;

src/session/handle.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use serde_json::Value;
2-
use std::fmt;
3-
use std::fmt::{Debug, Formatter};
42
use std::future::Future;
53
use std::path::Path;
64
use std::time::Duration;
@@ -10,10 +8,9 @@ use tokio::io::AsyncWriteExt;
108
use fantoccini::cookies::Cookie;
119
use fantoccini::elements::Element;
1210
use fantoccini::error::CmdError;
13-
use fantoccini::wd::{Capabilities, TimeoutConfiguration, WebDriverStatus, WindowHandle};
11+
use fantoccini::wd::{TimeoutConfiguration, WebDriverStatus, WindowHandle};
1412

1513
use crate::action_chain::ActionChain;
16-
use crate::common::config::WebDriverConfig;
1714
use crate::error::{WebDriverError, WebDriverResult};
1815
use crate::session::scriptret::ScriptRet;
1916
use crate::{By, Rect, SessionId, SwitchTo, WebElement};
@@ -23,26 +20,23 @@ use crate::{By, Rect, SessionId, SwitchTo, WebElement};
2320
#[derive(Clone)]
2421
pub struct SessionHandle {
2522
pub client: fantoccini::Client,
26-
pub config: WebDriverConfig,
23+
pub session_id: String,
2724
}
2825

29-
impl Debug for SessionHandle {
30-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
31-
write!(f, "{}", self.config.get_session_id())
26+
impl std::fmt::Debug for SessionHandle {
27+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28+
f.debug_struct("SessionHandle").field("session_id", &self.session_id).finish()
3229
}
3330
}
3431

3532
impl SessionHandle {
3633
/// Create new SessionHandle from a fantoccini Client.
3734
#[allow(dead_code)]
38-
pub(crate) async fn new(
39-
client: fantoccini::Client,
40-
capabilities: Capabilities,
41-
) -> WebDriverResult<Self> {
35+
pub(crate) async fn new(client: fantoccini::Client) -> WebDriverResult<Self> {
4236
let session_id = client.session_id().await?.expect("session id to be valid");
4337
Ok(Self {
4438
client,
45-
config: WebDriverConfig::new(SessionId::from(session_id), capabilities),
39+
session_id,
4640
})
4741
}
4842

@@ -51,24 +45,12 @@ impl SessionHandle {
5145
WebElement::new(element, self.clone())
5246
}
5347

54-
/// Return a clone of the capabilities as originally requested.
55-
pub fn capabilities(&mut self) -> Capabilities {
56-
self.config.get_capabilities()
57-
}
58-
5948
/// Get the session ID.
6049
pub async fn session_id(&self) -> WebDriverResult<SessionId> {
6150
let id = self.client.session_id().await?;
6251
Ok(SessionId::from(id.unwrap_or_default()))
6352
}
6453

65-
/// Get a clone of the `WebDriverConfig`.
66-
///
67-
/// You can update the config by modifying it directly.
68-
pub fn config(&self) -> WebDriverConfig {
69-
self.config.clone()
70-
}
71-
7254
/// Get the WebDriver status.
7355
///
7456
/// # Example

src/webdriver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use fantoccini::wd::Capabilities;
2626
/// # })
2727
/// # }
2828
/// ```
29-
#[derive(Debug)]
3029
pub struct WebDriver {
3130
pub handle: SessionHandle,
3231
}
@@ -80,7 +79,7 @@ impl WebDriver {
8079
client.update_timeouts(timeouts).await?;
8180

8281
Ok(Self {
83-
handle: SessionHandle::new(client, caps).await?,
82+
handle: SessionHandle::new(client).await?,
8483
})
8584
}
8685
}

0 commit comments

Comments
 (0)