Skip to content

Commit

Permalink
webdriver: Align Send Alert Text To use same properties as Element Se…
Browse files Browse the repository at this point in the history
…nd Keys (#39)

Instead of Send Alert Text using 'text' it now uses 'value' allowing
us to simplify the parameter checking.

Source-Repo: https://github.com/mozilla/webdriver-rust
Source-Revision: a0240f01f13b8e7e8fcc4cc3b0929675e9e3297c

committer: jgraham <[email protected]>

--HG--
extra : subtree_source : http%3A//tristan.corp.lon2.mozilla.com%3A8000
extra : subtree_revision : 337e13ac8c2f968fae708ccf92829381d107fd50
  • Loading branch information
AutomatedTester committed Sep 29, 2016
1 parent 9888a6b commit 3936278
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions testing/webdriver/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum WebDriverCommand<T: WebDriverExtensionCommand> {
DismissAlert,
AcceptAlert,
GetAlertText,
SendAlertText(SendAlertTextParameters),
SendAlertText(SendKeysParameters),
TakeScreenshot,
Extension(T)
}
Expand Down Expand Up @@ -315,7 +315,7 @@ impl <U: WebDriverExtensionRoute> WebDriverMessage<U> {
WebDriverCommand::GetAlertText
},
Route::SendAlertText => {
let parameters: SendAlertTextParameters = try!(Parameters::from_json(&body_data));
let parameters: SendKeysParameters = try!(Parameters::from_json(&body_data));
WebDriverCommand::SendAlertText(parameters)
},
Route::TakeScreenshot => WebDriverCommand::TakeScreenshot,
Expand Down Expand Up @@ -940,35 +940,6 @@ impl ToJson for AddCookieParameters {
}
}

#[derive(PartialEq)]
pub struct SendAlertTextParameters {
message: String
}

impl Parameters for SendAlertTextParameters {
fn from_json(body: &Json) -> WebDriverResult<SendAlertTextParameters> {
let data = try_opt!(body.as_object(), ErrorStatus::InvalidArgument,
"Message body was not an object");
let keys = try_opt!(
try_opt!(data.get("text"),
ErrorStatus::InvalidArgument,
"Missing 'text' parameter").as_string(),
ErrorStatus::InvalidArgument,
"'text' not a string").to_string();
return Ok(SendAlertTextParameters {
message: keys
})
}
}

impl ToJson for SendAlertTextParameters {
fn to_json(&self) -> Json {
let mut data = BTreeMap::new();
data.insert("message".to_string(), self.message.to_json());
Json::Object(data)
}
}

#[derive(PartialEq)]
pub struct TakeScreenshotParameters {
pub element: Nullable<WebElement>
Expand Down

0 comments on commit 3936278

Please sign in to comment.