From 1e90fdea44a035d572cc5fa5ba285828cce09833 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Sun, 6 Mar 2016 20:48:51 +0200 Subject: [PATCH] Removed position api --- source/api.d | 21 ++++++--------------- source/session.d | 26 ++++++++------------------ source/test.d | 12 +++++------- 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/source/api.d b/source/api.d index 42d5726..34a91a8 100755 --- a/source/api.d +++ b/source/api.d @@ -352,26 +352,17 @@ struct SeleniumApi { return this; } - auto windowSize(string handle, Size size) { - POST("/window/" ~ handle ~ "/size", size); + auto windowSize(Size size) { + POST("/window/size", size); return this; } - auto windowSize(string handle) { - return GET!Size("/window/" ~ handle ~ "/size"); + auto windowSize() { + return GET!Size("/window/size"); } - auto windowPosition(string handle, Position position) { - POST("/window/" ~ handle ~ "/position", position); - return this; - } - - auto windowPosition(string handle) { - return GET!Position("/window/" ~ handle ~ "/position"); - } - - auto windowMaximize(string handle) { - POST("/window/" ~ handle ~ "/maximize"); + auto windowMaximize() { + POST("/window/maximize"); return this; } diff --git a/source/session.d b/source/session.d index dbc6aa6..75e8c55 100644 --- a/source/session.d +++ b/source/session.d @@ -4,7 +4,6 @@ import selenium.api; class SeleniumSession { - SeleniumApi api; this(string serverUrl, @@ -18,12 +17,14 @@ class SeleniumSession { SeleniumWindow currentWindow() { return new SeleniumWindow(api.windowHandle, api); } - } class SeleniumWindow { - string handle; - SeleniumApi api; + + protected { + string handle; + SeleniumApi api; + } this(string handle, SeleniumApi api) { this.handle = handle; @@ -31,23 +32,15 @@ class SeleniumWindow { } Size size() { - return api.windowSize(handle); + return api.windowSize; } void size(Size value) { - api.windowSize(handle, value); - } - - Position position() { - return api.windowPosition(handle); - } - - void position(Position value) { - api.windowPosition(handle, value); + api.windowSize(value); } void maximize() { - api.windowMaximize(handle); + api.windowMaximize; } } @@ -57,8 +50,5 @@ unittest { session.currentWindow.size = Size(400, 500); assert(session.currentWindow.size == Size(400, 500)); - session.currentWindow.position = Position(100, 200); - assert(session.currentWindow.position == Position(100, 200)); - session.currentWindow.maximize; } diff --git a/source/test.d b/source/test.d index e4a910d..1d7d12f 100644 --- a/source/test.d +++ b/source/test.d @@ -6,7 +6,7 @@ import vibe.data.json; import std.datetime; -unittest {/+ +unittest { auto url1 = "http://www.amazon.com/All-Light-We-Cannot-See/dp/1476746583/"; auto url2 = "http://www.amazon.com/The-Boys-Boat-Americans-Olympics/dp/0143125478/"; @@ -50,12 +50,10 @@ unittest {/+ //session.selectWindow("testOpen"); //session.closeCurrentWindow(); - assert(session.windowSize(handle, Size(400, 500)).windowSize(handle) == Size(400, 500)); - assert(session.windowPosition(handle, Position(100, 200)).windowPosition(handle) == Position(100, 200)); + assert(session.windowSize(Size(400, 500)).windowSize == Size(400, 500)); - session.windowMaximize(handle); - assert(session.windowSize(handle) != Size(400, 500)); - assert(session.windowPosition(handle) != Position(100, 200)); + session.windowMaximize; + assert(session.windowSize != Size(400, 500)); assert(session.cookie.length > 0); @@ -185,5 +183,5 @@ unittest {/+ //session.applicationCacheStatus(); - session.disconnect;+/ + session.disconnect; }