Skip to content

Commit

Permalink
pulled has_arg out of its specific browsers capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtgs committed Apr 14, 2024
1 parent e495b0a commit 768e596
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions thirtyfour/src/common/capabilities/chromium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ pub trait ChromiumLikeCapabilities: BrowserCapabilitiesHelper {
self.insert_browser_option("args", to_value(args)?)
}

/// Return true if the specified arg is currently set.
fn has_arg(&self, arg: &str) -> bool {
self.args().iter().any(|s| s == arg)
}

/// Add the specified experimental option.
///
/// ## Example
Expand Down
15 changes: 10 additions & 5 deletions thirtyfour/src/common/capabilities/desiredcapabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ pub trait BrowserCapabilitiesHelper: CapabilitiesHelper {
/// The key containing the browser-specific capabilities.
const KEY: &'static str;

/// Get the current list of command-line arguments to `geckodriver` as a vec.
fn args(&self) -> Vec<String> {
self.browser_option("args").unwrap_or_default()
}

/// Add any Serialize-able object to the capabilities under the browser's custom key.
fn insert_browser_option(
&mut self,
Expand Down Expand Up @@ -271,6 +266,11 @@ pub trait BrowserCapabilitiesHelper: CapabilitiesHelper {
.and_then(|option| from_value(option.clone()).ok())
}

/// Get the current list of command-line arguments to `geckodriver` as a vec.
fn args(&self) -> Vec<String> {
self.browser_option("args").unwrap_or_default()
}

/// Remove the specified Chrome command-line argument if it had been added previously.
fn remove_arg(&mut self, arg: &str) -> WebDriverResult<()> {
let mut args = self.args();
Expand All @@ -281,6 +281,11 @@ pub trait BrowserCapabilitiesHelper: CapabilitiesHelper {
self.insert_browser_option("args", to_value(args)?)
}
}

/// Return true if the specified arg is currently set.
fn has_arg(&self, arg: &str) -> bool {
self.args().iter().any(|s| s == arg)
}
}

impl CapabilitiesHelper for Capabilities {
Expand Down
5 changes: 0 additions & 5 deletions thirtyfour/src/common/capabilities/firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ impl FirefoxCapabilities {
self.insert_browser_option("args", to_value(args)?)
}

/// Return true if the specified arg is currently set.
pub fn has_arg(&self, arg: &str) -> bool {
self.args().contains(&arg.to_string())
}

firefox_arg_wrapper! {
headless => "-headless"
}
Expand Down

0 comments on commit 768e596

Please sign in to comment.