webdriver: Align Send Alert Text To use same properties as Element Send Keys (#39)
authorDavid Burns <david.burns@theautomatedtester.co.uk>
Thu, 29 Sep 2016 14:22:02 +0100
changeset 428083 ec789f959a945b55d579a832ca125e75fe41ceb4
parent 428082 1b4d4044fe96f024ebf04a4886a959dfd1a2bb73
child 428084 3fde37a93ce5212b1fdf3041ddc096db74b4d96b
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
webdriver: Align Send Alert Text To use same properties as Element Send 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 <james@hoppipolla.co.uk>
testing/webdriver/src/command.rs
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -55,17 +55,17 @@ pub enum WebDriverCommand<T: WebDriverEx
     //Actions(ActionsParameters),
     ElementClick(WebElement),
     ElementTap(WebElement),
     ElementClear(WebElement),
     ElementSendKeys(WebElement, SendKeysParameters),
     DismissAlert,
     AcceptAlert,
     GetAlertText,
-    SendAlertText(SendAlertTextParameters),
+    SendAlertText(SendKeysParameters),
     TakeScreenshot,
     Extension(T)
 }
 
 pub trait WebDriverExtensionCommand : Clone + Send + PartialEq {
     fn parameters_json(&self) -> Option<Json>;
 }
 
@@ -310,17 +310,17 @@ impl <U: WebDriverExtensionRoute> WebDri
             },
             Route::AcceptAlert => {
                 WebDriverCommand::AcceptAlert
             },
             Route::GetAlertText => {
                 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,
             Route::Extension(ref extension) => {
                 try!(extension.command(params, &body_data))
             }
         };
         Ok(WebDriverMessage::new(session_id, command))
@@ -936,45 +936,16 @@ impl ToJson for AddCookieParameters {
         data.insert("expiry".to_string(), self.expiry.to_json());
         data.insert("secure".to_string(), self.secure.to_json());
         data.insert("httpOnly".to_string(), self.httpOnly.to_json());
         Json::Object(data)
     }
 }
 
 #[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>
 }
 
 impl Parameters for TakeScreenshotParameters {
     fn from_json(body: &Json) -> WebDriverResult<TakeScreenshotParameters> {
         let data = try_opt!(body.as_object(),
                             ErrorStatus::InvalidArgument,