Bug 1486793 - [webdriver] Fix regression in "Take Element Screenshot" from conversion to Serde. r=ato
authorHenrik Skupin <mail@hskupin.info>
Wed, 29 Aug 2018 10:15:32 +0200
changeset 482246 21ee44075725031af6d66389a4e58ae0d13c2e15
parent 482245 ceb6a933997ff79a4c9b45e04c18c09ae8dc7c4b
child 482247 e2251ddcafd236d667b5ebb4908429bc88c99de8
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersato
bugs1486793
milestone63.0a1
Bug 1486793 - [webdriver] Fix regression in "Take Element Screenshot" from conversion to Serde. r=ato The command "Take Element Screenshot" expects the web element as parameter, and not as part of the body.
testing/webdriver/src/command.rs
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -59,17 +59,17 @@ pub enum WebDriverCommand<T: WebDriverEx
     ElementSendKeys(WebElement, SendKeysParameters),
     PerformActions(ActionsParameters),
     ReleaseActions,
     DismissAlert,
     AcceptAlert,
     GetAlertText,
     SendAlertText(SendKeysParameters),
     TakeScreenshot,
-    TakeElementScreenshot(TakeScreenshotParameters),
+    TakeElementScreenshot(WebElement),
     Status,
     Extension(T),
 }
 
 pub trait WebDriverExtensionCommand: Clone + Send + PartialEq {
     fn parameters_json(&self) -> Option<Value>;
 }
 
@@ -325,17 +325,23 @@ impl<U: WebDriverExtensionRoute> WebDriv
             Route::DismissAlert => WebDriverCommand::DismissAlert,
             Route::AcceptAlert => WebDriverCommand::AcceptAlert,
             Route::GetAlertText => WebDriverCommand::GetAlertText,
             Route::SendAlertText => {
                 WebDriverCommand::SendAlertText(serde_json::from_str(raw_body)?)
             }
             Route::TakeScreenshot => WebDriverCommand::TakeScreenshot,
             Route::TakeElementScreenshot => {
-                WebDriverCommand::TakeElementScreenshot(serde_json::from_str(raw_body)?)
+                let element_id = try_opt!(
+                    params.name("elementId"),
+                    ErrorStatus::InvalidArgument,
+                    "Missing elementId parameter"
+                );
+                let element = WebElement::new(element_id.as_str().into());
+                WebDriverCommand::TakeElementScreenshot(element)
             }
             Route::Status => WebDriverCommand::Status,
             Route::Extension(ref extension) => try!(extension.command(params, &body_data)),
         };
         Ok(WebDriverMessage::new(session_id, command))
     }
 
     fn get_session_id(params: &Captures) -> Option<String> {