webdriver: Add support for GetCookies, DeleteCookies and DeleteCookie commands
authorJames Graham <james@hoppipolla.co.uk>
Fri, 01 May 2015 16:58:01 +0100
changeset 428026 d49aaeea1f7e9571871423d7caa3a99514591a57
parent 428025 c9cf1c59019f3a59159a331f580f649c060c50f1
child 428027 bbf55a6d6c19198813cd6c816860ee402a66e975
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 GetCookies, DeleteCookies and DeleteCookie commands Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: be7d51eff155eeb37ae841836a47d37df6730f90
testing/webdriver/src/command.rs
testing/webdriver/src/httpapi.rs
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -36,18 +36,21 @@ pub enum WebDriverCommand {
     GetElementAttribute(WebElement, String),
     GetCSSValue(WebElement, String),
     GetElementText(WebElement),
     GetElementTagName(WebElement),
     GetElementRect(WebElement),
     IsEnabled(WebElement),
     ExecuteScript(JavascriptCommandParameters),
     ExecuteAsyncScript(JavascriptCommandParameters),
-    GetCookie,
+    GetCookies,
+    GetCookie(String),
     AddCookie(AddCookieParameters),
+    DeleteCookies,
+    DeleteCookie(String),
     SetTimeouts(TimeoutsParameters),
     //Actions(ActionsParameters),
     ElementClick(WebElement),
     ElementTap(WebElement),
     ElementClear(WebElement),
     ElementSendKeys(WebElement, SendKeysParameters),
     DismissAlert,
     AcceptAlert,
@@ -240,23 +243,38 @@ impl WebDriverMessage {
             Route::ExecuteScript => {
                 let parameters: JavascriptCommandParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::ExecuteScript(parameters)
             },
             Route::ExecuteAsyncScript => {
                 let parameters: JavascriptCommandParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::ExecuteAsyncScript(parameters)
             },
+            Route::GetCookies => {
+                WebDriverCommand::GetCookies
+            },
             Route::GetCookie => {
-                WebDriverCommand::GetCookie
+                let name = try_opt!(params.name("name"),
+                                    ErrorStatus::InvalidArgument,
+                                    "Missing name parameter").to_string();
+                WebDriverCommand::GetCookie(name)
             },
             Route::AddCookie => {
                 let parameters: AddCookieParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::AddCookie(parameters)
             },
+            Route::DeleteCookies => {
+                WebDriverCommand::DeleteCookies
+            },
+            Route::DeleteCookie => {
+                let name = try_opt!(params.name("name"),
+                                    ErrorStatus::InvalidArgument,
+                                    "Missing name parameter").to_string();
+                WebDriverCommand::DeleteCookie(name)
+            },
             Route::DismissAlert => {
                 WebDriverCommand::DismissAlert
             },
             Route::AcceptAlert => {
                 WebDriverCommand::AcceptAlert
             },
             Route::GetAlertText => {
                 WebDriverCommand::GetAlertText
@@ -284,21 +302,22 @@ impl ToJson for WebDriverMessage {
             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::GetCookie |
-            WebDriverCommand::DismissAlert | WebDriverCommand::AcceptAlert |
-            WebDriverCommand::GetAlertText | WebDriverCommand::ElementClick(_) |
-            WebDriverCommand::ElementTap(_) | WebDriverCommand::ElementClear(_) |
-            WebDriverCommand::TakeScreenshot => {
+            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); 43] = [
+static ROUTES: [(Method, &'static str, Route); 46] = [
     (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),
@@ -33,18 +33,21 @@ static ROUTES: [(Method, &'static str, R
     (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),
     (Post, "/session/{sessionId}/execute", Route::ExecuteScript),
     (Post, "/session/{sessionId}/execute_async", Route::ExecuteAsyncScript),
-    (Get, "/session/{sessionId}/cookie", Route::GetCookie),
+    (Get, "/session/{sessionId}/cookie", Route::GetCookies),
+    (Get, "/session/{sessionId}/cookie/{name}", Route::GetCookie),
     (Post, "/session/{sessionId}/cookie", Route::AddCookie),
+    (Delete, "/session/{sessionId}/cookie", Route::DeleteCookies),
+    (Delete, "/session/{sessionId}/cookie/{name}", Route::DeleteCookie),
     (Post, "/session/{sessionId}/timeouts", Route::SetTimeouts),
     //(Post, "/session/{sessionId}/actions", Route::Actions),
     (Post, "/session/{sessionId}/element/{elementId}/click", Route::ElementClick),
     (Post, "/session/{sessionId}/element/{elementId}/tap", Route::ElementTap),
     (Post, "/session/{sessionId}/element/{elementId}/clear", Route::ElementClear),
     (Post, "/session/{sessionId}/element/{elementId}/value", Route::ElementSendKeys),
     (Post, "/session/{sessionId}/dismiss_alert", Route::DismissAlert),
     (Post, "/session/{sessionId}/accept_alert", Route::AcceptAlert),
@@ -81,18 +84,21 @@ pub enum Route {
     GetElementAttribute,
     GetCSSValue,
     GetElementText,
     GetElementTagName,
     GetElementRect,
     IsEnabled,
     ExecuteScript,
     ExecuteAsyncScript,
+    GetCookies,
     GetCookie,
     AddCookie,
+    DeleteCookies,
+    DeleteCookie,
     SetTimeouts,
     //Actions XXX - once I understand the spec, perhaps
     ElementClick,
     ElementTap,
     ElementClear,
     ElementSendKeys,
     DismissAlert,
     AcceptAlert,