Skip to content

Commit

Permalink
geckodriver: Implement SetWindowPosition and GetWindowPosition
Browse files Browse the repository at this point in the history
Source-Repo: https://github.com/mozilla/geckodriver
Source-Revision: cb1b7996d19f4884c697274a6379c8936e7e3772

--HG--
extra : rebase_source : 84fd92754df00fdd78f4f7f2101d6dae60f3fee9
  • Loading branch information
AutomatedTester committed Oct 5, 2016
1 parent 808393b commit 9737146
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions testing/geckodriver/src/marionette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ use webdriver::command::WebDriverCommand::{
ElementClick, ElementTap, ElementClear, ElementSendKeys,
ExecuteScript, ExecuteAsyncScript, GetCookies, GetCookie, AddCookie,
DeleteCookies, DeleteCookie, SetTimeouts, DismissAlert,
AcceptAlert, GetAlertText, SendAlertText, TakeScreenshot, Extension};
AcceptAlert, GetAlertText, SendAlertText, TakeScreenshot, Extension,
SetWindowPosition, GetWindowPosition};
use webdriver::command::{
NewSessionParameters, GetParameters, WindowSizeParameters, SwitchToWindowParameters,
SwitchToFrameParameters, LocatorParameters, JavascriptCommandParameters,
GetCookieParameters, AddCookieParameters, TimeoutsParameters,
TakeScreenshotParameters};
TakeScreenshotParameters, WindowPositionParameters};
use webdriver::response::{
WebDriverResponse, NewSessionResponse, ValueResponse, WindowSizeResponse,
ElementRectResponse, CookieResponse, Cookie};
WindowPositionResponse, ElementRectResponse, CookieResponse, Cookie};
use webdriver::common::{
Date, Nullable, WebElement, FrameId, ELEMENT_KEY};
use webdriver::error::{
Expand Down Expand Up @@ -756,7 +757,7 @@ impl MarionetteSession {
//Things that simply return the contents of the marionette "value" property
GetCurrentUrl | GetTitle | GetPageSource | GetWindowHandle | IsDisplayed(_) |
IsSelected(_) | GetElementAttribute(_, _) | GetElementProperty(_, _) |
GetCSSValue(_, _) | GetElementText(_) |
GetCSSValue(_, _) | GetElementText(_) | SetWindowPosition(_) |
GetElementTagName(_) | IsEnabled(_) | ExecuteScript(_) | ExecuteAsyncScript(_) |
GetAlertText | TakeScreenshot => {
let value = try_opt!(resp.result.find("value"),
Expand Down Expand Up @@ -785,6 +786,23 @@ impl MarionetteSession {

WebDriverResponse::WindowSize(WindowSizeResponse::new(width, height))
},
GetWindowPosition => {
let x = try_opt!(
try_opt!(resp.result.find("x"),
ErrorStatus::UnknownError,
"Failed to find x field").as_u64(),
ErrorStatus::UnknownError,
"Failed to interpret x as integer");

let y = try_opt!(
try_opt!(resp.result.find("y"),
ErrorStatus::UnknownError,
"Failed to find y field").as_u64(),
ErrorStatus::UnknownError,
"Failed to interpret y as integer");

WebDriverResponse::WindowPosition(WindowPositionResponse::new(x, y))
},
GetElementRect(_) => {
let x = try_opt!(
try_opt!(resp.result.find("x"),
Expand Down Expand Up @@ -1024,6 +1042,8 @@ impl MarionetteCommand {
SetTimeouts(ref x) => (Some("timeouts"), Some(x.to_marionette())),
SetWindowSize(ref x) => (Some("setWindowSize"), Some(x.to_marionette())),
GetWindowSize => (Some("getWindowSize"), None),
SetWindowPosition(ref x) => (Some("setWindowPosition"), Some(x.to_marionette())),
GetWindowPosition => (Some("getWindowPosition"), None),
MaximizeWindow => (Some("maximizeWindow"), None),
SwitchToWindow(ref x) => (Some("switchToWindow"), Some(x.to_marionette())),
SwitchToFrame(ref x) => (Some("switchToFrame"), Some(x.to_marionette())),
Expand Down Expand Up @@ -1450,6 +1470,12 @@ impl ToMarionette for WindowSizeParameters {
}
}

impl ToMarionette for WindowPositionParameters {
fn to_marionette(&self) -> WebDriverResult<BTreeMap<String, Json>> {
Ok(try_opt!(self.to_json().as_object(), ErrorStatus::UnknownError, "Expected an object").clone())
}
}

impl ToMarionette for SwitchToWindowParameters {
fn to_marionette(&self) -> WebDriverResult<BTreeMap<String, Json>> {
let mut data = BTreeMap::new();
Expand Down

0 comments on commit 9737146

Please sign in to comment.