webdriver: Add support for getActiveElement
authorJames Graham <james@hoppipolla.co.uk>
Fri, 08 May 2015 19:37:51 +0100
changeset 428028 4472cf9b6700cec86e388bec0e8ca53520afd485
parent 428027 bbf55a6d6c19198813cd6c816860ee402a66e975
child 428029 290a60be89b663571a83df1f913b6f58be2a743e
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: Add support for getActiveElement Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 4065017191f1054b62f8c17c2b07c412111e0022
testing/webdriver/src/command.rs
testing/webdriver/src/httpapi.rs
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -26,16 +26,17 @@ pub enum WebDriverCommand {
 //    FullscreenWindow // Not supported in marionette
     SwitchToWindow(SwitchToWindowParameters),
     SwitchToFrame(SwitchToFrameParameters),
     SwitchToParentFrame,
     FindElement(LocatorParameters),
     FindElements(LocatorParameters),
     FindElementElement(WebElement, LocatorParameters),
     FindElementElements(WebElement, LocatorParameters),
+    GetActiveElement,
     IsDisplayed(WebElement),
     IsSelected(WebElement),
     GetElementAttribute(WebElement, String),
     GetCSSValue(WebElement, String),
     GetElementText(WebElement),
     GetElementTagName(WebElement),
     GetElementRect(WebElement),
     IsEnabled(WebElement),
@@ -144,16 +145,17 @@ impl WebDriverMessage {
             Route::FindElementElements => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
                 let element = WebElement::new(element_id.to_string());
                 let parameters: LocatorParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::FindElementElements(element, parameters)
             },
+            Route::GetActiveElement => WebDriverCommand::GetActiveElement,
             Route::IsDisplayed => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
                 let element = WebElement::new(element_id.to_string());
                 WebDriverCommand::IsDisplayed(element)
             },
             Route::IsSelected => {
@@ -298,26 +300,27 @@ impl ToJson for WebDriverMessage {
         let mut data = BTreeMap::new();
         let parameters = match self.command {
             WebDriverCommand::NewSession |
             WebDriverCommand::DeleteSession | WebDriverCommand::GetCurrentUrl |
             WebDriverCommand::GoBack | WebDriverCommand::GoForward | WebDriverCommand::Refresh |
             WebDriverCommand::GetTitle | WebDriverCommand::GetWindowHandle |
             WebDriverCommand::GetWindowHandles | WebDriverCommand::Close |
             WebDriverCommand::GetWindowSize | WebDriverCommand::MaximizeWindow |
-            WebDriverCommand::SwitchToParentFrame | WebDriverCommand::IsDisplayed(_) |
-            WebDriverCommand::IsSelected(_) | WebDriverCommand::GetElementAttribute(_, _) |
-            WebDriverCommand::GetCSSValue(_, _) | WebDriverCommand::GetElementText(_) |
-            WebDriverCommand::GetElementTagName(_) | WebDriverCommand::GetElementRect(_) |
-            WebDriverCommand::IsEnabled(_) | WebDriverCommand::GetCookies |
-            WebDriverCommand::GetCookie(_) | WebDriverCommand::DeleteCookies |
-            WebDriverCommand::DeleteCookie(_) |WebDriverCommand::DismissAlert |
-            WebDriverCommand::AcceptAlert | WebDriverCommand::GetAlertText |
-            WebDriverCommand::ElementClick(_) | WebDriverCommand::ElementTap(_) |
-            WebDriverCommand::ElementClear(_) | WebDriverCommand::TakeScreenshot => {
+            WebDriverCommand::SwitchToParentFrame | WebDriverCommand::GetActiveElement |
+            WebDriverCommand::IsDisplayed(_) | WebDriverCommand::IsSelected(_) |
+            WebDriverCommand::GetElementAttribute(_, _) | WebDriverCommand::GetCSSValue(_, _) |
+            WebDriverCommand::GetElementText(_) | WebDriverCommand::GetElementTagName(_) |
+            WebDriverCommand::GetElementRect(_) | WebDriverCommand::IsEnabled(_) |
+            WebDriverCommand::GetCookies | WebDriverCommand::GetCookie(_) |
+            WebDriverCommand::DeleteCookies | WebDriverCommand::DeleteCookie(_) |
+            WebDriverCommand::DismissAlert | WebDriverCommand::AcceptAlert |
+            WebDriverCommand::GetAlertText | WebDriverCommand::ElementClick(_) |
+            WebDriverCommand::ElementTap(_) | WebDriverCommand::ElementClear(_) |
+            WebDriverCommand::TakeScreenshot => {
                 None
             },
             WebDriverCommand::Get(ref x) => Some(x.to_json()),
             WebDriverCommand::SetTimeouts(ref x) => Some(x.to_json()),
             WebDriverCommand::SetWindowSize(ref x) => Some(x.to_json()),
             WebDriverCommand::SwitchToWindow(ref x) => Some(x.to_json()),
             WebDriverCommand::SwitchToFrame(ref x) => Some(x.to_json()),
             WebDriverCommand::FindElement(ref x) => Some(x.to_json()),
--- a/testing/webdriver/src/httpapi.rs
+++ b/testing/webdriver/src/httpapi.rs
@@ -1,17 +1,17 @@
 use regex::{Regex, Captures};
 
 use hyper::method::Method;
 use hyper::method::Method::{Get, Post, Delete};
 
 use command::{WebDriverMessage};
 use error::{WebDriverResult, WebDriverError, ErrorStatus};
 
-static ROUTES: [(Method, &'static str, Route); 46] = [
+static ROUTES: [(Method, &'static str, Route); 47] = [
     (Post, "/session", Route::NewSession),
     (Delete, "/session/{sessionId}", Route::DeleteSession),
     (Post, "/session/{sessionId}/url", Route::Get),
     (Get, "/session/{sessionId}/url", Route::GetCurrentUrl),
     (Post, "/session/{sessionId}/back", Route::GoBack),
     (Post, "/session/{sessionId}/forward", Route::GoForward),
     (Post, "/session/{sessionId}/refresh", Route::Refresh),
     (Get, "/session/{sessionId}/title", Route::GetTitle),
@@ -23,16 +23,17 @@ static ROUTES: [(Method, &'static str, R
     (Post, "/session/{sessionId}/window/maximize", Route::MaximizeWindow),
     (Post, "/session/{sessionId}/window", Route::SwitchToWindow),
     (Post, "/session/{sessionId}/frame", Route::SwitchToFrame),
     (Post, "/session/{sessionId}/frame/parent", Route::SwitchToParentFrame),
     (Post, "/session/{sessionId}/element", Route::FindElement),
     (Post, "/session/{sessionId}/elements", Route::FindElements),
     (Post, "/session/{sessionId}/element/{elementId}/element", Route::FindElementElement),
     (Post, "/session/{sessionId}/element/{elementId}/elements", Route::FindElementElements),
+    (Get, "/session/{sessionId}/element/active", Route::GetActiveElement),
     (Get, "/session/{sessionId}/element/{elementId}/displayed", Route::IsDisplayed),
     (Get, "/session/{sessionId}/element/{elementId}/selected", Route::IsSelected),
     (Get, "/session/{sessionId}/element/{elementId}/attribute/{name}", Route::GetElementAttribute),
     (Get, "/session/{sessionId}/element/{elementId}/css/{propertyName}", Route::GetCSSValue),
     (Get, "/session/{sessionId}/element/{elementId}/text", Route::GetElementText),
     (Get, "/session/{sessionId}/element/{elementId}/name", Route::GetElementTagName),
     (Get, "/session/{sessionId}/element/{elementId}/rect", Route::GetElementRect),
     (Get, "/session/{sessionId}/element/{elementId}/enabled", Route::IsEnabled),
@@ -74,16 +75,17 @@ pub enum Route {
     MaximizeWindow,
     SwitchToWindow,
     SwitchToFrame,
     SwitchToParentFrame,
     FindElement,
     FindElements,
     FindElementElement,
     FindElementElements,
+    GetActiveElement,
     IsDisplayed,
     IsSelected,
     GetElementAttribute,
     GetCSSValue,
     GetElementText,
     GetElementTagName,
     GetElementRect,
     IsEnabled,