Skip to content

Commit

Permalink
Updating Java W3CHttpCommandCodec for window commands and element loc…
Browse files Browse the repository at this point in the history
…ation

Making the W3CHttpCommandCodec understand the get/setWindowRect end points
instead of separate end points for window size and position.

Additionally, updating the script used by
getElementLocationOnceScrolledIntoView to return a custom object instead
of just the serialized DOMRect structure. Not all browsers support 'x'
and 'y' properties of DOMRect, so when the language bindings attempt to
access those properties, an error is thrown.
  • Loading branch information
jimevans committed Mar 31, 2017
1 parent a6c1e04 commit 433eb06
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ public W3CHttpCommandCodec() {
alias(GET_SESSION_STORAGE_SIZE, EXECUTE_SCRIPT);

defineCommand(MAXIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/maximize"));
alias(GET_CURRENT_WINDOW_POSITION, EXECUTE_SCRIPT);
alias(SET_CURRENT_WINDOW_POSITION, EXECUTE_SCRIPT);
defineCommand(GET_CURRENT_WINDOW_SIZE, get("/session/:sessionId/window/size"));
defineCommand(SET_CURRENT_WINDOW_SIZE, post("/session/:sessionId/window/size"));
defineCommand(GET_CURRENT_WINDOW_SIZE, get("/session/:sessionId/window/rect"));
defineCommand(SET_CURRENT_WINDOW_SIZE, post("/session/:sessionId/window/rect"));
alias(GET_CURRENT_WINDOW_POSITION, GET_CURRENT_WINDOW_SIZE);
alias(SET_CURRENT_WINDOW_POSITION, SET_CURRENT_WINDOW_SIZE);
defineCommand(GET_CURRENT_WINDOW_HANDLE, get("/session/:sessionId/window"));
defineCommand(GET_WINDOW_HANDLES, get("/session/:sessionId/window/handles"));

Expand Down Expand Up @@ -187,7 +187,7 @@ public W3CHttpCommandCodec() {

case GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW:
return toScript(
"return arguments[0].getBoundingClientRect()",
"var rect = arguments[0].getBoundingClientRect(); return {'x': rect.left, 'y': rect.top};",
asElement(parameters.get("id")));

case GET_PAGE_SOURCE:
Expand Down

0 comments on commit 433eb06

Please sign in to comment.